feat(be): clear migrations

This commit is contained in:
Denis Gukov 2024-10-26 09:58:27 +00:00
parent 1f3f598f11
commit 3d90e94b60
5 changed files with 21 additions and 45 deletions

View File

@ -17,6 +17,7 @@ create table `project` (
); );
create table `project__user` ( create table `project__user` (
`id` integer primary key autoincrement,
`project_id` int not null, `project_id` int not null,
`user_id` int not null, `user_id` int not null,
`admin` boolean not null default false, `admin` boolean not null default false,
@ -101,12 +102,13 @@ create table `task` (
foreign key (`template_id`) references project__template(`id`) on delete cascade foreign key (`template_id`) references project__template(`id`) on delete cascade
); );
create table `task__output` ( create table task__output
`task_id` int not null, (
`task` varchar(255) not null, id integer primary key autoincrement,
`time` datetime not null, task_id int not null,
`output` longtext 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 );
);

View File

@ -1,9 +1,14 @@
CREATE TABLE `event` ( create table `event`
`project_id` int DEFAULT NULL, (
`object_id` int DEFAULT NULL, `id` integer primary key autoincrement,
`object_type` varchar(20) DEFAULT '', `project_id` int,
`description` text, `object_id` int,
`created` datetime NOT NULL `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; alter table `task` add `created` datetime null;

View File

@ -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;

View File

@ -1 +0,0 @@
alter table `event` add `user_id` int null references `user`(`id`);

View File

@ -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
);