From 3d90e94b6081d367c906f1948e05a8ca9de9c267 Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Sat, 26 Oct 2024 09:58:27 +0000 Subject: [PATCH] feat(be): clear migrations --- db/sql/migrations/v0.0.0.sql | 18 ++++++++++-------- db/sql/migrations/v1.4.0.sql | 17 +++++++++++------ db/sql/migrations/v2.2.1.sql | 16 ---------------- db/sql/migrations/v2.7.4.sql | 1 - db/sql/migrations/v2.8.20.sql | 14 -------------- 5 files changed, 21 insertions(+), 45 deletions(-) diff --git a/db/sql/migrations/v0.0.0.sql b/db/sql/migrations/v0.0.0.sql index ed69212b..01bb82f5 100644 --- a/db/sql/migrations/v0.0.0.sql +++ b/db/sql/migrations/v0.0.0.sql @@ -17,6 +17,7 @@ create table `project` ( ); create table `project__user` ( + `id` integer primary key autoincrement, `project_id` int not null, `user_id` int not null, `admin` boolean not null default false, @@ -101,12 +102,13 @@ create table `task` ( foreign key (`template_id`) references project__template(`id`) on delete cascade ); -create table `task__output` ( - `task_id` int not null, - `task` varchar(255) not null, - `time` datetime not null, - `output` longtext not null, +create table task__output +( + id integer primary key autoincrement, + task_id int not null, + task varchar(255) not null, + time datetime not null, + output longtext not null, - unique (`task_id`, `time`), - foreign key (`task_id`) references task(`id`) on delete cascade -); + foreign key (`task_id`) references task(`id`) on delete cascade +); \ No newline at end of file diff --git a/db/sql/migrations/v1.4.0.sql b/db/sql/migrations/v1.4.0.sql index 635532ea..690e6f3d 100644 --- a/db/sql/migrations/v1.4.0.sql +++ b/db/sql/migrations/v1.4.0.sql @@ -1,9 +1,14 @@ -CREATE TABLE `event` ( - `project_id` int DEFAULT NULL, - `object_id` int DEFAULT NULL, - `object_type` varchar(20) DEFAULT '', - `description` text, - `created` datetime NOT NULL +create table `event` +( + `id` integer primary key autoincrement, + `project_id` int, + `object_id` int, + `object_type` varchar(20) DEFAULT '', + `description` text, + `created` datetime NOT NULL, + `user_id` int, + foreign key (`project_id`) references `project` (`id`) on delete cascade, + foreign key (`user_id`) references `user` (`id`) on delete set null ); alter table `task` add `created` datetime null; diff --git a/db/sql/migrations/v2.2.1.sql b/db/sql/migrations/v2.2.1.sql index 2cf48247..e69de29b 100644 --- a/db/sql/migrations/v2.2.1.sql +++ b/db/sql/migrations/v2.2.1.sql @@ -1,16 +0,0 @@ -alter table task__output rename to task__output_backup; - -create table task__output -( - id integer primary key autoincrement, - task_id int not null, - task varchar(255) not null, - time datetime not null, - output longtext not null, - - foreign key (`task_id`) references task(`id`) on delete cascade -); - -insert into task__output(task_id, task, time, output) select * from task__output_backup; - -drop table task__output_backup; diff --git a/db/sql/migrations/v2.7.4.sql b/db/sql/migrations/v2.7.4.sql index 647b07c9..e69de29b 100644 --- a/db/sql/migrations/v2.7.4.sql +++ b/db/sql/migrations/v2.7.4.sql @@ -1 +0,0 @@ -alter table `event` add `user_id` int null references `user`(`id`); diff --git a/db/sql/migrations/v2.8.20.sql b/db/sql/migrations/v2.8.20.sql index 3cd5d28b..e69de29b 100644 --- a/db/sql/migrations/v2.8.20.sql +++ b/db/sql/migrations/v2.8.20.sql @@ -1,14 +0,0 @@ -alter table `event` rename to `event_backup_5784568`; - -create table `event` -( - `id` integer primary key autoincrement, - `project_id` int, - `object_id` int, - `object_type` varchar(20) DEFAULT '', - `description` text, - `created` datetime NOT NULL, - `user_id` int, - foreign key (`project_id`) references `project` (`id`) on delete cascade, - foreign key (`user_id`) references `user` (`id`) on delete set null -);