feat(boards): add responsive layout system (#2271)
This commit is contained in:
42
packages/db/migrations/sqlite/0029_add_layouts.sql
Normal file
42
packages/db/migrations/sqlite/0029_add_layouts.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
CREATE TABLE `item_layout` (
|
||||
`item_id` text NOT NULL,
|
||||
`section_id` text NOT NULL,
|
||||
`layout_id` text NOT NULL,
|
||||
`x_offset` integer NOT NULL,
|
||||
`y_offset` integer NOT NULL,
|
||||
`width` integer NOT NULL,
|
||||
`height` integer NOT NULL,
|
||||
PRIMARY KEY(`item_id`, `section_id`, `layout_id`),
|
||||
FOREIGN KEY (`item_id`) REFERENCES `item`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`layout_id`) REFERENCES `layout`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `layout` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`board_id` text NOT NULL,
|
||||
`column_count` integer NOT NULL,
|
||||
`breakpoint` integer DEFAULT 0 NOT NULL,
|
||||
FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `section_layout` (
|
||||
`section_id` text NOT NULL,
|
||||
`layout_id` text NOT NULL,
|
||||
`parent_section_id` text,
|
||||
`x_offset` integer NOT NULL,
|
||||
`y_offset` integer NOT NULL,
|
||||
`width` integer NOT NULL,
|
||||
`height` integer NOT NULL,
|
||||
PRIMARY KEY(`section_id`, `layout_id`),
|
||||
FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`layout_id`) REFERENCES `layout`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`parent_section_id`) REFERENCES `section`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> 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,47 @@
|
||||
-- Custom SQL migration file, put your code below! --
|
||||
COMMIT TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys=OFF;
|
||||
--> statement-breakpoint
|
||||
BEGIN TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `__new_item` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`board_id` text NOT NULL,
|
||||
`kind` text NOT NULL,
|
||||
`options` text DEFAULT '{"json": {}}' NOT NULL,
|
||||
`advanced_options` text DEFAULT '{"json": {}}' NOT NULL,
|
||||
FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_item`("id", "board_id", "kind", "options", "advanced_options") SELECT "item"."id", "section"."board_id", "item"."kind", "item"."options", "item"."advanced_options" FROM `item` LEFT JOIN `section` ON section.id=item.section_id;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `item`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `__new_item` RENAME TO `item`;
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `__new_section` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`board_id` text NOT NULL,
|
||||
`kind` text NOT NULL,
|
||||
`x_offset` integer,
|
||||
`y_offset` integer,
|
||||
`name` text,
|
||||
FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_section`("id", "board_id", "kind", "x_offset", "y_offset", "name") SELECT "id", "board_id", "kind", "x_offset", "y_offset", "name" FROM `section`;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `section`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `__new_section` RENAME TO `section`;
|
||||
--> statement-breakpoint
|
||||
UPDATE `section` SET `x_offset` = NULL, `y_offset` = NULL WHERE `kind` = 'dynamic';
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `board` DROP COLUMN `column_count`;
|
||||
--> statement-breakpoint
|
||||
COMMIT TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys=ON;
|
||||
--> statement-breakpoint
|
||||
BEGIN TRANSACTION;
|
||||
1932
packages/db/migrations/sqlite/meta/0029_snapshot.json
Normal file
1932
packages/db/migrations/sqlite/meta/0029_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1932
packages/db/migrations/sqlite/meta/0030_snapshot.json
Normal file
1932
packages/db/migrations/sqlite/meta/0030_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -204,6 +204,20 @@
|
||||
"when": 1740086746417,
|
||||
"tag": "0028_add_app_ping_url",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 29,
|
||||
"version": "6",
|
||||
"when": 1740255687392,
|
||||
"tag": "0029_add_layouts",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 30,
|
||||
"version": "6",
|
||||
"when": 1740255968549,
|
||||
"tag": "0030_migrate_item_and_section_for_layouts",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user