feat!: release v2 (#6545)
Co-authored-by: Artur <145776561+arturict@users.noreply.github.com> Co-authored-by: arturict <arturict@users.noreply.github.com> Co-authored-by: Thomas <thomas@ajnart.fr> Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com> Co-authored-by: Danura30082 <danura30082+github@gmail.com> Co-authored-by: Kushie <122986913+kushiemoon-dev@users.noreply.github.com> Co-authored-by: ajnart <thomas@ajnart.fr> Co-authored-by: ajnart <thomas@ajnart.dev> Co-authored-by: chenjun <chenjun@foxmail.com> Co-authored-by: Wikibear <wikibear@users.noreply.github.com> Co-authored-by: Bergasha <bergasha@gmail.com> Co-authored-by: leafyelin <43306196+leafyelin@users.noreply.github.com> Co-authored-by: Lucas Araujo <lucas.lra@gmail.com> Co-authored-by: GreenMonito <86085570+GreenMonito@users.noreply.github.com> Co-authored-by: Nerdy-Technician <roffo@nerdy-technician.social> Co-authored-by: Jun <34545896+jcstrong@users.noreply.github.com> Co-authored-by: Edmond Abraham <54119952+gitedmond@users.noreply.github.com> Co-authored-by: thrawnx <tight.bulb9384@fastmail.com> Co-authored-by: Chris <58918656+nordada@users.noreply.github.com> Co-authored-by: yi111 <153097222+Yi-111-a@users.noreply.github.com> Co-authored-by: Yanis <naamaneyanis@gmail.com> Co-authored-by: Wikibear <me@sej.de> Co-authored-by: alessiottavo <93441886+alessiottavo@users.noreply.github.com>
This commit is contained in:
3286 files changed
+284386
-139176
No files matched your search
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
test
|
||||
*.sqlite*
|
||||
@@ -0,0 +1,7 @@
|
||||
FROM node:24.18.0-bookworm-slim
|
||||
WORKDIR /converter
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --omit=dev --ignore-scripts
|
||||
COPY src ./src
|
||||
COPY legacy ./legacy
|
||||
ENTRYPOINT ["node", "src/cli.mjs"]
|
||||
@@ -0,0 +1,36 @@
|
||||
# MySQL to SQLite
|
||||
|
||||
One-off converter tested against the Homarr **v1.77.1 database schema**. It creates a v1.77.1 SQLite database; Homarr v2 applies its normal SQLite migrations when started with the output.
|
||||
|
||||
See the [migration guide](../../apps/docs/docs/advanced/mysql-to-sqlite.mdx) for backup, Docker commands, cutover, encryption-key preservation, and rollback.
|
||||
|
||||
## Run locally
|
||||
|
||||
Requires Node 24.18+ (24.x).
|
||||
|
||||
```sh
|
||||
npm ci
|
||||
# Supply MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE.
|
||||
# MYSQL_SSL_CA optionally points to a PEM CA file for TLS.
|
||||
node src/cli.mjs --output /new/path/db.sqlite --homarr-stopped
|
||||
```
|
||||
|
||||
Stop **all** Homarr processes using the source database first. A SELECT-only database account is sufficient. The converter checks the migration journal and table/column types before copying. Different schemas and incomplete migrations are rejected. The application binary version is not detected; older releases with identical schemas are compatible. Upgrade to the latest stable v1 release before conversion.
|
||||
|
||||
The source is read in one read-only snapshot. Every transferred value and table count is verified, followed by SQLite foreign-key and integrity checks. Only a successful copy is published to the requested path. Existing destinations are never overwritten. Interruptions leave the source unchanged; a forced kill may leave an unverified `.partial-*` file, which must not be used.
|
||||
|
||||
The converter does not read, rotate, or decrypt encryption keys. Keep the original `SECRET_ENCRYPTION_KEY` and appdata when starting v2. It does not copy filesystem assets or convert to PostgreSQL.
|
||||
|
||||
## Verification
|
||||
|
||||
```sh
|
||||
npm test
|
||||
```
|
||||
|
||||
Requires Docker on Linux. Tests initialize disposable MySQL 8.4.6 using the published Homarr v1.77.1 image migrator pinned by digest, then populate every legacy application table, convert with a SELECT-only account, verify preserved data and cancellation/failure behavior, and run the packaged Docker entrypoint. No existing service is contacted. `e2e/mysql-conversion.spec.ts` separately boots the current Homarr image twice with the converted file and verifies authentication, board rendering, media, and decrypted secrets.
|
||||
|
||||
## Frozen compatibility data
|
||||
|
||||
`legacy/v1.77.1` contains the unmodified MySQL and SQLite SQL migrations and journals from Homarr tag `v1.77.1`, commit `7859faaa1d9bc0bb883e6f2d09770daf44750ed1` (Apache-2.0, see the repository [license](../../LICENSE)). `schema.json` records the table/column mapping from that revision's final snapshots, with explicit SQLite timestamp units taken from its schema definitions.
|
||||
|
||||
Do not regenerate these files from v2 or format the SQL: migration hashes are checked against the source journal. Supporting a different source schema requires identified compatibility data and a real conversion fixture.
|
||||
@@ -0,0 +1,193 @@
|
||||
CREATE TABLE `account` (
|
||||
`userId` varchar(64) NOT NULL,
|
||||
`type` text NOT NULL,
|
||||
`provider` varchar(64) NOT NULL,
|
||||
`providerAccountId` varchar(64) NOT NULL,
|
||||
`refresh_token` text,
|
||||
`access_token` text,
|
||||
`expires_at` int,
|
||||
`token_type` text,
|
||||
`scope` text,
|
||||
`id_token` text,
|
||||
`session_state` text,
|
||||
CONSTRAINT `account_provider_providerAccountId_pk` PRIMARY KEY(`provider`,`providerAccountId`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `app` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`description` text,
|
||||
`icon_url` text NOT NULL,
|
||||
`href` text,
|
||||
CONSTRAINT `app_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `boardGroupPermission` (
|
||||
`board_id` varchar(64) NOT NULL,
|
||||
`group_id` varchar(64) NOT NULL,
|
||||
`permission` varchar(128) NOT NULL,
|
||||
CONSTRAINT `boardGroupPermission_board_id_group_id_permission_pk` PRIMARY KEY(`board_id`,`group_id`,`permission`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `boardUserPermission` (
|
||||
`board_id` varchar(64) NOT NULL,
|
||||
`user_id` varchar(64) NOT NULL,
|
||||
`permission` varchar(128) NOT NULL,
|
||||
CONSTRAINT `boardUserPermission_board_id_user_id_permission_pk` PRIMARY KEY(`board_id`,`user_id`,`permission`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `board` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`name` varchar(256) NOT NULL,
|
||||
`is_public` boolean NOT NULL DEFAULT false,
|
||||
`creator_id` varchar(64),
|
||||
`page_title` text,
|
||||
`meta_title` text,
|
||||
`logo_image_url` text,
|
||||
`favicon_image_url` text,
|
||||
`background_image_url` text,
|
||||
`background_image_attachment` text NOT NULL DEFAULT ('fixed'),
|
||||
`background_image_repeat` text NOT NULL DEFAULT ('no-repeat'),
|
||||
`background_image_size` text NOT NULL DEFAULT ('cover'),
|
||||
`primary_color` text NOT NULL DEFAULT ('#fa5252'),
|
||||
`secondary_color` text NOT NULL DEFAULT ('#fd7e14'),
|
||||
`opacity` int NOT NULL DEFAULT 100,
|
||||
`custom_css` text,
|
||||
`column_count` int NOT NULL DEFAULT 10,
|
||||
CONSTRAINT `board_id` PRIMARY KEY(`id`),
|
||||
CONSTRAINT `board_name_unique` UNIQUE(`name`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `groupMember` (
|
||||
`groupId` varchar(64) NOT NULL,
|
||||
`userId` varchar(64) NOT NULL,
|
||||
CONSTRAINT `groupMember_groupId_userId_pk` PRIMARY KEY(`groupId`,`userId`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `groupPermission` (
|
||||
`groupId` varchar(64) NOT NULL,
|
||||
`permission` text NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `group` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`name` varchar(64) NOT NULL,
|
||||
`owner_id` varchar(64),
|
||||
CONSTRAINT `group_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `iconRepository` (
|
||||
`iconRepository_id` varchar(64) NOT NULL,
|
||||
`iconRepository_slug` varchar(150) NOT NULL,
|
||||
CONSTRAINT `iconRepository_iconRepository_id` PRIMARY KEY(`iconRepository_id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `icon` (
|
||||
`icon_id` varchar(64) NOT NULL,
|
||||
`icon_name` varchar(250) NOT NULL,
|
||||
`icon_url` text NOT NULL,
|
||||
`icon_checksum` text NOT NULL,
|
||||
`iconRepository_id` varchar(64) NOT NULL,
|
||||
CONSTRAINT `icon_icon_id` PRIMARY KEY(`icon_id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `integration_item` (
|
||||
`item_id` varchar(64) NOT NULL,
|
||||
`integration_id` varchar(64) NOT NULL,
|
||||
CONSTRAINT `integration_item_item_id_integration_id_pk` PRIMARY KEY(`item_id`,`integration_id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `integrationSecret` (
|
||||
`kind` varchar(16) NOT NULL,
|
||||
`value` text NOT NULL,
|
||||
`updated_at` timestamp NOT NULL,
|
||||
`integration_id` varchar(64) NOT NULL,
|
||||
CONSTRAINT `integrationSecret_integration_id_kind_pk` PRIMARY KEY(`integration_id`,`kind`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `integration` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`url` text NOT NULL,
|
||||
`kind` varchar(128) NOT NULL,
|
||||
CONSTRAINT `integration_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `invite` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`token` varchar(512) NOT NULL,
|
||||
`expiration_date` timestamp NOT NULL,
|
||||
`creator_id` varchar(64) NOT NULL,
|
||||
CONSTRAINT `invite_id` PRIMARY KEY(`id`),
|
||||
CONSTRAINT `invite_token_unique` UNIQUE(`token`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `item` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`section_id` varchar(64) NOT NULL,
|
||||
`kind` text NOT NULL,
|
||||
`x_offset` int NOT NULL,
|
||||
`y_offset` int NOT NULL,
|
||||
`width` int NOT NULL,
|
||||
`height` int NOT NULL,
|
||||
`options` text NOT NULL DEFAULT ('{"json": {}}'),
|
||||
CONSTRAINT `item_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `section` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`board_id` varchar(64) NOT NULL,
|
||||
`kind` text NOT NULL,
|
||||
`position` int NOT NULL,
|
||||
`name` text,
|
||||
CONSTRAINT `section_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `session` (
|
||||
`sessionToken` varchar(512) NOT NULL,
|
||||
`userId` varchar(64) NOT NULL,
|
||||
`expires` timestamp NOT NULL,
|
||||
CONSTRAINT `session_sessionToken` PRIMARY KEY(`sessionToken`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `user` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`name` text,
|
||||
`email` text,
|
||||
`emailVerified` timestamp,
|
||||
`image` text,
|
||||
`password` text,
|
||||
`salt` text,
|
||||
CONSTRAINT `user_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `verificationToken` (
|
||||
`identifier` varchar(64) NOT NULL,
|
||||
`token` varchar(512) NOT NULL,
|
||||
`expires` timestamp NOT NULL,
|
||||
CONSTRAINT `verificationToken_identifier_token_pk` PRIMARY KEY(`identifier`,`token`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `account` ADD CONSTRAINT `account_userId_user_id_fk` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `boardGroupPermission` ADD CONSTRAINT `boardGroupPermission_board_id_board_id_fk` FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `boardGroupPermission` ADD CONSTRAINT `boardGroupPermission_group_id_group_id_fk` FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `boardUserPermission` ADD CONSTRAINT `boardUserPermission_board_id_board_id_fk` FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `boardUserPermission` ADD CONSTRAINT `boardUserPermission_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `board` ADD CONSTRAINT `board_creator_id_user_id_fk` FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `groupMember` ADD CONSTRAINT `groupMember_groupId_group_id_fk` FOREIGN KEY (`groupId`) REFERENCES `group`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `groupMember` ADD CONSTRAINT `groupMember_userId_user_id_fk` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `groupPermission` ADD CONSTRAINT `groupPermission_groupId_group_id_fk` FOREIGN KEY (`groupId`) REFERENCES `group`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `group` ADD CONSTRAINT `group_owner_id_user_id_fk` FOREIGN KEY (`owner_id`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `icon` ADD CONSTRAINT `icon_iconRepository_id_iconRepository_iconRepository_id_fk` FOREIGN KEY (`iconRepository_id`) REFERENCES `iconRepository`(`iconRepository_id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `integration_item` ADD CONSTRAINT `integration_item_item_id_item_id_fk` FOREIGN KEY (`item_id`) REFERENCES `item`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `integration_item` ADD CONSTRAINT `integration_item_integration_id_integration_id_fk` FOREIGN KEY (`integration_id`) REFERENCES `integration`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `integrationSecret` ADD CONSTRAINT `integrationSecret_integration_id_integration_id_fk` FOREIGN KEY (`integration_id`) REFERENCES `integration`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `invite` ADD CONSTRAINT `invite_creator_id_user_id_fk` FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `item` ADD CONSTRAINT `item_section_id_section_id_fk` FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `section` ADD CONSTRAINT `section_board_id_board_id_fk` FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `session` ADD CONSTRAINT `session_userId_user_id_fk` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX `userId_idx` ON `account` (`userId`);--> statement-breakpoint
|
||||
CREATE INDEX `integration_secret__kind_idx` ON `integrationSecret` (`kind`);--> statement-breakpoint
|
||||
CREATE INDEX `integration_secret__updated_at_idx` ON `integrationSecret` (`updated_at`);--> statement-breakpoint
|
||||
CREATE INDEX `integration__kind_idx` ON `integration` (`kind`);--> statement-breakpoint
|
||||
CREATE INDEX `user_id_idx` ON `session` (`userId`);
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `user` ADD `homeBoardId` varchar(64);--> statement-breakpoint
|
||||
ALTER TABLE `user` ADD CONSTRAINT `user_homeBoardId_board_id_fk` FOREIGN KEY (`homeBoardId`) REFERENCES `board`(`id`) ON DELETE set null ON UPDATE no action;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `item` ADD `advanced_options` text DEFAULT ('{"json": {}}') NOT NULL;
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE `serverSetting` (
|
||||
`key` varchar(64) NOT NULL,
|
||||
`value` text NOT NULL DEFAULT ('{"json": {}}'),
|
||||
CONSTRAINT `serverSetting_key` PRIMARY KEY(`key`),
|
||||
CONSTRAINT `serverSetting_key_unique` UNIQUE(`key`)
|
||||
);
|
||||
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE `integrationGroupPermissions` (
|
||||
`integration_id` varchar(64) NOT NULL,
|
||||
`group_id` varchar(64) NOT NULL,
|
||||
`permission` varchar(128) NOT NULL,
|
||||
CONSTRAINT `integration_group_permission__pk` PRIMARY KEY(`integration_id`,`group_id`,`permission`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `integrationUserPermission` (
|
||||
`integration_id` varchar(64) NOT NULL,
|
||||
`user_id` varchar(64) NOT NULL,
|
||||
`permission` varchar(128) NOT NULL,
|
||||
CONSTRAINT `integrationUserPermission_integration_id_user_id_permission_pk` PRIMARY KEY(`integration_id`,`user_id`,`permission`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `integrationGroupPermissions` ADD CONSTRAINT `integrationGroupPermissions_integration_id_integration_id_fk` FOREIGN KEY (`integration_id`) REFERENCES `integration`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `integrationGroupPermissions` ADD CONSTRAINT `integrationGroupPermissions_group_id_group_id_fk` FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `integrationUserPermission` ADD CONSTRAINT `integrationUserPermission_integration_id_integration_id_fk` FOREIGN KEY (`integration_id`) REFERENCES `integration`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `integrationUserPermission` ADD CONSTRAINT `integrationUserPermission_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `provider` varchar(64) DEFAULT 'credentials' NOT NULL;
|
||||
@@ -0,0 +1,6 @@
|
||||
ALTER TABLE `section` RENAME COLUMN `position` TO `y_offset`;--> statement-breakpoint
|
||||
ALTER TABLE `section` ADD `x_offset` int NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE `section` ADD `width` int;--> statement-breakpoint
|
||||
ALTER TABLE `section` ADD `height` int;--> statement-breakpoint
|
||||
ALTER TABLE `section` ADD `parent_section_id` varchar(64);--> statement-breakpoint
|
||||
ALTER TABLE `section` ADD CONSTRAINT `section_parent_section_id_section_id_fk` FOREIGN KEY (`parent_section_id`) REFERENCES `section`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `colorScheme` varchar(5) DEFAULT 'auto' NOT NULL;
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE `search_engine` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`icon_url` text NOT NULL,
|
||||
`name` varchar(64) NOT NULL,
|
||||
`short` varchar(8) NOT NULL,
|
||||
`description` text,
|
||||
`url_template` text NOT NULL,
|
||||
CONSTRAINT `search_engine_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE `apiKey` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`apiKey` text NOT NULL,
|
||||
`salt` text NOT NULL,
|
||||
`userId` varchar(64) NOT NULL,
|
||||
CONSTRAINT `apiKey_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `apiKey` ADD CONSTRAINT `apiKey_userId_user_id_fk` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `firstDayOfWeek` tinyint DEFAULT 1 NOT NULL;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `pingIconsEnabled` boolean DEFAULT false NOT NULL;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` MODIFY COLUMN `colorScheme` varchar(5) NOT NULL DEFAULT 'dark';
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `group` ADD CONSTRAINT `group_name_unique` UNIQUE(`name`);
|
||||
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE `media` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`name` varchar(512) NOT NULL,
|
||||
`content` BLOB NOT NULL,
|
||||
`content_type` text NOT NULL,
|
||||
`size` int NOT NULL,
|
||||
`created_at` timestamp NOT NULL DEFAULT (now()),
|
||||
`creator_id` varchar(64),
|
||||
CONSTRAINT `media_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `media` ADD CONSTRAINT `media_creator_id_user_id_fk` FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE no action;
|
||||
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE `search_engine` MODIFY COLUMN `url_template` text;--> statement-breakpoint
|
||||
ALTER TABLE `search_engine` ADD `type` varchar(64) DEFAULT 'generic' NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE `search_engine` ADD `integration_id` varchar(64);--> statement-breakpoint
|
||||
ALTER TABLE `search_engine` ADD CONSTRAINT `search_engine_integration_id_integration_id_fk` FOREIGN KEY (`integration_id`) REFERENCES `integration`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1,64 @@
|
||||
ALTER TABLE `account` RENAME COLUMN `userId` TO `user_id`;--> statement-breakpoint
|
||||
ALTER TABLE `account` RENAME COLUMN `providerAccountId` TO `provider_account_id`;--> statement-breakpoint
|
||||
ALTER TABLE `apiKey` RENAME COLUMN `apiKey` TO `api_key`;--> statement-breakpoint
|
||||
ALTER TABLE `apiKey` RENAME COLUMN `userId` TO `user_id`;--> statement-breakpoint
|
||||
ALTER TABLE `groupMember` RENAME COLUMN `groupId` TO `group_id`;--> statement-breakpoint
|
||||
ALTER TABLE `groupMember` RENAME COLUMN `userId` TO `user_id`;--> statement-breakpoint
|
||||
ALTER TABLE `groupPermission` RENAME COLUMN `groupId` TO `group_id`;--> statement-breakpoint
|
||||
ALTER TABLE `iconRepository` RENAME COLUMN `iconRepository_id` TO `id`;--> statement-breakpoint
|
||||
ALTER TABLE `iconRepository` RENAME COLUMN `iconRepository_slug` TO `slug`;--> statement-breakpoint
|
||||
ALTER TABLE `icon` RENAME COLUMN `icon_id` TO `id`;--> statement-breakpoint
|
||||
ALTER TABLE `icon` RENAME COLUMN `icon_name` TO `name`;--> statement-breakpoint
|
||||
ALTER TABLE `icon` RENAME COLUMN `icon_url` TO `url`;--> statement-breakpoint
|
||||
ALTER TABLE `icon` RENAME COLUMN `icon_checksum` TO `checksum`;--> statement-breakpoint
|
||||
ALTER TABLE `icon` RENAME COLUMN `iconRepository_id` TO `icon_repository_id`;--> statement-breakpoint
|
||||
ALTER TABLE `serverSetting` RENAME COLUMN `key` TO `setting_key`;--> statement-breakpoint
|
||||
ALTER TABLE `session` RENAME COLUMN `sessionToken` TO `session_token`;--> statement-breakpoint
|
||||
ALTER TABLE `session` RENAME COLUMN `userId` TO `user_id`;--> statement-breakpoint
|
||||
ALTER TABLE `user` RENAME COLUMN `emailVerified` TO `email_verified`;--> statement-breakpoint
|
||||
ALTER TABLE `user` RENAME COLUMN `homeBoardId` TO `home_board_id`;--> statement-breakpoint
|
||||
ALTER TABLE `user` RENAME COLUMN `colorScheme` TO `color_scheme`;--> statement-breakpoint
|
||||
ALTER TABLE `user` RENAME COLUMN `firstDayOfWeek` TO `first_day_of_week`;--> statement-breakpoint
|
||||
ALTER TABLE `user` RENAME COLUMN `pingIconsEnabled` TO `ping_icons_enabled`;--> statement-breakpoint
|
||||
ALTER TABLE `serverSetting` DROP INDEX `serverSetting_key_unique`;--> statement-breakpoint
|
||||
ALTER TABLE `account` DROP FOREIGN KEY `account_userId_user_id_fk`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `apiKey` DROP FOREIGN KEY `apiKey_userId_user_id_fk`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `groupMember` DROP FOREIGN KEY `groupMember_groupId_group_id_fk`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `groupMember` DROP FOREIGN KEY `groupMember_userId_user_id_fk`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `groupPermission` DROP FOREIGN KEY `groupPermission_groupId_group_id_fk`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `icon` DROP FOREIGN KEY `icon_iconRepository_id_iconRepository_iconRepository_id_fk`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `session` DROP FOREIGN KEY `session_userId_user_id_fk`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `user` DROP FOREIGN KEY `user_homeBoardId_board_id_fk`;
|
||||
--> statement-breakpoint
|
||||
DROP INDEX `userId_idx` ON `account`;--> statement-breakpoint
|
||||
DROP INDEX `user_id_idx` ON `session`;--> statement-breakpoint
|
||||
ALTER TABLE `account` DROP PRIMARY KEY;--> statement-breakpoint
|
||||
ALTER TABLE `groupMember` DROP PRIMARY KEY;--> statement-breakpoint
|
||||
ALTER TABLE `iconRepository` DROP PRIMARY KEY;--> statement-breakpoint
|
||||
ALTER TABLE `icon` DROP PRIMARY KEY;--> statement-breakpoint
|
||||
ALTER TABLE `serverSetting` DROP PRIMARY KEY;--> statement-breakpoint
|
||||
ALTER TABLE `session` DROP PRIMARY KEY;--> statement-breakpoint
|
||||
ALTER TABLE `account` ADD PRIMARY KEY(`provider`,`provider_account_id`);--> statement-breakpoint
|
||||
ALTER TABLE `groupMember` ADD PRIMARY KEY(`group_id`,`user_id`);--> statement-breakpoint
|
||||
ALTER TABLE `iconRepository` ADD PRIMARY KEY(`id`);--> statement-breakpoint
|
||||
ALTER TABLE `icon` ADD PRIMARY KEY(`id`);--> statement-breakpoint
|
||||
ALTER TABLE `serverSetting` ADD PRIMARY KEY(`setting_key`);--> statement-breakpoint
|
||||
ALTER TABLE `session` ADD PRIMARY KEY(`session_token`);--> statement-breakpoint
|
||||
ALTER TABLE `serverSetting` ADD CONSTRAINT `serverSetting_settingKey_unique` UNIQUE(`setting_key`);--> statement-breakpoint
|
||||
ALTER TABLE `account` ADD CONSTRAINT `account_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `apiKey` ADD CONSTRAINT `apiKey_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `groupMember` ADD CONSTRAINT `groupMember_group_id_group_id_fk` FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `groupMember` ADD CONSTRAINT `groupMember_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `groupPermission` ADD CONSTRAINT `groupPermission_group_id_group_id_fk` FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `icon` ADD CONSTRAINT `icon_icon_repository_id_iconRepository_id_fk` FOREIGN KEY (`icon_repository_id`) REFERENCES `iconRepository`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `session` ADD CONSTRAINT `session_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `user` ADD CONSTRAINT `user_home_board_id_board_id_fk` FOREIGN KEY (`home_board_id`) REFERENCES `board`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX `userId_idx` ON `account` (`user_id`);--> statement-breakpoint
|
||||
CREATE INDEX `user_id_idx` ON `session` (`user_id`);
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE `onboarding` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`step` varchar(64) NOT NULL,
|
||||
`previous_step` varchar(64),
|
||||
CONSTRAINT `onboarding_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `search_engine` ADD CONSTRAINT `search_engine_short_unique` UNIQUE(`short`);
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `user` ADD `default_search_engine_id` varchar(64);--> statement-breakpoint
|
||||
ALTER TABLE `user` ADD CONSTRAINT `user_default_search_engine_id_search_engine_id_fk` FOREIGN KEY (`default_search_engine_id`) REFERENCES `search_engine`(`id`) ON DELETE set null ON UPDATE no action;
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `user` ADD `mobile_home_board_id` varchar(64);--> statement-breakpoint
|
||||
ALTER TABLE `user` ADD CONSTRAINT `user_mobile_home_board_id_board_id_fk` FOREIGN KEY (`mobile_home_board_id`) REFERENCES `board`(`id`) ON DELETE set null ON UPDATE no action;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `open_search_in_new_tab` boolean DEFAULT false NOT NULL;
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE `section_collapse_state` (
|
||||
`user_id` varchar(64) NOT NULL,
|
||||
`section_id` varchar(64) NOT NULL,
|
||||
`collapsed` boolean NOT NULL DEFAULT false,
|
||||
CONSTRAINT `section_collapse_state_user_id_section_id_pk` PRIMARY KEY(`user_id`,`section_id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section_collapse_state` ADD CONSTRAINT `section_collapse_state_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `section_collapse_state` ADD CONSTRAINT `section_collapse_state_section_id_section_id_fk` FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Custom SQL migration file, put your code below! --
|
||||
-- This file is empty as there was a bug in the migration script of sqlite, missing on delete actions. See https://github.com/homarr-labs/homarr/pull/2211 --
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `board` ADD `disable_status` boolean DEFAULT false NOT NULL;
|
||||
@@ -0,0 +1,25 @@
|
||||
ALTER TABLE `group` ADD `home_board_id` varchar(64);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `group` ADD `mobile_home_board_id` varchar(64);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `group` ADD `position` smallint;
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `temp_group` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`position` smallint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `temp_group`(`id`, `name`, `position`) SELECT `id`, `name`, ROW_NUMBER() OVER(ORDER BY `name`) FROM `group` WHERE `name` != 'everyone';
|
||||
--> statement-breakpoint
|
||||
UPDATE `group` SET `position`=(SELECT `position` FROM `temp_group` WHERE `temp_group`.`id`=`group`.`id`);
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `temp_group`;
|
||||
--> statement-breakpoint
|
||||
UPDATE `group` SET `position` = -1 WHERE `name` = 'everyone';
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `group` MODIFY `position` smallint NOT NULL;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `group` ADD CONSTRAINT `group_home_board_id_board_id_fk` FOREIGN KEY (`home_board_id`) REFERENCES `board`(`id`) ON DELETE set null ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `group` ADD CONSTRAINT `group_mobile_home_board_id_board_id_fk` FOREIGN KEY (`mobile_home_board_id`) REFERENCES `board`(`id`) ON DELETE set null ON UPDATE no action;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `board` ADD `item_radius` text DEFAULT ('lg') NOT NULL;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `board` ADD `icon_color` text;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `app` ADD `ping_url` text;
|
||||
@@ -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';
|
||||
+36
@@ -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';
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `section` ADD `options` text DEFAULT ('{"json": {}}');
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE `trusted_certificate_hostname` (
|
||||
`hostname` varchar(256) NOT NULL,
|
||||
`thumbprint` varchar(128) NOT NULL,
|
||||
`certificate` text NOT NULL,
|
||||
CONSTRAINT `trusted_certificate_hostname_hostname_thumbprint_pk` PRIMARY KEY(`hostname`,`thumbprint`)
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE `cron_job_configuration` (
|
||||
`name` varchar(256) NOT NULL,
|
||||
`cron_expression` varchar(32) NOT NULL,
|
||||
`is_enabled` boolean NOT NULL DEFAULT true,
|
||||
CONSTRAINT `cron_job_configuration_name` PRIMARY KEY(`name`)
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `media` MODIFY COLUMN `content` LONGBLOB NOT NULL;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `integrationSecret` MODIFY COLUMN `kind` varchar(64) NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `integration` ADD `app_id` varchar(128);--> statement-breakpoint
|
||||
ALTER TABLE `integration` ADD CONSTRAINT `integration_app_id_app_id_fk` FOREIGN KEY (`app_id`) REFERENCES `app`(`id`) ON DELETE set null ON UPDATE no action;
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `apiKey` DROP COLUMN `salt`;--> statement-breakpoint
|
||||
ALTER TABLE `user` DROP COLUMN `salt`;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `ddg_bangs` boolean DEFAULT true NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `user` ADD `completed_manage_tour` boolean DEFAULT false NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE `user` ADD `completed_board_tour` boolean DEFAULT false NOT NULL;
|
||||
@@ -0,0 +1,29 @@
|
||||
CREATE TABLE `custom_widget_definition` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`name` varchar(256) NOT NULL,
|
||||
`description` text,
|
||||
`icon_url` text,
|
||||
`base_url` text NOT NULL,
|
||||
`auth_type` varchar(32) NOT NULL DEFAULT 'none',
|
||||
`header_name` varchar(256),
|
||||
`endpoint` text NOT NULL,
|
||||
`method` varchar(16) NOT NULL DEFAULT 'GET',
|
||||
`request_body` text,
|
||||
`display_type` varchar(32) NOT NULL DEFAULT 'singleValue',
|
||||
`display_config` text NOT NULL DEFAULT ('{"json": {}}'),
|
||||
`created_at` timestamp NOT NULL DEFAULT (now()),
|
||||
`updated_at` timestamp NOT NULL DEFAULT (now()),
|
||||
`creator_id` varchar(64),
|
||||
CONSTRAINT `custom_widget_definition_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `custom_widget_secret` (
|
||||
`kind` varchar(64) NOT NULL,
|
||||
`value` text NOT NULL,
|
||||
`updated_at` timestamp NOT NULL,
|
||||
`definition_id` varchar(64) NOT NULL,
|
||||
CONSTRAINT `custom_widget_secret_definition_id_kind_pk` PRIMARY KEY(`definition_id`,`kind`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_definition` ADD CONSTRAINT `custom_widget_definition_creator_id_user_id_fk` FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_secret` ADD CONSTRAINT `cw_secret_definition_id_cw_definition_id_fk` FOREIGN KEY (`definition_id`) REFERENCES `custom_widget_definition`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1,6 @@
|
||||
ALTER TABLE `custom_widget_definition` ADD `url` text;--> statement-breakpoint
|
||||
UPDATE `custom_widget_definition` SET `url` = CONCAT(`base_url`, `endpoint`);--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_definition` MODIFY `url` text NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_definition` DROP COLUMN `base_url`;--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_definition` DROP COLUMN `endpoint`;--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_definition` ADD `enabled` boolean NOT NULL DEFAULT true;
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE `widget_secret` (
|
||||
`item_id` varchar(64) NOT NULL,
|
||||
`kind` varchar(64) NOT NULL,
|
||||
`value` text NOT NULL,
|
||||
`updated_at` timestamp NOT NULL,
|
||||
CONSTRAINT `widget_secret_item_id_kind_pk` PRIMARY KEY(`item_id`,`kind`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `widget_secret` ADD CONSTRAINT `widget_secret_item_id_item_id_fk` FOREIGN KEY (`item_id`) REFERENCES `item`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `enable_right_click_on_widgets` boolean DEFAULT true NOT NULL;
|
||||
@@ -0,0 +1,314 @@
|
||||
{
|
||||
"version": "6",
|
||||
"dialect": "mysql",
|
||||
"entries": [
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "5",
|
||||
"when": 1715334452118,
|
||||
"tag": "0000_harsh_photon",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 1,
|
||||
"version": "5",
|
||||
"when": 1715885855801,
|
||||
"tag": "0001_wild_alex_wilder",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 2,
|
||||
"version": "5",
|
||||
"when": 1715980459023,
|
||||
"tag": "0002_flimsy_deathbird",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 3,
|
||||
"version": "5",
|
||||
"when": 1716148439439,
|
||||
"tag": "0003_freezing_black_panther",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 4,
|
||||
"version": "5",
|
||||
"when": 1720113913876,
|
||||
"tag": "0004_noisy_giant_girl",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 5,
|
||||
"version": "5",
|
||||
"when": 1722068832607,
|
||||
"tag": "0005_soft_microbe",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 6,
|
||||
"version": "5",
|
||||
"when": 1722517058725,
|
||||
"tag": "0006_young_micromax",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "5",
|
||||
"when": 1723749320706,
|
||||
"tag": "0007_boring_nocturne",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 8,
|
||||
"version": "5",
|
||||
"when": 1727532165317,
|
||||
"tag": "0008_far_lifeguard",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 9,
|
||||
"version": "5",
|
||||
"when": 1728074730696,
|
||||
"tag": "0009_wakeful_tenebrous",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 10,
|
||||
"version": "5",
|
||||
"when": 1728142597094,
|
||||
"tag": "0010_melted_pestilence",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 11,
|
||||
"version": "5",
|
||||
"when": 1728490046896,
|
||||
"tag": "0011_freezing_banshee",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 12,
|
||||
"version": "5",
|
||||
"when": 1729348221072,
|
||||
"tag": "0012_abnormal_wendell_vaughn",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 13,
|
||||
"version": "5",
|
||||
"when": 1729369383739,
|
||||
"tag": "0013_youthful_vulture",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 14,
|
||||
"version": "5",
|
||||
"when": 1729524382483,
|
||||
"tag": "0014_bizarre_red_shift",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 15,
|
||||
"version": "5",
|
||||
"when": 1730653393442,
|
||||
"tag": "0015_unknown_firedrake",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 16,
|
||||
"version": "5",
|
||||
"when": 1732212709518,
|
||||
"tag": "0016_change_all_to_snake_case",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 17,
|
||||
"version": "5",
|
||||
"when": 1733777544067,
|
||||
"tag": "0017_tired_penance",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 18,
|
||||
"version": "5",
|
||||
"when": 1735593853768,
|
||||
"tag": "0018_mighty_shaman",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 19,
|
||||
"version": "5",
|
||||
"when": 1735651231818,
|
||||
"tag": "0019_crazy_marvel_zombies",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 20,
|
||||
"version": "5",
|
||||
"when": 1736514409126,
|
||||
"tag": "0020_salty_doorman",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 21,
|
||||
"version": "5",
|
||||
"when": 1737883744729,
|
||||
"tag": "0021_fluffy_jocasta",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 22,
|
||||
"version": "5",
|
||||
"when": 1737927618711,
|
||||
"tag": "0022_famous_otto_octavius",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 23,
|
||||
"version": "5",
|
||||
"when": 1738687012272,
|
||||
"tag": "0023_fix_on_delete_actions",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 24,
|
||||
"version": "5",
|
||||
"when": 1738961147412,
|
||||
"tag": "0024_mean_vin_gonzales",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 25,
|
||||
"version": "5",
|
||||
"when": 1739469710187,
|
||||
"tag": "0025_add-group-home-board-settings",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 26,
|
||||
"version": "5",
|
||||
"when": 1739907771355,
|
||||
"tag": "0026_add-border-radius",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 27,
|
||||
"version": "5",
|
||||
"when": 1739915526818,
|
||||
"tag": "0027_acoustic_karma",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 28,
|
||||
"version": "5",
|
||||
"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
|
||||
},
|
||||
{
|
||||
"idx": 31,
|
||||
"version": "5",
|
||||
"when": 1740784837957,
|
||||
"tag": "0031_add_dynamic_section_options",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 32,
|
||||
"version": "5",
|
||||
"when": 1746821770071,
|
||||
"tag": "0032_add_trusted_certificate_hostnames",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 33,
|
||||
"version": "5",
|
||||
"when": 1750013953833,
|
||||
"tag": "0033_add_cron_job_configuration",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 34,
|
||||
"version": "5",
|
||||
"when": 1754929897145,
|
||||
"tag": "0034_increase-blob-size",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 35,
|
||||
"version": "5",
|
||||
"when": 1756701556908,
|
||||
"tag": "0035_increase-secret-kind-length",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 36,
|
||||
"version": "5",
|
||||
"when": 1760968518445,
|
||||
"tag": "0036_add_app_reference_to_integration",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 37,
|
||||
"version": "5",
|
||||
"when": 1775399941430,
|
||||
"tag": "0037_remove_salt",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 38,
|
||||
"version": "5",
|
||||
"when": 1775400000000,
|
||||
"tag": "0038_add_user_ddg_bangs",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 39,
|
||||
"version": "5",
|
||||
"when": 1779199104477,
|
||||
"tag": "0039_add_user_onboarding_tour_status",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 40,
|
||||
"version": "5",
|
||||
"when": 1780764453945,
|
||||
"tag": "0040_wealthy_thunderbolts",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 41,
|
||||
"version": "5",
|
||||
"when": 1780764500000,
|
||||
"tag": "0041_merge_custom_widget_url",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 42,
|
||||
"version": "5",
|
||||
"when": 1783176100870,
|
||||
"tag": "0042_add_widget_secret",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 43,
|
||||
"version": "5",
|
||||
"when": 1783852800000,
|
||||
"tag": "0043_add_right_click_preference",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,182 @@
|
||||
CREATE TABLE `account` (
|
||||
`userId` text NOT NULL,
|
||||
`type` text NOT NULL,
|
||||
`provider` text NOT NULL,
|
||||
`providerAccountId` text NOT NULL,
|
||||
`refresh_token` text,
|
||||
`access_token` text,
|
||||
`expires_at` integer,
|
||||
`token_type` text,
|
||||
`scope` text,
|
||||
`id_token` text,
|
||||
`session_state` text,
|
||||
PRIMARY KEY(`provider`, `providerAccountId`),
|
||||
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `app` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`description` text,
|
||||
`icon_url` text NOT NULL,
|
||||
`href` text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `boardGroupPermission` (
|
||||
`board_id` text NOT NULL,
|
||||
`group_id` text NOT NULL,
|
||||
`permission` text NOT NULL,
|
||||
PRIMARY KEY(`board_id`, `group_id`, `permission`),
|
||||
FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `boardUserPermission` (
|
||||
`board_id` text NOT NULL,
|
||||
`user_id` text NOT NULL,
|
||||
`permission` text NOT NULL,
|
||||
PRIMARY KEY(`board_id`, `permission`, `user_id`),
|
||||
FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `board` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`is_public` integer DEFAULT false NOT NULL,
|
||||
`creator_id` text,
|
||||
`page_title` text,
|
||||
`meta_title` text,
|
||||
`logo_image_url` text,
|
||||
`favicon_image_url` text,
|
||||
`background_image_url` text,
|
||||
`background_image_attachment` text DEFAULT 'fixed' NOT NULL,
|
||||
`background_image_repeat` text DEFAULT 'no-repeat' NOT NULL,
|
||||
`background_image_size` text DEFAULT 'cover' NOT NULL,
|
||||
`primary_color` text DEFAULT '#fa5252' NOT NULL,
|
||||
`secondary_color` text DEFAULT '#fd7e14' NOT NULL,
|
||||
`opacity` integer DEFAULT 100 NOT NULL,
|
||||
`custom_css` text,
|
||||
`column_count` integer DEFAULT 10 NOT NULL,
|
||||
FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `groupMember` (
|
||||
`groupId` text NOT NULL,
|
||||
`userId` text NOT NULL,
|
||||
PRIMARY KEY(`groupId`, `userId`),
|
||||
FOREIGN KEY (`groupId`) REFERENCES `group`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `groupPermission` (
|
||||
`groupId` text NOT NULL,
|
||||
`permission` text NOT NULL,
|
||||
FOREIGN KEY (`groupId`) REFERENCES `group`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `group` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`owner_id` text,
|
||||
FOREIGN KEY (`owner_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `iconRepository` (
|
||||
`iconRepository_id` text PRIMARY KEY NOT NULL,
|
||||
`iconRepository_slug` text NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `icon` (
|
||||
`icon_id` text PRIMARY KEY NOT NULL,
|
||||
`icon_name` text NOT NULL,
|
||||
`icon_url` text NOT NULL,
|
||||
`icon_checksum` text NOT NULL,
|
||||
`iconRepository_id` text NOT NULL,
|
||||
FOREIGN KEY (`iconRepository_id`) REFERENCES `iconRepository`(`iconRepository_id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `integration_item` (
|
||||
`item_id` text NOT NULL,
|
||||
`integration_id` text NOT NULL,
|
||||
PRIMARY KEY(`integration_id`, `item_id`),
|
||||
FOREIGN KEY (`item_id`) REFERENCES `item`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`integration_id`) REFERENCES `integration`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `integrationSecret` (
|
||||
`kind` text NOT NULL,
|
||||
`value` text NOT NULL,
|
||||
`updated_at` integer NOT NULL,
|
||||
`integration_id` text NOT NULL,
|
||||
PRIMARY KEY(`integration_id`, `kind`),
|
||||
FOREIGN KEY (`integration_id`) REFERENCES `integration`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `integration` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`url` text NOT NULL,
|
||||
`kind` text NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `invite` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`token` text NOT NULL,
|
||||
`expiration_date` integer NOT NULL,
|
||||
`creator_id` text NOT NULL,
|
||||
FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `item` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`section_id` text NOT NULL,
|
||||
`kind` text NOT NULL,
|
||||
`x_offset` integer NOT NULL,
|
||||
`y_offset` integer NOT NULL,
|
||||
`width` integer NOT NULL,
|
||||
`height` integer NOT NULL,
|
||||
`options` text DEFAULT '{"json": {}}' NOT NULL,
|
||||
FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `section` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`board_id` text NOT NULL,
|
||||
`kind` text NOT NULL,
|
||||
`position` integer NOT NULL,
|
||||
`name` text,
|
||||
FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `session` (
|
||||
`sessionToken` text PRIMARY KEY NOT NULL,
|
||||
`userId` text NOT NULL,
|
||||
`expires` integer NOT NULL,
|
||||
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `user` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text,
|
||||
`email` text,
|
||||
`emailVerified` integer,
|
||||
`image` text,
|
||||
`password` text,
|
||||
`salt` text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `verificationToken` (
|
||||
`identifier` text NOT NULL,
|
||||
`token` text NOT NULL,
|
||||
`expires` integer NOT NULL,
|
||||
PRIMARY KEY(`identifier`, `token`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX `userId_idx` ON `account` (`userId`);--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `board_name_unique` ON `board` (`name`);--> statement-breakpoint
|
||||
CREATE INDEX `integration_secret__kind_idx` ON `integrationSecret` (`kind`);--> statement-breakpoint
|
||||
CREATE INDEX `integration_secret__updated_at_idx` ON `integrationSecret` (`updated_at`);--> statement-breakpoint
|
||||
CREATE INDEX `integration__kind_idx` ON `integration` (`kind`);--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `invite_token_unique` ON `invite` (`token`);--> statement-breakpoint
|
||||
CREATE INDEX `user_id_idx` ON `session` (`userId`);
|
||||
@@ -0,0 +1,33 @@
|
||||
COMMIT TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys = OFF;
|
||||
--> statement-breakpoint
|
||||
BEGIN TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `user` RENAME TO `__user_old`;
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `user` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text,
|
||||
`email` text,
|
||||
`emailVerified` integer,
|
||||
`image` text,
|
||||
`password` text,
|
||||
`salt` text,
|
||||
`homeBoardId` text,
|
||||
FOREIGN KEY (`homeBoardId`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `user` SELECT `id`, `name`, `email`, `emailVerified`, `image`, `password`, `salt`, null FROM `__user_old`;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `__user_old`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `user` RENAME TO `__user_old`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `__user_old` RENAME TO `user`;
|
||||
--> statement-breakpoint
|
||||
COMMIT TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys = ON;
|
||||
--> statement-breakpoint
|
||||
BEGIN TRANSACTION;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `item` ADD `advanced_options` text DEFAULT '{"json": {}}' NOT NULL;
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE `serverSetting` (
|
||||
`key` text PRIMARY KEY NOT NULL,
|
||||
`value` text DEFAULT '{"json": {}}' NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `serverSetting_key_unique` ON `serverSetting` (`key`);
|
||||
@@ -0,0 +1,17 @@
|
||||
CREATE TABLE `integrationGroupPermissions` (
|
||||
`integration_id` text NOT NULL,
|
||||
`group_id` text NOT NULL,
|
||||
`permission` text NOT NULL,
|
||||
PRIMARY KEY(`group_id`, `integration_id`, `permission`),
|
||||
FOREIGN KEY (`integration_id`) REFERENCES `integration`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `integrationUserPermission` (
|
||||
`integration_id` text NOT NULL,
|
||||
`user_id` text NOT NULL,
|
||||
`permission` text NOT NULL,
|
||||
PRIMARY KEY(`integration_id`, `permission`, `user_id`),
|
||||
FOREIGN KEY (`integration_id`) REFERENCES `integration`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `provider` text DEFAULT 'credentials' NOT NULL;
|
||||
@@ -0,0 +1,35 @@
|
||||
COMMIT TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys = OFF;
|
||||
--> statement-breakpoint
|
||||
BEGIN TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section` RENAME TO `__section_old`;
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `section` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`board_id` text NOT NULL,
|
||||
`kind` text NOT NULL,
|
||||
`x_offset` integer NOT NULL,
|
||||
`y_offset` integer NOT NULL,
|
||||
`width` integer,
|
||||
`height` integer,
|
||||
`name` text,
|
||||
`parent_section_id` text,
|
||||
FOREIGN KEY (`board_id`) REFERENCES `board`(`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 `section` SELECT `id`, `board_id`, `kind`, 0, `position`, null, null, `name`, null FROM `__section_old`;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `__section_old`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `section` RENAME TO `__section_old`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `__section_old` RENAME TO `section`;
|
||||
--> statement-breakpoint
|
||||
COMMIT TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys = ON;
|
||||
--> statement-breakpoint
|
||||
BEGIN TRANSACTION;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `colorScheme` text DEFAULT 'auto' NOT NULL;
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE `search_engine` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`icon_url` text NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`short` text NOT NULL,
|
||||
`description` text,
|
||||
`url_template` text NOT NULL
|
||||
);
|
||||
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE `apiKey` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`apiKey` text NOT NULL,
|
||||
`salt` text NOT NULL,
|
||||
`userId` text NOT NULL,
|
||||
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `firstDayOfWeek` integer DEFAULT 1 NOT NULL;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `pingIconsEnabled` integer DEFAULT false NOT NULL;
|
||||
@@ -0,0 +1,21 @@
|
||||
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
||||
CREATE TABLE `__new_user` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text,
|
||||
`email` text,
|
||||
`emailVerified` integer,
|
||||
`image` text,
|
||||
`password` text,
|
||||
`salt` text,
|
||||
`provider` text DEFAULT 'credentials' NOT NULL,
|
||||
`homeBoardId` text,
|
||||
`colorScheme` text DEFAULT 'dark' NOT NULL,
|
||||
`firstDayOfWeek` integer DEFAULT 1 NOT NULL,
|
||||
`pingIconsEnabled` integer DEFAULT false NOT NULL,
|
||||
FOREIGN KEY (`homeBoardId`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_user`("id", "name", "email", "emailVerified", "image", "password", "salt", "provider", "homeBoardId", "colorScheme", "firstDayOfWeek", "pingIconsEnabled") SELECT "id", "name", "email", "emailVerified", "image", "password", "salt", "provider", "homeBoardId", "colorScheme", "firstDayOfWeek", "pingIconsEnabled" FROM `user`;--> statement-breakpoint
|
||||
DROP TABLE `user`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_user` RENAME TO `user`;--> statement-breakpoint
|
||||
PRAGMA foreign_keys=ON;
|
||||
@@ -0,0 +1 @@
|
||||
CREATE UNIQUE INDEX `group_name_unique` ON `group` (`name`);
|
||||
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE `media` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`content` blob NOT NULL,
|
||||
`content_type` text NOT NULL,
|
||||
`size` integer NOT NULL,
|
||||
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
|
||||
`creator_id` text,
|
||||
FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);
|
||||
@@ -0,0 +1,17 @@
|
||||
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
||||
CREATE TABLE `__new_search_engine` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`icon_url` text NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`short` text NOT NULL,
|
||||
`description` text,
|
||||
`url_template` text,
|
||||
`type` text DEFAULT 'generic' NOT NULL,
|
||||
`integration_id` text,
|
||||
FOREIGN KEY (`integration_id`) REFERENCES `integration`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_search_engine`("id", "icon_url", "name", "short", "description", "url_template") SELECT "id", "icon_url", "name", "short", "description", "url_template" FROM `search_engine`;--> statement-breakpoint
|
||||
DROP TABLE `search_engine`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_search_engine` RENAME TO `search_engine`;--> statement-breakpoint
|
||||
PRAGMA foreign_keys=ON;
|
||||
@@ -0,0 +1,102 @@
|
||||
ALTER TABLE `iconRepository` RENAME COLUMN "iconRepository_id" TO "id";--> statement-breakpoint
|
||||
ALTER TABLE `iconRepository` RENAME COLUMN "iconRepository_slug" TO "slug";--> statement-breakpoint
|
||||
ALTER TABLE `serverSetting` RENAME COLUMN "key" TO "setting_key";--> statement-breakpoint
|
||||
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
||||
CREATE TABLE `__new_account` (
|
||||
`user_id` text NOT NULL,
|
||||
`type` text NOT NULL,
|
||||
`provider` text NOT NULL,
|
||||
`provider_account_id` text NOT NULL,
|
||||
`refresh_token` text,
|
||||
`access_token` text,
|
||||
`expires_at` integer,
|
||||
`token_type` text,
|
||||
`scope` text,
|
||||
`id_token` text,
|
||||
`session_state` text,
|
||||
PRIMARY KEY(`provider`, `provider_account_id`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_account`("user_id", "type", "provider", "provider_account_id", "refresh_token", "access_token", "expires_at", "token_type", "scope", "id_token", "session_state") SELECT "userId", "type", "provider", "providerAccountId", "refresh_token", "access_token", "expires_at", "token_type", "scope", "id_token", "session_state" FROM `account`;--> statement-breakpoint
|
||||
DROP TABLE `account`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_account` RENAME TO `account`;--> statement-breakpoint
|
||||
PRAGMA foreign_keys=ON;--> statement-breakpoint
|
||||
CREATE INDEX `userId_idx` ON `account` (`user_id`);--> statement-breakpoint
|
||||
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
||||
CREATE TABLE `__new_apiKey` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`api_key` text NOT NULL,
|
||||
`salt` text NOT NULL,
|
||||
`user_id` text NOT NULL,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_apiKey`("id", "api_key", "salt", "user_id") SELECT "id", "apiKey", "salt", "userId" FROM `apiKey`;--> statement-breakpoint
|
||||
DROP TABLE `apiKey`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_apiKey` RENAME TO `apiKey`;--> statement-breakpoint
|
||||
CREATE TABLE `__new_groupMember` (
|
||||
`group_id` text NOT NULL,
|
||||
`user_id` text NOT NULL,
|
||||
PRIMARY KEY(`group_id`, `user_id`),
|
||||
FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_groupMember`("group_id", "user_id") SELECT "groupId", "userId" FROM `groupMember`;--> statement-breakpoint
|
||||
DROP TABLE `groupMember`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_groupMember` RENAME TO `groupMember`;--> statement-breakpoint
|
||||
CREATE TABLE `__new_groupPermission` (
|
||||
`group_id` text NOT NULL,
|
||||
`permission` text NOT NULL,
|
||||
FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_groupPermission`("group_id", "permission") SELECT "groupId", "permission" FROM `groupPermission`;--> statement-breakpoint
|
||||
DROP TABLE `groupPermission`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_groupPermission` RENAME TO `groupPermission`;--> statement-breakpoint
|
||||
CREATE TABLE `__new_icon` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`url` text NOT NULL,
|
||||
`checksum` text NOT NULL,
|
||||
`icon_repository_id` text NOT NULL,
|
||||
FOREIGN KEY (`icon_repository_id`) REFERENCES `iconRepository`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_icon`("id", "name", "url", "checksum", "icon_repository_id") SELECT "icon_id", "icon_name", "icon_url", "icon_checksum", "iconRepository_id" FROM `icon`;--> statement-breakpoint
|
||||
DROP TABLE `icon`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_icon` RENAME TO `icon`;--> statement-breakpoint
|
||||
DROP INDEX IF EXISTS `serverSetting_key_unique`;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `serverSetting_settingKey_unique` ON `serverSetting` (`setting_key`);--> statement-breakpoint
|
||||
CREATE TABLE `__new_session` (
|
||||
`session_token` text PRIMARY KEY NOT NULL,
|
||||
`user_id` text NOT NULL,
|
||||
`expires` integer NOT NULL,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_session`("session_token", "user_id", "expires") SELECT "sessionToken", "userId", "expires" FROM `session`;--> statement-breakpoint
|
||||
DROP TABLE `session`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_session` RENAME TO `session`;--> statement-breakpoint
|
||||
CREATE INDEX `user_id_idx` ON `session` (`user_id`);--> statement-breakpoint
|
||||
CREATE TABLE `__new_user` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text,
|
||||
`email` text,
|
||||
`email_verified` integer,
|
||||
`image` text,
|
||||
`password` text,
|
||||
`salt` text,
|
||||
`provider` text DEFAULT 'credentials' NOT NULL,
|
||||
`home_board_id` text,
|
||||
`color_scheme` text DEFAULT 'dark' NOT NULL,
|
||||
`first_day_of_week` integer DEFAULT 1 NOT NULL,
|
||||
`ping_icons_enabled` integer DEFAULT false NOT NULL,
|
||||
FOREIGN KEY (`home_board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_user`("id", "name", "email", "email_verified", "image", "password", "salt", "provider", "home_board_id", "color_scheme", "first_day_of_week", "ping_icons_enabled") SELECT "id", "name", "email", "emailVerified", "image", "password", "salt", "provider", "homeBoardId", "colorScheme", "firstDayOfWeek", "pingIconsEnabled" FROM `user`;--> statement-breakpoint
|
||||
DROP TABLE `user`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_user` RENAME TO `user`;--> statement-breakpoint
|
||||
PRAGMA foreign_keys=ON;
|
||||
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE `onboarding` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`step` text NOT NULL,
|
||||
`previous_step` text
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
CREATE UNIQUE INDEX `search_engine_short_unique` ON `search_engine` (`short`);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `default_search_engine_id` text REFERENCES search_engine(id);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `mobile_home_board_id` text REFERENCES board(id);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `open_search_in_new_tab` integer DEFAULT true NOT NULL;
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE `section_collapse_state` (
|
||||
`user_id` text NOT NULL,
|
||||
`section_id` text NOT NULL,
|
||||
`collapsed` integer DEFAULT false NOT NULL,
|
||||
PRIMARY KEY(`user_id`, `section_id`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
@@ -0,0 +1,39 @@
|
||||
-- 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_user` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text,
|
||||
`email` text,
|
||||
`email_verified` integer,
|
||||
`image` text,
|
||||
`password` text,
|
||||
`salt` text,
|
||||
`provider` text DEFAULT 'credentials' NOT NULL,
|
||||
`home_board_id` text,
|
||||
`mobile_home_board_id` text,
|
||||
`default_search_engine_id` text,
|
||||
`open_search_in_new_tab` integer DEFAULT true NOT NULL,
|
||||
`color_scheme` text DEFAULT 'dark' NOT NULL,
|
||||
`first_day_of_week` integer DEFAULT 1 NOT NULL,
|
||||
`ping_icons_enabled` integer DEFAULT false NOT NULL,
|
||||
FOREIGN KEY (`home_board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE set null,
|
||||
FOREIGN KEY (`mobile_home_board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE set null,
|
||||
FOREIGN KEY (`default_search_engine_id`) REFERENCES `search_engine`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_user`("id", "name", "email", "email_verified", "image", "password", "salt", "provider", "home_board_id", "mobile_home_board_id", "default_search_engine_id", "open_search_in_new_tab", "color_scheme", "first_day_of_week", "ping_icons_enabled") SELECT "id", "name", "email", "email_verified", "image", "password", "salt", "provider", "home_board_id", "mobile_home_board_id", "default_search_engine_id", "open_search_in_new_tab", "color_scheme", "first_day_of_week", "ping_icons_enabled" FROM `user`;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `user`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `__new_user` RENAME TO `user`;
|
||||
--> statement-breakpoint
|
||||
COMMIT TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys = ON;
|
||||
--> statement-breakpoint
|
||||
BEGIN TRANSACTION;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `board` ADD `disable_status` integer DEFAULT false NOT NULL;
|
||||
@@ -0,0 +1,33 @@
|
||||
COMMIT TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys = OFF;
|
||||
--> statement-breakpoint
|
||||
BEGIN TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `__new_group` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`owner_id` text,
|
||||
`home_board_id` text,
|
||||
`mobile_home_board_id` text,
|
||||
`position` integer NOT NULL,
|
||||
FOREIGN KEY (`owner_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE set null,
|
||||
FOREIGN KEY (`home_board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE set null,
|
||||
FOREIGN KEY (`mobile_home_board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_group`("id", "name", "owner_id", "position") SELECT "id", "name", "owner_id", -1 FROM `group` WHERE "name" = 'everyone';
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_group`("id", "name", "owner_id", "position") SELECT "id", "name", "owner_id", ROW_NUMBER() OVER(ORDER BY "name") FROM `group` WHERE "name" != 'everyone';
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `group`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `__new_group` RENAME TO `group`;
|
||||
--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `group_name_unique` ON `group` (`name`);
|
||||
--> statement-breakpoint
|
||||
COMMIT TRANSACTION;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys = ON;
|
||||
--> statement-breakpoint
|
||||
BEGIN TRANSACTION;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `board` ADD `item_radius` text DEFAULT 'lg' NOT NULL;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `board` ADD `icon_color` text;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `app` ADD `ping_url` text;
|
||||
@@ -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';
|
||||
+47
@@ -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;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `section` ADD `options` text DEFAULT '{"json": {}}';
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE `trusted_certificate_hostname` (
|
||||
`hostname` text NOT NULL,
|
||||
`thumbprint` text NOT NULL,
|
||||
`certificate` text NOT NULL,
|
||||
PRIMARY KEY(`hostname`, `thumbprint`)
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE `cron_job_configuration` (
|
||||
`name` text PRIMARY KEY NOT NULL,
|
||||
`cron_expression` text NOT NULL,
|
||||
`is_enabled` integer DEFAULT true NOT NULL
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `integration` ADD `app_id` text REFERENCES app(id);
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `apiKey` DROP COLUMN `salt`;--> statement-breakpoint
|
||||
ALTER TABLE `user` DROP COLUMN `salt`;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `ddg_bangs` integer DEFAULT true NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `user` ADD `completed_manage_tour` integer DEFAULT false NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE `user` ADD `completed_board_tour` integer DEFAULT false NOT NULL;
|
||||
@@ -0,0 +1,27 @@
|
||||
CREATE TABLE `custom_widget_definition` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`description` text,
|
||||
`icon_url` text,
|
||||
`base_url` text NOT NULL,
|
||||
`auth_type` text DEFAULT 'none' NOT NULL,
|
||||
`header_name` text,
|
||||
`endpoint` text NOT NULL,
|
||||
`method` text DEFAULT 'GET' NOT NULL,
|
||||
`request_body` text,
|
||||
`display_type` text DEFAULT 'singleValue' NOT NULL,
|
||||
`display_config` text DEFAULT '{"json": {}}' NOT NULL,
|
||||
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
|
||||
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
|
||||
`creator_id` text,
|
||||
FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `custom_widget_secret` (
|
||||
`kind` text NOT NULL,
|
||||
`value` text NOT NULL,
|
||||
`updated_at` integer NOT NULL,
|
||||
`definition_id` text NOT NULL,
|
||||
PRIMARY KEY(`definition_id`, `kind`),
|
||||
FOREIGN KEY (`definition_id`) REFERENCES `custom_widget_definition`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
@@ -0,0 +1,23 @@
|
||||
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
||||
CREATE TABLE `__new_custom_widget_definition` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`description` text,
|
||||
`icon_url` text,
|
||||
`url` text NOT NULL,
|
||||
`auth_type` text DEFAULT 'none' NOT NULL,
|
||||
`header_name` text,
|
||||
`method` text DEFAULT 'GET' NOT NULL,
|
||||
`request_body` text,
|
||||
`display_type` text DEFAULT 'singleValue' NOT NULL,
|
||||
`display_config` text DEFAULT '{"json": {}}' NOT NULL,
|
||||
`enabled` integer DEFAULT true NOT NULL,
|
||||
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
|
||||
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
|
||||
`creator_id` text,
|
||||
FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);--> statement-breakpoint
|
||||
INSERT INTO `__new_custom_widget_definition`("id", "name", "description", "icon_url", "url", "auth_type", "header_name", "method", "request_body", "display_type", "display_config", "enabled", "created_at", "updated_at", "creator_id") SELECT "id", "name", "description", "icon_url", "base_url" || "endpoint", "auth_type", "header_name", "method", "request_body", "display_type", "display_config", 1, "created_at", "updated_at", "creator_id" FROM `custom_widget_definition`;--> statement-breakpoint
|
||||
DROP TABLE `custom_widget_definition`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_custom_widget_definition` RENAME TO `custom_widget_definition`;--> statement-breakpoint
|
||||
PRAGMA foreign_keys=ON;
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE `widget_secret` (
|
||||
`item_id` text NOT NULL,
|
||||
`kind` text NOT NULL,
|
||||
`value` text NOT NULL,
|
||||
`updated_at` integer NOT NULL,
|
||||
PRIMARY KEY(`item_id`, `kind`),
|
||||
FOREIGN KEY (`item_id`) REFERENCES `item`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `user` ADD `enable_right_click_on_widgets` integer DEFAULT true NOT NULL;
|
||||
@@ -0,0 +1,300 @@
|
||||
{
|
||||
"version": "6",
|
||||
"dialect": "sqlite",
|
||||
"entries": [
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "6",
|
||||
"when": 1715334238443,
|
||||
"tag": "0000_talented_ben_parker",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 1,
|
||||
"version": "6",
|
||||
"when": 1715871797713,
|
||||
"tag": "0001_mixed_titanium_man",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 2,
|
||||
"version": "6",
|
||||
"when": 1715973963014,
|
||||
"tag": "0002_cooing_sumo",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 3,
|
||||
"version": "6",
|
||||
"when": 1716148434186,
|
||||
"tag": "0003_adorable_raider",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 4,
|
||||
"version": "6",
|
||||
"when": 1720036615408,
|
||||
"tag": "0004_peaceful_red_ghost",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 5,
|
||||
"version": "6",
|
||||
"when": 1722014142492,
|
||||
"tag": "0005_lean_random",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 6,
|
||||
"version": "6",
|
||||
"when": 1722517033483,
|
||||
"tag": "0006_windy_doctor_faustus",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "6",
|
||||
"when": 1723746828385,
|
||||
"tag": "0007_known_ultragirl",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 8,
|
||||
"version": "6",
|
||||
"when": 1727526190343,
|
||||
"tag": "0008_third_thor",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 9,
|
||||
"version": "6",
|
||||
"when": 1728074724956,
|
||||
"tag": "0009_stale_roulette",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 10,
|
||||
"version": "6",
|
||||
"when": 1728142590232,
|
||||
"tag": "0010_gorgeous_stingray",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 11,
|
||||
"version": "6",
|
||||
"when": 1728490026154,
|
||||
"tag": "0011_classy_angel",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 12,
|
||||
"version": "6",
|
||||
"when": 1729348200091,
|
||||
"tag": "0012_ambiguous_black_panther",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 13,
|
||||
"version": "6",
|
||||
"when": 1729369389386,
|
||||
"tag": "0013_faithful_hex",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 14,
|
||||
"version": "6",
|
||||
"when": 1729524387583,
|
||||
"tag": "0014_colorful_cargill",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 15,
|
||||
"version": "6",
|
||||
"when": 1730653336134,
|
||||
"tag": "0015_superb_psylocke",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 16,
|
||||
"version": "6",
|
||||
"when": 1732210918783,
|
||||
"tag": "0016_change_all_to_snake_case",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 17,
|
||||
"version": "6",
|
||||
"when": 1733777395703,
|
||||
"tag": "0017_small_rumiko_fujikawa",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 18,
|
||||
"version": "6",
|
||||
"when": 1735593831501,
|
||||
"tag": "0018_cheerful_tattoo",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 19,
|
||||
"version": "6",
|
||||
"when": 1735651175378,
|
||||
"tag": "0019_steady_darkhawk",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 20,
|
||||
"version": "6",
|
||||
"when": 1736510755691,
|
||||
"tag": "0020_empty_hellfire_club",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 21,
|
||||
"version": "6",
|
||||
"when": 1737883733050,
|
||||
"tag": "0021_famous_bruce_banner",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 22,
|
||||
"version": "6",
|
||||
"when": 1737927609085,
|
||||
"tag": "0022_modern_sunfire",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 23,
|
||||
"version": "6",
|
||||
"when": 1738686324915,
|
||||
"tag": "0023_fix_on_delete_actions",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 24,
|
||||
"version": "6",
|
||||
"when": 1738961178990,
|
||||
"tag": "0024_bitter_scrambler",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 25,
|
||||
"version": "6",
|
||||
"when": 1739468826756,
|
||||
"tag": "0025_add-group-home-board-settings",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 26,
|
||||
"version": "6",
|
||||
"when": 1739907755789,
|
||||
"tag": "0026_add-border-radius",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 27,
|
||||
"version": "6",
|
||||
"when": 1739915486467,
|
||||
"tag": "0027_wooden_blizzard",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 28,
|
||||
"version": "6",
|
||||
"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
|
||||
},
|
||||
{
|
||||
"idx": 31,
|
||||
"version": "6",
|
||||
"when": 1740784849045,
|
||||
"tag": "0031_add_dynamic_section_options",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 32,
|
||||
"version": "6",
|
||||
"when": 1746821779051,
|
||||
"tag": "0032_add_trusted_certificate_hostnames",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 33,
|
||||
"version": "6",
|
||||
"when": 1750014001941,
|
||||
"tag": "0033_add_cron_job_configuration",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 34,
|
||||
"version": "6",
|
||||
"when": 1760968503571,
|
||||
"tag": "0034_add_app_reference_to_integration",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 35,
|
||||
"version": "6",
|
||||
"when": 1775399918831,
|
||||
"tag": "0035_remove_salt",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 36,
|
||||
"version": "6",
|
||||
"when": 1775400000000,
|
||||
"tag": "0036_add_user_ddg_bangs",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 37,
|
||||
"version": "6",
|
||||
"when": 1779199046805,
|
||||
"tag": "0037_add_user_onboarding_tour_status",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 38,
|
||||
"version": "6",
|
||||
"when": 1780764406810,
|
||||
"tag": "0038_crazy_hobgoblin",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 39,
|
||||
"version": "6",
|
||||
"when": 1780764500000,
|
||||
"tag": "0039_merge_custom_widget_url",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 40,
|
||||
"version": "6",
|
||||
"when": 1783176100870,
|
||||
"tag": "0040_add_widget_secret",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 41,
|
||||
"version": "6",
|
||||
"when": 1783786658943,
|
||||
"tag": "0041_add_right_click_preference",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Generated
+160
@@ -0,0 +1,160 @@
|
||||
{
|
||||
"name": "homarr-mysql-to-sqlite",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "homarr-mysql-to-sqlite",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"mysql2": "3.22.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=24.18.0 <25"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "26.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.5.1.tgz",
|
||||
"integrity": "sha512-CzNm2FezW4VR/LjG6yUdiEgLE/rAQ9Slj5gCu/C2VrdcW7I0ahNZ8DRbHT7zOZ6r3ONgd/bsQIeSaoDGrd1C6g==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~8.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/aws-ssl-profiles": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz",
|
||||
"integrity": "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/denque": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
|
||||
"integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/generate-function": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz",
|
||||
"integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-property": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.7.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
|
||||
"integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/is-property": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
|
||||
"integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/long": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
|
||||
"integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/lru.min": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.5.tgz",
|
||||
"integrity": "sha512-5J9ysMYUpYIg9RF2vJpy9SinEmSviFSe0GyPpCQ4L5QSkLAgeLXlTAOu2ZwWUU5m+0SBl6gUU1R1ZQB3aKypfA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"bun": ">=1.0.0",
|
||||
"deno": ">=1.30.0",
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wellwelwel"
|
||||
}
|
||||
},
|
||||
"node_modules/mysql2": {
|
||||
"version": "3.22.6",
|
||||
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.22.6.tgz",
|
||||
"integrity": "sha512-fPKmeDGUzvFP7bMD5SASlJ5zIgvCC4hbanTmhbUlEmhyrY1hR4Hi3xLOWgTd3luYjLVifx6uGvMNJ2m/LlqEpg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"aws-ssl-profiles": "^1.1.2",
|
||||
"denque": "^2.1.0",
|
||||
"generate-function": "^2.3.1",
|
||||
"iconv-lite": "^0.7.2",
|
||||
"long": "^5.3.2",
|
||||
"lru.min": "^1.1.4",
|
||||
"named-placeholders": "^1.1.6",
|
||||
"sql-escaper": "^1.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/named-placeholders": {
|
||||
"version": "1.1.6",
|
||||
"resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.6.tgz",
|
||||
"integrity": "sha512-Tz09sEL2EEuv5fFowm419c1+a/jSMiBjI9gHxVLrVdbUkkNUUfjsVYs9pVZu5oCon/kmRh9TfLEObFtkVxmY0w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lru.min": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/sql-escaper": {
|
||||
"version": "1.5.2",
|
||||
"resolved": "https://registry.npmjs.org/sql-escaper/-/sql-escaper-1.5.2.tgz",
|
||||
"integrity": "sha512-6CKD38c31SENivxOADeMNLdukOnUxUcflKtzVWzace7Riv1v7cAEym5Cx9Q7gYZ3ezIJI7ZpqecQq8cqNeSSFg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"bun": ">=1.0.0",
|
||||
"deno": ">=2.0.0",
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/mysqljs/sql-escaper?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "8.9.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz",
|
||||
"integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "homarr-mysql-to-sqlite",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node src/cli.mjs",
|
||||
"test": "node --test test/*.test.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"mysql2": "3.22.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=24.18.0 <25"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
import { convert } from "./convert.mjs";
|
||||
|
||||
const controller = new AbortController();
|
||||
const abort = () => controller.abort(new Error("Conversion interrupted; no output was published."));
|
||||
process.once("SIGTERM", abort);
|
||||
process.once("SIGINT", abort);
|
||||
|
||||
try {
|
||||
const { values } = parseArgs({
|
||||
options: { output: { type: "string" }, "homarr-stopped": { type: "boolean" }, help: { type: "boolean" } },
|
||||
});
|
||||
if (values.help) {
|
||||
console.log(
|
||||
"Usage: node src/cli.mjs --output /output/db.sqlite --homarr-stopped\nSet MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE; optional MYSQL_PORT (3306), MYSQL_SSL_CA (PEM file). Supports Homarr v1.77.1 only.",
|
||||
);
|
||||
} else {
|
||||
for (const key of ["MYSQL_HOST", "MYSQL_USER", "MYSQL_PASSWORD", "MYSQL_DATABASE"]) {
|
||||
if (!process.env[key]) throw new Error(`Missing ${key}`);
|
||||
}
|
||||
const port = Number(process.env.MYSQL_PORT ?? 3306);
|
||||
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("Invalid MYSQL_PORT");
|
||||
const result = await convert({
|
||||
connectionOptions: {
|
||||
host: process.env.MYSQL_HOST,
|
||||
port,
|
||||
user: process.env.MYSQL_USER,
|
||||
password: process.env.MYSQL_PASSWORD,
|
||||
database: process.env.MYSQL_DATABASE,
|
||||
...(process.env.MYSQL_SSL_CA ? { ssl: { ca: readFileSync(process.env.MYSQL_SSL_CA) } } : {}),
|
||||
},
|
||||
output: values.output,
|
||||
homarrStopped: values["homarr-stopped"],
|
||||
signal: controller.signal,
|
||||
});
|
||||
console.log(
|
||||
`Verified ${Object.keys(result.counts).length} tables (${Object.values(result.counts).reduce((a, b) => a + b, 0)} rows). Created ${result.output}.`,
|
||||
);
|
||||
console.log(
|
||||
"Start v2 with this SQLite file, the original appdata, and the same SECRET_ENCRYPTION_KEY. Keep MySQL unchanged for rollback.",
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
// Driver errors may embed query values. Only print our validation messages or
|
||||
// the driver's error code, never its SQL, connection object, or credentials.
|
||||
console.error(
|
||||
error.code
|
||||
? `Conversion failed (${error.code}). Source unchanged; check connectivity and the supported source schema.`
|
||||
: error.message,
|
||||
);
|
||||
process.exitCode = 1;
|
||||
} finally {
|
||||
process.removeListener("SIGTERM", abort);
|
||||
process.removeListener("SIGINT", abort);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { ConnectionOptions } from "mysql2/promise";
|
||||
|
||||
export function convert(options: {
|
||||
connectionOptions: ConnectionOptions;
|
||||
output: string;
|
||||
homarrStopped: boolean;
|
||||
signal?: AbortSignal;
|
||||
}): Promise<{ release: string; output: string; counts: Record<string, number> }>;
|
||||
@@ -0,0 +1,210 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { closeSync, constants, fsyncSync, openSync } from "node:fs";
|
||||
import { link, lstat, unlink } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
import { DatabaseSync } from "node:sqlite";
|
||||
import { isDeepStrictEqual } from "node:util";
|
||||
import mysql from "mysql2/promise";
|
||||
|
||||
import { initializeSqlite, migrations, quote, schema } from "./legacy.mjs";
|
||||
|
||||
function normalizeType(type) {
|
||||
return type
|
||||
.toLowerCase()
|
||||
.replace(/^boolean$/, "tinyint")
|
||||
.replace(/^(tinyint|smallint|int)\(\d+\)$/, "$1");
|
||||
}
|
||||
|
||||
async function validateSource(connection) {
|
||||
const [tables] = await connection.query(
|
||||
"SELECT TABLE_NAME AS name, ENGINE AS engine FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE()",
|
||||
);
|
||||
const expected = [...schema.tables.map(({ name }) => name), "__drizzle_migrations"].toSorted();
|
||||
if (
|
||||
!isDeepStrictEqual(tables.map(({ name }) => name).toSorted(), expected) ||
|
||||
tables.some(({ engine }) => engine !== "InnoDB")
|
||||
) {
|
||||
throw new Error("Unsupported source schema: expected the complete v1.77.1 InnoDB database, without extra tables.");
|
||||
}
|
||||
const [columns] = await connection.query(
|
||||
"SELECT TABLE_NAME AS tableName, COLUMN_NAME AS name, COLUMN_TYPE AS type, IS_NULLABLE AS nullable FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE()",
|
||||
);
|
||||
for (const table of schema.tables) {
|
||||
const actual = columns.filter(({ tableName }) => tableName === table.name);
|
||||
if (
|
||||
actual.length !== table.columns.length ||
|
||||
table.columns.some((column) => {
|
||||
const found = actual.find(({ name }) => name === column.name);
|
||||
return (
|
||||
!found ||
|
||||
normalizeType(found.type) !== normalizeType(column.mysqlType) ||
|
||||
(found.nullable === "NO") !== column.notNull
|
||||
);
|
||||
})
|
||||
) {
|
||||
throw new Error(`Unsupported or partially migrated source schema: ${table.name}. Expected v1.77.1.`);
|
||||
}
|
||||
}
|
||||
const [journal] = await connection.query("SELECT hash, created_at FROM __drizzle_migrations ORDER BY created_at");
|
||||
const expectedJournal = migrations("mysql");
|
||||
if (
|
||||
journal.length !== expectedJournal.length ||
|
||||
journal.some(
|
||||
(row, index) =>
|
||||
row.hash !== expectedJournal[index].hash || Number(row.created_at) !== expectedJournal[index].when,
|
||||
)
|
||||
) {
|
||||
throw new Error("Unsupported migration journal. Upgrade Homarr to v1.77.1 and complete all migrations first.");
|
||||
}
|
||||
}
|
||||
|
||||
function encode(value, column) {
|
||||
if (value === null) return null;
|
||||
switch (column.encoding) {
|
||||
case "milliseconds":
|
||||
case "seconds": {
|
||||
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(value)) {
|
||||
throw new Error(`Invalid timestamp in ${column.name}`);
|
||||
}
|
||||
const milliseconds = Date.parse(`${value.replace(" ", "T")}Z`);
|
||||
if (
|
||||
!Number.isFinite(milliseconds) ||
|
||||
new Date(milliseconds).toISOString().slice(0, 19).replace("T", " ") !== value
|
||||
) {
|
||||
throw new Error(`Invalid timestamp in ${column.name}`);
|
||||
}
|
||||
return column.encoding === "milliseconds" ? milliseconds : milliseconds / 1000;
|
||||
}
|
||||
case "boolean":
|
||||
if (value !== 0 && value !== 1) throw new Error(`Invalid boolean in ${column.name}`);
|
||||
return value;
|
||||
case "integer":
|
||||
if (!Number.isSafeInteger(value)) throw new Error(`Invalid integer in ${column.name}`);
|
||||
return value;
|
||||
case "blob":
|
||||
if (!Buffer.isBuffer(value)) throw new Error(`Invalid binary value in ${column.name}`);
|
||||
return value;
|
||||
case "text":
|
||||
if (typeof value !== "string") throw new Error(`Invalid text in ${column.name}`);
|
||||
return value;
|
||||
default:
|
||||
throw new Error(`Unknown encoding in ${column.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function convert({ connectionOptions, output, homarrStopped, signal }) {
|
||||
signal?.throwIfAborted();
|
||||
if (!homarrStopped) throw new Error("Stop every Homarr process using this database, then pass --homarr-stopped.");
|
||||
if (!output) throw new Error("An --output file is required.");
|
||||
const destination = resolve(output);
|
||||
try {
|
||||
await lstat(destination);
|
||||
throw new Error("Destination already exists; choose a new output file.");
|
||||
} catch (error) {
|
||||
if (error.code !== "ENOENT") throw error;
|
||||
}
|
||||
const temporary = `${destination}.partial-${randomUUID()}`;
|
||||
let connection;
|
||||
let database;
|
||||
let created = false;
|
||||
let published = false;
|
||||
try {
|
||||
connection = await mysql.createConnection({
|
||||
...connectionOptions,
|
||||
timezone: "Z",
|
||||
dateStrings: true,
|
||||
supportBigNumbers: true,
|
||||
bigNumberStrings: true,
|
||||
multipleStatements: false,
|
||||
charset: "utf8mb4",
|
||||
});
|
||||
await connection.query("SET SESSION time_zone = '+00:00'");
|
||||
await connection.query("SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ");
|
||||
await connection.query("START TRANSACTION WITH CONSISTENT SNAPSHOT, READ ONLY");
|
||||
await validateSource(connection);
|
||||
signal?.throwIfAborted();
|
||||
|
||||
closeSync(openSync(temporary, "wx", 0o600));
|
||||
created = true;
|
||||
database = new DatabaseSync(temporary);
|
||||
database.exec("PRAGMA foreign_keys = OFF");
|
||||
initializeSqlite(database);
|
||||
// Historical migrations contain their own FK pragmas. Disable only for the
|
||||
// complete copy, then check every relationship before publishing the file.
|
||||
database.exec("PRAGMA foreign_keys = OFF; BEGIN IMMEDIATE");
|
||||
const counts = {};
|
||||
for (const table of schema.tables) {
|
||||
const names = table.columns.map(({ name }) => quote(name)).join(", ");
|
||||
const insert = database.prepare(
|
||||
`INSERT INTO ${quote(table.name)} (${names}) VALUES (${table.columns.map(() => "?").join(", ")})`,
|
||||
);
|
||||
const read = database.prepare(`SELECT ${names} FROM ${quote(table.name)} WHERE rowid = ?`);
|
||||
let count = 0;
|
||||
while (true) {
|
||||
signal?.throwIfAborted();
|
||||
const [rows] = await connection.query(
|
||||
`SELECT ${names} FROM ${quote(table.name)} ORDER BY ${table.orderBy.map(quote).join(", ")} LIMIT 250 OFFSET ?`,
|
||||
[count],
|
||||
);
|
||||
for (const row of rows) {
|
||||
const values = table.columns.map((column) => encode(row[column.name], column));
|
||||
const inserted = insert.run(...values);
|
||||
const stored = read.get(inserted.lastInsertRowid);
|
||||
for (const [index, column] of table.columns.entries()) {
|
||||
const value = stored[column.name];
|
||||
const normalized = value instanceof Uint8Array ? Buffer.from(value) : value;
|
||||
if (!isDeepStrictEqual(normalized, values[index]))
|
||||
throw new Error(`Value verification failed in ${table.name}.${column.name}`);
|
||||
}
|
||||
}
|
||||
count += rows.length;
|
||||
if (rows.length < 250) break;
|
||||
}
|
||||
const [[sourceCount]] = await connection.query(`SELECT COUNT(*) AS count FROM ${quote(table.name)}`);
|
||||
const targetCount = database.prepare(`SELECT COUNT(*) AS count FROM ${quote(table.name)}`).get().count;
|
||||
if (Number(sourceCount.count) !== count || targetCount !== count)
|
||||
throw new Error(`Row count mismatch in ${table.name}`);
|
||||
counts[table.name] = count;
|
||||
}
|
||||
if (database.prepare("PRAGMA foreign_key_check").all().length)
|
||||
throw new Error("Source contains broken relationships; output was not published.");
|
||||
const integrity = database.prepare("PRAGMA integrity_check").all();
|
||||
if (integrity.length !== 1 || integrity[0].integrity_check !== "ok")
|
||||
throw new Error("SQLite integrity check failed.");
|
||||
database.exec("COMMIT; PRAGMA foreign_keys = ON");
|
||||
database.close();
|
||||
database = undefined;
|
||||
await connection.rollback();
|
||||
await connection.end();
|
||||
connection = undefined;
|
||||
const descriptor = openSync(temporary, constants.O_RDONLY);
|
||||
try {
|
||||
fsyncSync(descriptor);
|
||||
} finally {
|
||||
closeSync(descriptor);
|
||||
}
|
||||
signal?.throwIfAborted();
|
||||
// Hard-link publication is atomic and fails if another process created the
|
||||
// destination. rename() would silently overwrite that file on Unix.
|
||||
await link(temporary, destination);
|
||||
published = true;
|
||||
return { release: schema.release, output: destination, counts };
|
||||
} finally {
|
||||
try {
|
||||
database?.close();
|
||||
} finally {
|
||||
try {
|
||||
await connection?.end();
|
||||
} finally {
|
||||
if (created)
|
||||
await unlink(temporary).catch((error) => {
|
||||
if (error.code === "ENOENT") return;
|
||||
if (!published) throw error;
|
||||
// The verified output already exists. A leftover hard link must not
|
||||
// turn a successful conversion into a misleading failure report.
|
||||
console.warn("Conversion succeeded, but its temporary .partial file could not be removed.");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
const root = new URL("../legacy/v1.77.1/", import.meta.url);
|
||||
export const schema = JSON.parse(readFileSync(new URL("schema.json", root), "utf8"));
|
||||
|
||||
export function migrations(dialect) {
|
||||
const journal = JSON.parse(readFileSync(new URL(`${dialect}/journal.json`, root), "utf8"));
|
||||
return journal.entries.map((entry) => {
|
||||
const sql = readFileSync(new URL(`${dialect}/${entry.tag}.sql`, root), "utf8");
|
||||
return { ...entry, sql, hash: createHash("sha256").update(sql).digest("hex") };
|
||||
});
|
||||
}
|
||||
|
||||
export const quote = (identifier) => `\`${identifier.replaceAll("`", "``")}\``;
|
||||
|
||||
// Use the release's SQL, not its seeding entrypoint: source data owns every ID.
|
||||
export function initializeSqlite(database) {
|
||||
database.exec('CREATE TABLE "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)');
|
||||
const record = database.prepare('INSERT INTO "__drizzle_migrations" (hash, created_at) VALUES (?, ?)');
|
||||
database.exec("BEGIN");
|
||||
for (const migration of migrations("sqlite")) {
|
||||
for (const statement of migration.sql.split("--> statement-breakpoint")) {
|
||||
if (statement.trim()) database.exec(statement);
|
||||
}
|
||||
record.run(migration.hash, migration.when);
|
||||
}
|
||||
database.exec("COMMIT");
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { execFile } from "node:child_process";
|
||||
import { mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { DatabaseSync } from "node:sqlite";
|
||||
import { promisify } from "node:util";
|
||||
import { test } from "node:test";
|
||||
import { setTimeout } from "node:timers/promises";
|
||||
|
||||
import { convert } from "../src/convert.mjs";
|
||||
import { migrations, quote, schema } from "../src/legacy.mjs";
|
||||
import { createFixture, fixtureCiphertext, fixtureDate, fixtureMedia, fixturePasswordHash } from "./fixture.mjs";
|
||||
|
||||
const exec = promisify(execFile);
|
||||
|
||||
test("real v1.77.1 MySQL converts losslessly and rejects unsafe sources", { timeout: 300_000 }, async (t) => {
|
||||
const fixture = await createFixture();
|
||||
const directory = await mkdtemp(join(tmpdir(), "homarr-conversion-"));
|
||||
t.after(async () => {
|
||||
try {
|
||||
await fixture.cleanup();
|
||||
} finally {
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
const { connection, connectionOptions } = fixture;
|
||||
const output = join(directory, "db.sqlite");
|
||||
const sourceSnapshot = async () =>
|
||||
Object.fromEntries(
|
||||
await Promise.all(
|
||||
schema.tables.map(async ({ name }) => {
|
||||
const [rows] = await connection.query(`SELECT * FROM ${quote(name)}`);
|
||||
return [name, rows];
|
||||
}),
|
||||
),
|
||||
);
|
||||
const before = await sourceSnapshot();
|
||||
await assert.rejects(convert({ connectionOptions, output }), /Stop every Homarr/);
|
||||
const result = await convert({ connectionOptions, output, homarrStopped: true });
|
||||
assert.equal(Object.keys(result.counts).length, 35);
|
||||
assert.equal(result.counts.serverSetting, 252);
|
||||
assert.deepEqual(await sourceSnapshot(), before);
|
||||
const database = new DatabaseSync(output, { readOnly: true });
|
||||
try {
|
||||
assert.deepEqual(database.prepare("PRAGMA foreign_key_check").all(), []);
|
||||
assert.equal(database.prepare("PRAGMA integrity_check").get().integrity_check, "ok");
|
||||
assert.equal(database.prepare("SELECT password FROM user").get().password, fixturePasswordHash);
|
||||
assert.equal(database.prepare("SELECT value FROM integrationSecret").get().value, fixtureCiphertext);
|
||||
assert.deepEqual(Buffer.from(database.prepare("SELECT content FROM media").get().content), fixtureMedia);
|
||||
assert.equal(
|
||||
database.prepare("SELECT expires FROM session").get().expires,
|
||||
Date.parse(fixtureDate.replace(" ", "T") + "Z"),
|
||||
);
|
||||
assert.equal(
|
||||
database.prepare("SELECT updated_at FROM integrationSecret").get().updated_at,
|
||||
Date.parse(fixtureDate.replace(" ", "T") + "Z") / 1000,
|
||||
);
|
||||
assert.equal(database.prepare("SELECT image FROM user").get().image, null);
|
||||
const [sourceBoards] = await connection.query("SELECT custom_css, is_public FROM board");
|
||||
const convertedBoard = database.prepare("SELECT custom_css, is_public FROM board").get();
|
||||
assert.equal(convertedBoard.custom_css, sourceBoards[0].custom_css);
|
||||
assert.ok(convertedBoard.custom_css.length > 50_000);
|
||||
assert.ok(convertedBoard.custom_css.includes("café 🏡"));
|
||||
assert.equal(convertedBoard.is_public, 0);
|
||||
assert.equal(database.prepare("SELECT completed_manage_tour FROM user").get().completed_manage_tour, 1);
|
||||
assert.equal(database.prepare("SELECT is_enabled FROM cron_job_configuration").get().is_enabled, 0);
|
||||
assert.equal(database.prepare("SELECT parent_section_id FROM section_layout").get().parent_section_id, null);
|
||||
assert.equal(
|
||||
database.prepare("SELECT COUNT(*) AS n FROM __drizzle_migrations").get().n,
|
||||
migrations("sqlite").length,
|
||||
);
|
||||
} finally {
|
||||
database.close();
|
||||
}
|
||||
|
||||
const original = await readFile(output);
|
||||
await assert.rejects(convert({ connectionOptions, output, homarrStopped: true }), /Destination already exists/);
|
||||
assert.deepEqual(await readFile(output), original);
|
||||
await connection.query("ALTER TABLE user ADD COLUMN unsupported_schema TEXT");
|
||||
await assert.rejects(
|
||||
convert({ connectionOptions, output: join(directory, "unsupported.sqlite"), homarrStopped: true }),
|
||||
/Unsupported or partially migrated/,
|
||||
);
|
||||
await connection.query("ALTER TABLE user DROP COLUMN unsupported_schema");
|
||||
await connection.query("UPDATE __drizzle_migrations SET hash = 'unknown' WHERE id = 1");
|
||||
await assert.rejects(
|
||||
convert({ connectionOptions, output: join(directory, "journal.sqlite"), homarrStopped: true }),
|
||||
/Unsupported migration journal/,
|
||||
);
|
||||
await connection.query("UPDATE __drizzle_migrations SET hash = ? WHERE id = 1", [migrations("mysql")[0].hash]);
|
||||
|
||||
await connection.query("SET FOREIGN_KEY_CHECKS = 0");
|
||||
await connection.query("UPDATE groupMember SET user_id = 'missing-user'");
|
||||
await assert.rejects(
|
||||
convert({ connectionOptions, output: join(directory, "invalid.sqlite"), homarrStopped: true }),
|
||||
/broken relationships/,
|
||||
);
|
||||
await connection.query("UPDATE groupMember SET user_id = 'migration-user'");
|
||||
await connection.query("SET FOREIGN_KEY_CHECKS = 1");
|
||||
assert.deepEqual(await readdir(directory), ["db.sqlite"]);
|
||||
assert.deepEqual(await sourceSnapshot(), before);
|
||||
|
||||
const controller = new AbortController();
|
||||
const interrupted = convert({
|
||||
connectionOptions,
|
||||
output: join(directory, "interrupted.sqlite"),
|
||||
homarrStopped: true,
|
||||
signal: controller.signal,
|
||||
});
|
||||
// Observe a started copy rather than relying on a sleep duration to interrupt it.
|
||||
const rejection = assert.rejects(interrupted, /aborted/);
|
||||
const deadline = Date.now() + 10_000;
|
||||
while (!(await readdir(directory)).some((name) => name.startsWith("interrupted.sqlite.partial-"))) {
|
||||
if (Date.now() > deadline) throw new Error("Conversion did not start in time");
|
||||
await setTimeout(1);
|
||||
}
|
||||
controller.abort();
|
||||
await rejection;
|
||||
assert.deepEqual(await readdir(directory), ["db.sqlite"]);
|
||||
assert.deepEqual(await sourceSnapshot(), before);
|
||||
|
||||
// Create a competing destination after conversion passes its initial existence check.
|
||||
const racedOutput = join(directory, "raced.sqlite");
|
||||
const racedConversion = convert({ connectionOptions, output: racedOutput, homarrStopped: true });
|
||||
const racedRejection = assert.rejects(racedConversion, { code: "EEXIST" });
|
||||
const raceDeadline = Date.now() + 10_000;
|
||||
while (!(await readdir(directory)).some((name) => name.startsWith("raced.sqlite.partial-"))) {
|
||||
if (Date.now() > raceDeadline) throw new Error("Conversion did not start before the destination race");
|
||||
await setTimeout(1);
|
||||
}
|
||||
const competingContent = Buffer.from("An independently created file must never be overwritten.");
|
||||
await writeFile(racedOutput, competingContent, { flag: "wx", mode: 0o600 });
|
||||
await racedRejection;
|
||||
assert.deepEqual(await readFile(racedOutput), competingContent);
|
||||
assert.deepEqual((await readdir(directory)).sort(), ["db.sqlite", "raced.sqlite"]);
|
||||
await rm(racedOutput);
|
||||
assert.deepEqual(await sourceSnapshot(), before);
|
||||
|
||||
// Exercise the delivered Docker entrypoint against the same real database.
|
||||
const image = `homarr-mysql-converter-test:${process.pid}`;
|
||||
await exec("docker", ["build", "-t", image, "."], {
|
||||
cwd: new URL("../", import.meta.url),
|
||||
maxBuffer: 8 * 1024 * 1024,
|
||||
});
|
||||
t.after(() => exec("docker", ["image", "rm", image]));
|
||||
const environmentFile = join(directory, "connection.env");
|
||||
await writeFile(
|
||||
environmentFile,
|
||||
`MYSQL_HOST=127.0.0.1\nMYSQL_PORT=${connectionOptions.port}\nMYSQL_USER=${connectionOptions.user}\nMYSQL_PASSWORD=${connectionOptions.password}\nMYSQL_DATABASE=homarr\n`,
|
||||
{ mode: 0o600 },
|
||||
);
|
||||
await exec("docker", [
|
||||
"run",
|
||||
"--rm",
|
||||
"--user",
|
||||
`${process.getuid()}:${process.getgid()}`,
|
||||
"--network",
|
||||
"host",
|
||||
"--env-file",
|
||||
environmentFile,
|
||||
"-v",
|
||||
`${directory}:/output`,
|
||||
image,
|
||||
"--output",
|
||||
"/output/packaged.sqlite",
|
||||
"--homarr-stopped",
|
||||
]);
|
||||
const packaged = new DatabaseSync(join(directory, "packaged.sqlite"), { readOnly: true });
|
||||
try {
|
||||
assert.equal(packaged.prepare("SELECT password FROM user").get().password, fixturePasswordHash);
|
||||
} finally {
|
||||
packaged.close();
|
||||
}
|
||||
assert.deepEqual(await sourceSnapshot(), before);
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { Connection, ConnectionOptions } from "mysql2/promise";
|
||||
|
||||
export const fixtureUser: string;
|
||||
export const fixturePassword: string;
|
||||
export const fixtureBoard: string;
|
||||
export const fixtureSecret: string;
|
||||
export const fixtureMedia: Buffer;
|
||||
export const fixtureDate: string;
|
||||
export const fixturePasswordHash: string;
|
||||
export const fixtureCiphertext: string;
|
||||
export function createFixture(): Promise<{
|
||||
connectionOptions: ConnectionOptions;
|
||||
connection: Connection;
|
||||
container: string;
|
||||
cleanup(): Promise<void>;
|
||||
}>;
|
||||
Loaded 100 of 3286 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user