feat(boards): add responsive layout system (#2271)
This commit is contained in:
50
packages/db/migrations/mysql/0029_add_layouts.sql
Normal file
50
packages/db/migrations/mysql/0029_add_layouts.sql
Normal file
@@ -0,0 +1,50 @@
|
||||
CREATE TABLE `item_layout` (
|
||||
`item_id` varchar(64) NOT NULL,
|
||||
`section_id` varchar(64) NOT NULL,
|
||||
`layout_id` varchar(64) NOT NULL,
|
||||
`x_offset` int NOT NULL,
|
||||
`y_offset` int NOT NULL,
|
||||
`width` int NOT NULL,
|
||||
`height` int NOT NULL,
|
||||
CONSTRAINT `item_layout_item_id_section_id_layout_id_pk` PRIMARY KEY(`item_id`,`section_id`,`layout_id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `layout` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`name` varchar(32) NOT NULL,
|
||||
`board_id` varchar(64) NOT NULL,
|
||||
`column_count` tinyint NOT NULL,
|
||||
`breakpoint` smallint NOT NULL DEFAULT 0,
|
||||
CONSTRAINT `layout_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `section_layout` (
|
||||
`section_id` varchar(64) NOT NULL,
|
||||
`layout_id` varchar(64) NOT NULL,
|
||||
`parent_section_id` varchar(64),
|
||||
`x_offset` int NOT NULL,
|
||||
`y_offset` int NOT NULL,
|
||||
`width` int NOT NULL,
|
||||
`height` int NOT NULL,
|
||||
CONSTRAINT `section_layout_section_id_layout_id_pk` PRIMARY KEY(`section_id`,`layout_id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item_layout` ADD CONSTRAINT `item_layout_item_id_item_id_fk` FOREIGN KEY (`item_id`) REFERENCES `item`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item_layout` ADD CONSTRAINT `item_layout_section_id_section_id_fk` FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item_layout` ADD CONSTRAINT `item_layout_layout_id_layout_id_fk` FOREIGN KEY (`layout_id`) REFERENCES `layout`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `layout` ADD CONSTRAINT `layout_board_id_board_id_fk` FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section_layout` ADD CONSTRAINT `section_layout_section_id_section_id_fk` FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section_layout` ADD CONSTRAINT `section_layout_layout_id_layout_id_fk` FOREIGN KEY (`layout_id`) REFERENCES `layout`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section_layout` ADD CONSTRAINT `section_layout_parent_section_id_section_id_fk` FOREIGN KEY (`parent_section_id`) REFERENCES `section`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `layout`(`id`, `name`, `board_id`, `column_count`) SELECT `id`, 'Base', `id`, `column_count` FROM `board`;
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `item_layout`(`item_id`, `section_id`, `layout_id`, `x_offset`, `y_offset`, `width`, `height`) SELECT `item`.`id`, `section`.`id`, `board`.`id`, `item`.`x_offset`, `item`.`y_offset`, `item`.`width`, `item`.`height` FROM `board` LEFT JOIN `section` ON `section`.`board_id`=`board`.`id` LEFT JOIN `item` ON `item`.`section_id`=`section`.`id` WHERE `item`.`id` IS NOT NULL;
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `section_layout`(`section_id`, `layout_id`, `parent_section_id`, `x_offset`, `y_offset`, `width`, `height`) SELECT `section`.`id`, `board`.`id`, `section`.`parent_section_id`, `section`.`x_offset`, `section`.`y_offset`, `section`.`width`, `section`.`height` FROM `board` LEFT JOIN `section` ON `section`.`board_id`=`board`.`id` WHERE `section`.`id` IS NOT NULL AND `section`.`kind` = 'dynamic';
|
||||
@@ -0,0 +1,36 @@
|
||||
-- Custom SQL migration file, put your code below! --
|
||||
ALTER TABLE `item` DROP FOREIGN KEY `item_section_id_section_id_fk`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section` DROP FOREIGN KEY `section_parent_section_id_section_id_fk`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section` MODIFY COLUMN `x_offset` int;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section` MODIFY COLUMN `y_offset` int;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item` ADD `board_id` varchar(64);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item` ADD CONSTRAINT `item_board_id_board_id_fk` FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
UPDATE `item` JOIN `section` ON `item`.`section_id`=`section`.`id` SET `item`.`board_id` = `section`.`board_id`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item` MODIFY COLUMN `board_id` varchar(64) NOT NULL;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `board` DROP COLUMN `column_count`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item` DROP COLUMN `section_id`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item` DROP COLUMN `x_offset`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item` DROP COLUMN `y_offset`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item` DROP COLUMN `width`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `item` DROP COLUMN `height`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section` DROP COLUMN `width`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section` DROP COLUMN `height`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section` DROP COLUMN `parent_section_id`;
|
||||
--> statement-breakpoint
|
||||
UPDATE `section` SET `x_offset` = NULL, `y_offset` = NULL WHERE `kind` = 'dynamic';
|
||||
2012
packages/db/migrations/mysql/meta/0029_snapshot.json
Normal file
2012
packages/db/migrations/mysql/meta/0029_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
2012
packages/db/migrations/mysql/meta/0030_snapshot.json
Normal file
2012
packages/db/migrations/mysql/meta/0030_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -204,6 +204,20 @@
|
||||
"when": 1740086765989,
|
||||
"tag": "0028_add_app_ping_url",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 29,
|
||||
"version": "5",
|
||||
"when": 1740255915876,
|
||||
"tag": "0029_add_layouts",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 30,
|
||||
"version": "5",
|
||||
"when": 1740256006328,
|
||||
"tag": "0030_migrate_item_and_section_for_layouts",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user