summaryrefslogtreecommitdiff
path: root/app/Schema
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-03-27 16:21:15 -0400
committerFrederic Guillot <fred@kanboard.net>2016-03-27 16:21:15 -0400
commit004fde30f7cc0dd4864c50f8d804da9679f524fa (patch)
treee3122c89e16b4abb97166494009835115b30b5e8 /app/Schema
parentf11fccd0d78ab037e77cd973a9168eedcb609fc2 (diff)
Update SQL dumps and improve schema migration process
Diffstat (limited to 'app/Schema')
-rw-r--r--app/Schema/Mysql.php2
-rw-r--r--app/Schema/Sql/mysql.sql17
-rw-r--r--app/Schema/Sql/postgres.sql67
3 files changed, 53 insertions, 33 deletions
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index a041b3dc..934b063f 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -15,6 +15,8 @@ function version_110(PDO $pdo)
$pdo->exec("DROP INDEX `project_id` ON user_has_notifications");
$pdo->exec("ALTER TABLE user_has_notifications DROP KEY `user_id`");
$pdo->exec("CREATE UNIQUE INDEX `user_has_notifications_unique_idx` ON `user_has_notifications` (`user_id`, `project_id`)");
+ $pdo->exec("ALTER TABLE user_has_notifications ADD CONSTRAINT user_has_notifications_ibfk_1 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE");
+ $pdo->exec("ALTER TABLE user_has_notifications ADD CONSTRAINT user_has_notifications_ibfk_2 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE");
}
function version_109(PDO $pdo)
diff --git a/app/Schema/Sql/mysql.sql b/app/Schema/Sql/mysql.sql
index b5620400..ce2374f0 100644
--- a/app/Schema/Sql/mysql.sql
+++ b/app/Schema/Sql/mysql.sql
@@ -273,6 +273,8 @@ CREATE TABLE `project_has_metadata` (
`project_id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`value` varchar(255) DEFAULT '',
+ `changed_by` int(11) NOT NULL DEFAULT '0',
+ `changed_on` int(11) NOT NULL DEFAULT '0',
UNIQUE KEY `project_id` (`project_id`,`name`),
CONSTRAINT `project_has_metadata_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -357,6 +359,8 @@ DROP TABLE IF EXISTS `settings`;
CREATE TABLE `settings` (
`option` varchar(100) NOT NULL,
`value` varchar(255) DEFAULT '',
+ `changed_by` int(11) NOT NULL DEFAULT '0',
+ `changed_on` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`option`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -469,6 +473,8 @@ CREATE TABLE `task_has_metadata` (
`task_id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`value` varchar(255) DEFAULT '',
+ `changed_by` int(11) NOT NULL DEFAULT '0',
+ `changed_on` int(11) NOT NULL DEFAULT '0',
UNIQUE KEY `task_id` (`task_id`,`name`),
CONSTRAINT `task_has_metadata_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -548,6 +554,8 @@ CREATE TABLE `user_has_metadata` (
`user_id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`value` varchar(255) DEFAULT '',
+ `changed_by` int(11) NOT NULL DEFAULT '0',
+ `changed_on` int(11) NOT NULL DEFAULT '0',
UNIQUE KEY `user_id` (`user_id`,`name`),
CONSTRAINT `user_has_metadata_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -570,8 +578,8 @@ DROP TABLE IF EXISTS `user_has_notifications`;
CREATE TABLE `user_has_notifications` (
`user_id` int(11) NOT NULL,
`project_id` int(11) NOT NULL,
- UNIQUE KEY `project_id` (`project_id`,`user_id`),
- KEY `user_id` (`user_id`),
+ UNIQUE KEY `user_has_notifications_unique_idx` (`user_id`,`project_id`),
+ KEY `user_has_notifications_ibfk_2` (`project_id`),
CONSTRAINT `user_has_notifications_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
CONSTRAINT `user_has_notifications_ibfk_2` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -615,6 +623,7 @@ CREATE TABLE `users` (
`gitlab_id` int(11) DEFAULT NULL,
`role` varchar(25) NOT NULL DEFAULT 'app-user',
`is_active` tinyint(1) DEFAULT '1',
+ `avatar_path` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_username_idx` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -638,7 +647,7 @@ CREATE TABLE `users` (
LOCK TABLES `settings` WRITE;
/*!40000 ALTER TABLE `settings` DISABLE KEYS */;
-INSERT INTO `settings` VALUES ('api_token','cd9c46c6bdaa6afc49b3385dabe0b78c059bc124b1f72c2f47c9ca604cf1'),('application_currency','USD'),('application_date_format','m/d/Y'),('application_language','en_US'),('application_stylesheet',''),('application_timezone','UTC'),('application_url',''),('board_columns',''),('board_highlight_period','172800'),('board_private_refresh_interval','10'),('board_public_refresh_interval','60'),('calendar_project_tasks','date_started'),('calendar_user_subtasks_time_tracking','0'),('calendar_user_tasks','date_started'),('cfd_include_closed_tasks','1'),('default_color','yellow'),('integration_gravatar','0'),('password_reset','1'),('project_categories',''),('subtask_restriction','0'),('subtask_time_tracking','1'),('webhook_token','32387b121de8fe6031a6b71b7b1b9cae411a909539aa9d494cf69ac5f2ee'),('webhook_url','');
+INSERT INTO `settings` VALUES ('api_token','9c55053ae1d523893efc820e2e8338c4cf47f5c6c2c26861fec637eba62b',0,0),('application_currency','USD',0,0),('application_date_format','m/d/Y',0,0),('application_language','en_US',0,0),('application_stylesheet','',0,0),('application_timezone','UTC',0,0),('application_url','',0,0),('board_columns','',0,0),('board_highlight_period','172800',0,0),('board_private_refresh_interval','10',0,0),('board_public_refresh_interval','60',0,0),('calendar_project_tasks','date_started',0,0),('calendar_user_subtasks_time_tracking','0',0,0),('calendar_user_tasks','date_started',0,0),('cfd_include_closed_tasks','1',0,0),('default_color','yellow',0,0),('integration_gravatar','0',0,0),('password_reset','1',0,0),('project_categories','',0,0),('subtask_restriction','0',0,0),('subtask_time_tracking','1',0,0),('webhook_token','aaed762f4f6b0860902af0e2a87e5ad3427d24ff9e3ce8a2e0b005b58dfc',0,0),('webhook_url','',0,0);
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -667,4 +676,4 @@ UNLOCK TABLES;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$tyByY1dfUO9S.2wpJcSMEO4UU9H.yCwf/pmzo430DM2C4QZ/K3Kt2', 'app-admin');INSERT INTO schema_version VALUES ('107');
+INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$e.SftITKuBvXeNbxtmTKS.KAbIy4Mx09t254BAiEAuWOxkuS4xfLG', 'app-admin');INSERT INTO schema_version VALUES ('110');
diff --git a/app/Schema/Sql/postgres.sql b/app/Schema/Sql/postgres.sql
index c613ddb4..48a269d3 100644
--- a/app/Schema/Sql/postgres.sql
+++ b/app/Schema/Sql/postgres.sql
@@ -512,7 +512,9 @@ CREATE TABLE project_has_groups (
CREATE TABLE project_has_metadata (
project_id integer NOT NULL,
name character varying(50) NOT NULL,
- value character varying(255) DEFAULT ''::character varying
+ value character varying(255) DEFAULT ''::character varying,
+ changed_by integer DEFAULT 0 NOT NULL,
+ changed_on integer DEFAULT 0 NOT NULL
);
@@ -652,7 +654,9 @@ CREATE TABLE schema_version (
CREATE TABLE settings (
option character varying(100) NOT NULL,
- value character varying(255) DEFAULT ''::character varying
+ value character varying(255) DEFAULT ''::character varying,
+ changed_by integer DEFAULT 0 NOT NULL,
+ changed_on integer DEFAULT 0 NOT NULL
);
@@ -847,7 +851,9 @@ ALTER SEQUENCE task_has_links_id_seq OWNED BY task_has_links.id;
CREATE TABLE task_has_metadata (
task_id integer NOT NULL,
name character varying(50) NOT NULL,
- value character varying(255) DEFAULT ''::character varying
+ value character varying(255) DEFAULT ''::character varying,
+ changed_by integer DEFAULT 0 NOT NULL,
+ changed_on integer DEFAULT 0 NOT NULL
);
@@ -969,7 +975,9 @@ ALTER SEQUENCE transitions_id_seq OWNED BY transitions.id;
CREATE TABLE user_has_metadata (
user_id integer NOT NULL,
name character varying(50) NOT NULL,
- value character varying(255) DEFAULT ''::character varying
+ value character varying(255) DEFAULT ''::character varying,
+ changed_by integer DEFAULT 0 NOT NULL,
+ changed_on integer DEFAULT 0 NOT NULL
);
@@ -1070,7 +1078,8 @@ CREATE TABLE users (
lock_expiration_date bigint DEFAULT 0,
gitlab_id integer,
role character varying(25) DEFAULT 'app-user'::character varying NOT NULL,
- is_active boolean DEFAULT true
+ is_active boolean DEFAULT true,
+ avatar_path character varying(255)
);
@@ -2141,29 +2150,29 @@ SET search_path = public, pg_catalog;
-- Data for Name: settings; Type: TABLE DATA; Schema: public; Owner: postgres
--
-INSERT INTO settings (option, value) VALUES ('board_highlight_period', '172800');
-INSERT INTO settings (option, value) VALUES ('board_public_refresh_interval', '60');
-INSERT INTO settings (option, value) VALUES ('board_private_refresh_interval', '10');
-INSERT INTO settings (option, value) VALUES ('board_columns', '');
-INSERT INTO settings (option, value) VALUES ('webhook_token', 'c7caaf8f87ad391800e3989d7abfd98a6066a6f801fc151012bb5c4ee3cb');
-INSERT INTO settings (option, value) VALUES ('api_token', 'b0a6f56fe236fc9639fc6914e92365aa627d95cd790aa7e0c5a3ebebf844');
-INSERT INTO settings (option, value) VALUES ('application_language', 'en_US');
-INSERT INTO settings (option, value) VALUES ('application_timezone', 'UTC');
-INSERT INTO settings (option, value) VALUES ('application_url', '');
-INSERT INTO settings (option, value) VALUES ('application_date_format', 'm/d/Y');
-INSERT INTO settings (option, value) VALUES ('project_categories', '');
-INSERT INTO settings (option, value) VALUES ('subtask_restriction', '0');
-INSERT INTO settings (option, value) VALUES ('application_stylesheet', '');
-INSERT INTO settings (option, value) VALUES ('application_currency', 'USD');
-INSERT INTO settings (option, value) VALUES ('integration_gravatar', '0');
-INSERT INTO settings (option, value) VALUES ('calendar_user_subtasks_time_tracking', '0');
-INSERT INTO settings (option, value) VALUES ('calendar_user_tasks', 'date_started');
-INSERT INTO settings (option, value) VALUES ('calendar_project_tasks', 'date_started');
-INSERT INTO settings (option, value) VALUES ('webhook_url', '');
-INSERT INTO settings (option, value) VALUES ('default_color', 'yellow');
-INSERT INTO settings (option, value) VALUES ('subtask_time_tracking', '1');
-INSERT INTO settings (option, value) VALUES ('cfd_include_closed_tasks', '1');
-INSERT INTO settings (option, value) VALUES ('password_reset', '1');
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('board_highlight_period', '172800', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('board_public_refresh_interval', '60', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('board_private_refresh_interval', '10', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('board_columns', '', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('webhook_token', '67545fef6a0a3f43d60c7d57632d6e4af9930f064c12e72266b1c9b42381', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('api_token', 'c16b1c5896b258409a5eb344152b5b33c8ef4c58902bc543fc1348c37975', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('application_language', 'en_US', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('application_timezone', 'UTC', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('application_url', '', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('application_date_format', 'm/d/Y', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('project_categories', '', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('subtask_restriction', '0', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('application_stylesheet', '', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('application_currency', 'USD', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('integration_gravatar', '0', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('calendar_user_subtasks_time_tracking', '0', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('calendar_user_tasks', 'date_started', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('calendar_project_tasks', 'date_started', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('webhook_url', '', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('default_color', 'yellow', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('subtask_time_tracking', '1', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('cfd_include_closed_tasks', '1', 0, 0);
+INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('password_reset', '1', 0, 0);
--
@@ -2211,4 +2220,4 @@ SELECT pg_catalog.setval('links_id_seq', 11, true);
-- PostgreSQL database dump complete
--
-INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$tyByY1dfUO9S.2wpJcSMEO4UU9H.yCwf/pmzo430DM2C4QZ/K3Kt2', 'app-admin');INSERT INTO schema_version VALUES ('87');
+INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$e.SftITKuBvXeNbxtmTKS.KAbIy4Mx09t254BAiEAuWOxkuS4xfLG', 'app-admin');INSERT INTO schema_version VALUES ('89');