simplify v2 migration history

This commit is contained in:
ajnart committed 2026-07-29 20:19:47 +02:00
1 parent 6ae109e8f5
commit 7a2d6009f7
34 files changed
+725 -9091

No files matched your search

@@ -1,30 +0,0 @@
RENAME TABLE `custom_widget_definition` TO `legacy_custom_widget_definition`, `custom_widget_secret` TO `legacy_custom_widget_secret`;--> statement-breakpoint
ALTER TABLE `legacy_custom_widget_definition` DROP FOREIGN KEY `custom_widget_definition_creator_id_user_id_fk`;--> statement-breakpoint
ALTER TABLE `legacy_custom_widget_definition` ADD CONSTRAINT `legacy_cw_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 `legacy_custom_widget_secret` DROP FOREIGN KEY `cw_secret_definition_id_cw_definition_id_fk`;--> statement-breakpoint
ALTER TABLE `legacy_custom_widget_secret` ADD CONSTRAINT `legacy_cw_secret_definition_id_fk` FOREIGN KEY (`definition_id`) REFERENCES `legacy_custom_widget_definition`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE TABLE `custom_widget_definition` (
`id` varchar(64) NOT NULL,
`name` varchar(256) NOT NULL,
`description` text,
`icon_url` text,
`sources` text NOT NULL,
`requests` text NOT NULL,
`options` text NOT NULL,
`template` text NOT NULL,
`enabled` boolean DEFAULT true NOT NULL,
`created_at` timestamp DEFAULT (now()) NOT NULL,
`updated_at` timestamp DEFAULT (now()) NOT NULL,
`creator_id` varchar(64),
CONSTRAINT `custom_widget_definition_id` PRIMARY KEY(`id`)
);--> statement-breakpoint
CREATE TABLE `custom_widget_secret` (
`source_id` varchar(64) NOT NULL,
`kind` varchar(64) NOT NULL,
`encrypted_value` text NOT NULL,
`updated_at` timestamp NOT NULL,
`definition_id` varchar(64) NOT NULL,
CONSTRAINT `custom_widget_secret_definition_id_source_id_kind_pk` PRIMARY KEY(`definition_id`,`source_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_fk` FOREIGN KEY (`definition_id`) REFERENCES `custom_widget_definition`(`id`) ON DELETE cascade ON UPDATE no action;
@@ -0,0 +1,26 @@
CREATE TABLE `custom_widget_v2_definition` (
`id` varchar(64) NOT NULL,
`name` varchar(256) NOT NULL,
`description` text,
`icon_url` text,
`sources` text NOT NULL,
`requests` text NOT NULL,
`options` text NOT NULL,
`template` text NOT NULL,
`enabled` boolean DEFAULT true NOT NULL,
`created_at` timestamp DEFAULT (now()) NOT NULL,
`updated_at` timestamp DEFAULT (now()) NOT NULL,
`creator_id` varchar(64),
CONSTRAINT `custom_widget_v2_definition_id` PRIMARY KEY(`id`)
);--> statement-breakpoint
CREATE TABLE `custom_widget_v2_secret` (
`source_id` varchar(64) NOT NULL,
`kind` varchar(64) NOT NULL,
`encrypted_value` text NOT NULL,
`updated_at` timestamp NOT NULL,
`definition_id` varchar(64) NOT NULL,
CONSTRAINT `custom_widget_v2_secret_definition_id_source_id_kind_pk` PRIMARY KEY(`definition_id`,`source_id`,`kind`)
);--> statement-breakpoint
ALTER TABLE `custom_widget_v2_definition` ADD CONSTRAINT `custom_widget_v2_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_v2_secret` ADD CONSTRAINT `custom_widget_v2_secret_definition_id_fk` FOREIGN KEY (`definition_id`) REFERENCES `custom_widget_v2_definition`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
DELETE FROM `groupPermission` WHERE `permission` IN ('custom-widget-manage', 'custom-widget-secret-write');
@@ -1,22 +0,0 @@
RENAME TABLE
`custom_widget_definition` TO `custom_widget_v2_definition`,
`custom_widget_secret` TO `custom_widget_v2_secret`,
`legacy_custom_widget_definition` TO `custom_widget_definition`,
`legacy_custom_widget_secret` TO `custom_widget_secret`;--> statement-breakpoint
ALTER TABLE `custom_widget_v2_definition`
DROP FOREIGN KEY `custom_widget_definition_creator_id_user_id_fk`,
ADD CONSTRAINT `custom_widget_v2_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_v2_secret`
DROP FOREIGN KEY `cw_secret_definition_id_fk`,
ADD CONSTRAINT `custom_widget_v2_secret_definition_id_fk`
FOREIGN KEY (`definition_id`) REFERENCES `custom_widget_v2_definition`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE `custom_widget_definition`
DROP FOREIGN KEY `legacy_cw_definition_creator_id_user_id_fk`,
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`
DROP FOREIGN KEY `legacy_cw_secret_definition_id_fk`,
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;--> statement-breakpoint
DELETE FROM `groupPermission` WHERE `permission` IN ('custom-widget-manage', 'custom-widget-secret-write');
@@ -1,7 +1,7 @@
{
"version": "5",
"dialect": "mysql",
"id": "1a10d79c-6c82-4036-8717-0283ebaece10",
"id": "e2f11bb0-59e9-4fab-8ae1-5bf764795c74",
"prevId": "073d408e-ff80-4a57-8007-f1f32da1c71c",
"tables": {
"account": {
@@ -534,198 +534,8 @@
"uniqueConstraints": {},
"checkConstraint": {}
},
"legacy_custom_widget_definition": {
"name": "legacy_custom_widget_definition",
"columns": {
"id": {
"name": "id",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"icon_url": {
"name": "icon_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"auth_type": {
"name": "auth_type",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'none'"
},
"header_name": {
"name": "header_name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"method": {
"name": "method",
"type": "varchar(16)",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'GET'"
},
"request_body": {
"name": "request_body",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"display_type": {
"name": "display_type",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'singleValue'"
},
"display_config": {
"name": "display_config",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "('{\"json\": {}}')"
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(now())"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(now())"
},
"creator_id": {
"name": "creator_id",
"type": "varchar(64)",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"enabled": {
"name": "enabled",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": true
}
},
"indexes": {},
"foreignKeys": {
"legacy_cw_definition_creator_id_user_id_fk": {
"name": "legacy_cw_definition_creator_id_user_id_fk",
"tableFrom": "legacy_custom_widget_definition",
"tableTo": "user",
"columnsFrom": ["creator_id"],
"columnsTo": ["id"],
"onDelete": "set null",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"legacy_custom_widget_definition_id": {
"name": "legacy_custom_widget_definition_id",
"columns": ["id"]
}
},
"uniqueConstraints": {},
"checkConstraint": {}
},
"legacy_custom_widget_secret": {
"name": "legacy_custom_widget_secret",
"columns": {
"kind": {
"name": "kind",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"definition_id": {
"name": "definition_id",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"legacy_cw_secret_definition_id_fk": {
"name": "legacy_cw_secret_definition_id_fk",
"tableFrom": "legacy_custom_widget_secret",
"tableTo": "legacy_custom_widget_definition",
"columnsFrom": ["definition_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"legacy_custom_widget_secret_definition_id_kind_pk": {
"name": "legacy_custom_widget_secret_definition_id_kind_pk",
"columns": ["definition_id", "kind"]
}
},
"uniqueConstraints": {},
"checkConstraint": {}
},
"custom_widget_definition": {
"name": "custom_widget_definition",
"custom_widget_v2_definition": {
"name": "custom_widget_v2_definition",
"columns": {
"id": {
"name": "id",
@@ -817,9 +627,9 @@
},
"indexes": {},
"foreignKeys": {
"custom_widget_definition_creator_id_user_id_fk": {
"name": "custom_widget_definition_creator_id_user_id_fk",
"tableFrom": "custom_widget_definition",
"custom_widget_v2_definition_creator_id_user_id_fk": {
"name": "custom_widget_v2_definition_creator_id_user_id_fk",
"tableFrom": "custom_widget_v2_definition",
"tableTo": "user",
"columnsFrom": ["creator_id"],
"columnsTo": ["id"],
@@ -828,16 +638,16 @@
}
},
"compositePrimaryKeys": {
"custom_widget_definition_id": {
"name": "custom_widget_definition_id",
"custom_widget_v2_definition_id": {
"name": "custom_widget_v2_definition_id",
"columns": ["id"]
}
},
"uniqueConstraints": {},
"checkConstraint": {}
},
"custom_widget_secret": {
"name": "custom_widget_secret",
"custom_widget_v2_secret": {
"name": "custom_widget_v2_secret",
"columns": {
"source_id": {
"name": "source_id",
@@ -877,10 +687,10 @@
},
"indexes": {},
"foreignKeys": {
"cw_secret_definition_id_fk": {
"name": "cw_secret_definition_id_fk",
"tableFrom": "custom_widget_secret",
"tableTo": "custom_widget_definition",
"custom_widget_v2_secret_definition_id_fk": {
"name": "custom_widget_v2_secret_definition_id_fk",
"tableFrom": "custom_widget_v2_secret",
"tableTo": "custom_widget_v2_definition",
"columnsFrom": ["definition_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
@@ -888,8 +698,8 @@
}
},
"compositePrimaryKeys": {
"custom_widget_secret_definition_id_source_id_kind_pk": {
"name": "custom_widget_secret_definition_id_source_id_kind_pk",
"custom_widget_v2_secret_definition_id_source_id_kind_pk": {
"name": "custom_widget_v2_secret_definition_id_source_id_kind_pk",
"columns": ["definition_id", "source_id", "kind"]
}
},
@@ -1718,6 +1528,196 @@
"uniqueConstraints": {},
"checkConstraint": {}
},
"custom_widget_definition": {
"name": "custom_widget_definition",
"columns": {
"id": {
"name": "id",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"icon_url": {
"name": "icon_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"auth_type": {
"name": "auth_type",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'none'"
},
"header_name": {
"name": "header_name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"method": {
"name": "method",
"type": "varchar(16)",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'GET'"
},
"request_body": {
"name": "request_body",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"display_type": {
"name": "display_type",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'singleValue'"
},
"display_config": {
"name": "display_config",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "('{\"json\": {}}')"
},
"enabled": {
"name": "enabled",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(now())"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(now())"
},
"creator_id": {
"name": "creator_id",
"type": "varchar(64)",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"custom_widget_definition_creator_id_user_id_fk": {
"name": "custom_widget_definition_creator_id_user_id_fk",
"tableFrom": "custom_widget_definition",
"tableTo": "user",
"columnsFrom": ["creator_id"],
"columnsTo": ["id"],
"onDelete": "set null",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"custom_widget_definition_id": {
"name": "custom_widget_definition_id",
"columns": ["id"]
}
},
"uniqueConstraints": {},
"checkConstraint": {}
},
"custom_widget_secret": {
"name": "custom_widget_secret",
"columns": {
"kind": {
"name": "kind",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"definition_id": {
"name": "definition_id",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"cw_secret_definition_id_cw_definition_id_fk": {
"name": "cw_secret_definition_id_cw_definition_id_fk",
"tableFrom": "custom_widget_secret",
"tableTo": "custom_widget_definition",
"columnsFrom": ["definition_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"custom_widget_secret_definition_id_kind_pk": {
"name": "custom_widget_secret_definition_id_kind_pk",
"columns": ["definition_id", "kind"]
}
},
"uniqueConstraints": {},
"checkConstraint": {}
},
"media": {
"name": "media",
"columns": {
File diff suppressed because it is too large. Load diff
@@ -314,14 +314,7 @@
"idx": 44,
"version": "5",
"when": 1784305537309,
"tag": "0044_custom_widget_v2_reset",
"breakpoints": true
},
{
"idx": 45,
"version": "5",
"when": 1785225865332,
"tag": "0045_custom_widget_v1_compatibility",
"tag": "0044_custom_widget_v2_tables",
"breakpoints": true
}
]
@@ -1,29 +0,0 @@
ALTER TABLE "custom_widget_definition" RENAME TO "legacy_custom_widget_definition";--> statement-breakpoint
ALTER TABLE "custom_widget_secret" RENAME TO "legacy_custom_widget_secret";--> statement-breakpoint
ALTER TABLE "legacy_custom_widget_definition" RENAME CONSTRAINT "custom_widget_definition_creator_id_user_id_fk" TO "legacy_cw_definition_creator_id_user_id_fk";--> statement-breakpoint
ALTER TABLE "legacy_custom_widget_secret" RENAME CONSTRAINT "custom_widget_secret_definition_id_custom_widget_definition_id_fk" TO "legacy_cw_secret_definition_id_fk";--> statement-breakpoint
ALTER TABLE "legacy_custom_widget_secret" RENAME CONSTRAINT "custom_widget_secret_definition_id_kind_pk" TO "legacy_custom_widget_secret_definition_id_kind_pk";--> statement-breakpoint
CREATE TABLE "custom_widget_definition" (
"id" varchar(64) PRIMARY KEY NOT NULL,
"name" varchar(256) NOT NULL,
"description" text,
"icon_url" text,
"sources" text NOT NULL,
"requests" text NOT NULL,
"options" text NOT NULL,
"template" text NOT NULL,
"enabled" boolean DEFAULT true NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
"creator_id" varchar(64)
);--> statement-breakpoint
CREATE TABLE "custom_widget_secret" (
"source_id" varchar(64) NOT NULL,
"kind" varchar(64) NOT NULL,
"encrypted_value" text NOT NULL,
"updated_at" timestamp NOT NULL,
"definition_id" varchar(64) NOT NULL,
CONSTRAINT "custom_widget_secret_definition_id_source_id_kind_pk" PRIMARY KEY("definition_id","source_id","kind")
);--> statement-breakpoint
ALTER TABLE "custom_widget_definition" ADD CONSTRAINT "custom_widget_definition_creator_id_user_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "custom_widget_secret" ADD CONSTRAINT "cw_secret_definition_id_fk" FOREIGN KEY ("definition_id") REFERENCES "public"."custom_widget_definition"("id") ON DELETE cascade ON UPDATE no action;
@@ -0,0 +1,25 @@
CREATE TABLE "custom_widget_v2_definition" (
"id" varchar(64) PRIMARY KEY NOT NULL,
"name" varchar(256) NOT NULL,
"description" text,
"icon_url" text,
"sources" text NOT NULL,
"requests" text NOT NULL,
"options" text NOT NULL,
"template" text NOT NULL,
"enabled" boolean DEFAULT true NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
"creator_id" varchar(64)
);--> statement-breakpoint
CREATE TABLE "custom_widget_v2_secret" (
"source_id" varchar(64) NOT NULL,
"kind" varchar(64) NOT NULL,
"encrypted_value" text NOT NULL,
"updated_at" timestamp NOT NULL,
"definition_id" varchar(64) NOT NULL,
CONSTRAINT "custom_widget_v2_secret_definition_id_source_id_kind_pk" PRIMARY KEY("definition_id","source_id","kind")
);--> statement-breakpoint
ALTER TABLE "custom_widget_v2_definition" ADD CONSTRAINT "custom_widget_v2_definition_creator_id_user_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "custom_widget_v2_secret" ADD CONSTRAINT "custom_widget_v2_secret_definition_id_fk" FOREIGN KEY ("definition_id") REFERENCES "public"."custom_widget_v2_definition"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
DELETE FROM "groupPermission" WHERE "permission" IN ('custom-widget-manage', 'custom-widget-secret-write');
@@ -1,23 +0,0 @@
ALTER TABLE "custom_widget_definition" RENAME TO "custom_widget_v2_definition";--> statement-breakpoint
ALTER TABLE "custom_widget_secret" RENAME TO "custom_widget_v2_secret";--> statement-breakpoint
ALTER TABLE "legacy_custom_widget_definition" RENAME TO "custom_widget_definition";--> statement-breakpoint
ALTER TABLE "legacy_custom_widget_secret" RENAME TO "custom_widget_secret";--> statement-breakpoint
ALTER TABLE "custom_widget_v2_definition"
RENAME CONSTRAINT "custom_widget_definition_creator_id_user_id_fk"
TO "custom_widget_v2_definition_creator_id_user_id_fk";--> statement-breakpoint
ALTER TABLE "custom_widget_v2_secret"
RENAME CONSTRAINT "cw_secret_definition_id_fk"
TO "custom_widget_v2_secret_definition_id_fk";--> statement-breakpoint
ALTER TABLE "custom_widget_v2_secret"
RENAME CONSTRAINT "custom_widget_secret_definition_id_source_id_kind_pk"
TO "custom_widget_v2_secret_definition_id_source_id_kind_pk";--> statement-breakpoint
ALTER TABLE "custom_widget_definition"
RENAME CONSTRAINT "legacy_cw_definition_creator_id_user_id_fk"
TO "custom_widget_definition_creator_id_user_id_fk";--> statement-breakpoint
ALTER TABLE "custom_widget_secret"
RENAME CONSTRAINT "legacy_cw_secret_definition_id_fk"
TO "custom_widget_secret_definition_id_custom_widget_definition_id_fk";--> statement-breakpoint
ALTER TABLE "custom_widget_secret"
RENAME CONSTRAINT "legacy_custom_widget_secret_definition_id_kind_pk"
TO "custom_widget_secret_definition_id_kind_pk";--> statement-breakpoint
DELETE FROM "groupPermission" WHERE "permission" IN ('custom-widget-manage', 'custom-widget-secret-write');
@@ -1,5 +1,5 @@
{
"id": "f2cd8146-b478-4617-870e-f601fb437d15",
"id": "99938d86-5059-41b3-a21c-ac767440ed00",
"prevId": "97bda61f-0a71-4e41-8e60-874aafe17115",
"version": "7",
"dialect": "postgresql",
@@ -498,180 +498,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
"public.legacy_custom_widget_definition": {
"name": "legacy_custom_widget_definition",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar(64)",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"icon_url": {
"name": "icon_url",
"type": "text",
"primaryKey": false,
"notNull": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true
},
"auth_type": {
"name": "auth_type",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true,
"default": "'none'"
},
"header_name": {
"name": "header_name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": false
},
"method": {
"name": "method",
"type": "varchar(16)",
"primaryKey": false,
"notNull": true,
"default": "'GET'"
},
"request_body": {
"name": "request_body",
"type": "text",
"primaryKey": false,
"notNull": false
},
"display_type": {
"name": "display_type",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true,
"default": "'singleValue'"
},
"display_config": {
"name": "display_config",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "'{\"json\": {}}'"
},
"enabled": {
"name": "enabled",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"creator_id": {
"name": "creator_id",
"type": "varchar(64)",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"legacy_cw_definition_creator_id_user_id_fk": {
"name": "legacy_cw_definition_creator_id_user_id_fk",
"tableFrom": "legacy_custom_widget_definition",
"tableTo": "user",
"columnsFrom": ["creator_id"],
"columnsTo": ["id"],
"onDelete": "set null",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.legacy_custom_widget_secret": {
"name": "legacy_custom_widget_secret",
"schema": "",
"columns": {
"kind": {
"name": "kind",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"definition_id": {
"name": "definition_id",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {
"legacy_cw_secret_definition_id_fk": {
"name": "legacy_cw_secret_definition_id_fk",
"tableFrom": "legacy_custom_widget_secret",
"tableTo": "legacy_custom_widget_definition",
"columnsFrom": ["definition_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"legacy_custom_widget_secret_definition_id_kind_pk": {
"name": "legacy_custom_widget_secret_definition_id_kind_pk",
"columns": ["definition_id", "kind"]
}
},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.custom_widget_definition": {
"name": "custom_widget_definition",
"public.custom_widget_v2_definition": {
"name": "custom_widget_v2_definition",
"schema": "",
"columns": {
"id": {
@@ -752,9 +580,9 @@
},
"indexes": {},
"foreignKeys": {
"custom_widget_definition_creator_id_user_id_fk": {
"name": "custom_widget_definition_creator_id_user_id_fk",
"tableFrom": "custom_widget_definition",
"custom_widget_v2_definition_creator_id_user_id_fk": {
"name": "custom_widget_v2_definition_creator_id_user_id_fk",
"tableFrom": "custom_widget_v2_definition",
"tableTo": "user",
"columnsFrom": ["creator_id"],
"columnsTo": ["id"],
@@ -768,8 +596,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
"public.custom_widget_secret": {
"name": "custom_widget_secret",
"public.custom_widget_v2_secret": {
"name": "custom_widget_v2_secret",
"schema": "",
"columns": {
"source_id": {
@@ -805,10 +633,10 @@
},
"indexes": {},
"foreignKeys": {
"cw_secret_definition_id_fk": {
"name": "cw_secret_definition_id_fk",
"tableFrom": "custom_widget_secret",
"tableTo": "custom_widget_definition",
"custom_widget_v2_secret_definition_id_fk": {
"name": "custom_widget_v2_secret_definition_id_fk",
"tableFrom": "custom_widget_v2_secret",
"tableTo": "custom_widget_v2_definition",
"columnsFrom": ["definition_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
@@ -816,8 +644,8 @@
}
},
"compositePrimaryKeys": {
"custom_widget_secret_definition_id_source_id_kind_pk": {
"name": "custom_widget_secret_definition_id_source_id_kind_pk",
"custom_widget_v2_secret_definition_id_source_id_kind_pk": {
"name": "custom_widget_v2_secret_definition_id_source_id_kind_pk",
"columns": ["definition_id", "source_id", "kind"]
}
},
@@ -1632,6 +1460,178 @@
"checkConstraints": {},
"isRLSEnabled": false
},
"public.custom_widget_definition": {
"name": "custom_widget_definition",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar(64)",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"icon_url": {
"name": "icon_url",
"type": "text",
"primaryKey": false,
"notNull": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true
},
"auth_type": {
"name": "auth_type",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true,
"default": "'none'"
},
"header_name": {
"name": "header_name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": false
},
"method": {
"name": "method",
"type": "varchar(16)",
"primaryKey": false,
"notNull": true,
"default": "'GET'"
},
"request_body": {
"name": "request_body",
"type": "text",
"primaryKey": false,
"notNull": false
},
"display_type": {
"name": "display_type",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true,
"default": "'singleValue'"
},
"display_config": {
"name": "display_config",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "'{\"json\": {}}'"
},
"enabled": {
"name": "enabled",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"creator_id": {
"name": "creator_id",
"type": "varchar(64)",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"custom_widget_definition_creator_id_user_id_fk": {
"name": "custom_widget_definition_creator_id_user_id_fk",
"tableFrom": "custom_widget_definition",
"tableTo": "user",
"columnsFrom": ["creator_id"],
"columnsTo": ["id"],
"onDelete": "set null",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.custom_widget_secret": {
"name": "custom_widget_secret",
"schema": "",
"columns": {
"kind": {
"name": "kind",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"definition_id": {
"name": "definition_id",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {
"custom_widget_secret_definition_id_custom_widget_definition_id_fk": {
"name": "custom_widget_secret_definition_id_custom_widget_definition_id_fk",
"tableFrom": "custom_widget_secret",
"tableTo": "custom_widget_definition",
"columnsFrom": ["definition_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"custom_widget_secret_definition_id_kind_pk": {
"name": "custom_widget_secret_definition_id_kind_pk",
"columns": ["definition_id", "kind"]
}
},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.media": {
"name": "media",
"schema": "",
File diff suppressed because it is too large. Load diff
@@ -76,14 +76,7 @@
"idx": 10,
"version": "7",
"when": 1784305412862,
"tag": "0010_custom_widget_v2_reset",
"breakpoints": true
},
{
"idx": 11,
"version": "7",
"when": 1785225823345,
"tag": "0011_custom_widget_v1_compatibility",
"tag": "0010_custom_widget_v2_tables",
"breakpoints": true
}
]
@@ -1,7 +1,4 @@
PRAGMA foreign_keys=OFF;--> statement-breakpoint
ALTER TABLE `custom_widget_definition` RENAME TO `legacy_custom_widget_definition`;--> statement-breakpoint
ALTER TABLE `custom_widget_secret` RENAME TO `legacy_custom_widget_secret`;--> statement-breakpoint
CREATE TABLE `custom_widget_definition` (
CREATE TABLE `custom_widget_v2_definition` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`description` text,
@@ -16,13 +13,13 @@ CREATE TABLE `custom_widget_definition` (
`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` (
CREATE TABLE `custom_widget_v2_secret` (
`source_id` text NOT NULL,
`kind` text NOT NULL,
`encrypted_value` text NOT NULL,
`updated_at` integer NOT NULL,
`definition_id` text NOT NULL,
PRIMARY KEY(`definition_id`, `source_id`, `kind`),
FOREIGN KEY (`definition_id`) REFERENCES `custom_widget_definition`(`id`) ON UPDATE no action ON DELETE cascade
FOREIGN KEY (`definition_id`) REFERENCES `custom_widget_v2_definition`(`id`) ON UPDATE no action ON DELETE cascade
);--> statement-breakpoint
PRAGMA foreign_keys=ON;
DELETE FROM `groupPermission` WHERE `permission` IN ('custom-widget-manage', 'custom-widget-secret-write');
@@ -1,5 +0,0 @@
ALTER TABLE `custom_widget_secret` RENAME TO `custom_widget_v2_secret`;--> statement-breakpoint
ALTER TABLE `custom_widget_definition` RENAME TO `custom_widget_v2_definition`;--> statement-breakpoint
ALTER TABLE `legacy_custom_widget_secret` RENAME TO `custom_widget_secret`;--> statement-breakpoint
ALTER TABLE `legacy_custom_widget_definition` RENAME TO `custom_widget_definition`;--> statement-breakpoint
DELETE FROM `groupPermission` WHERE `permission` IN ('custom-widget-manage', 'custom-widget-secret-write');
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "30bbf6f8-3a3c-4cb0-994e-9d8494e4fcd0",
"id": "51923913-fdc0-4ae7-9127-e86587e0b51f",
"prevId": "852e049b-72cc-4d7f-8be9-931c042fe019",
"tables": {
"account": {
@@ -515,193 +515,8 @@
"uniqueConstraints": {},
"checkConstraints": {}
},
"legacy_custom_widget_definition": {
"name": "legacy_custom_widget_definition",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"icon_url": {
"name": "icon_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"auth_type": {
"name": "auth_type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'none'"
},
"header_name": {
"name": "header_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"method": {
"name": "method",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'GET'"
},
"request_body": {
"name": "request_body",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"display_type": {
"name": "display_type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'singleValue'"
},
"display_config": {
"name": "display_config",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'{\"json\": {}}'"
},
"enabled": {
"name": "enabled",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": true
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"creator_id": {
"name": "creator_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"legacy_cw_definition_creator_id_user_id_fk": {
"name": "legacy_cw_definition_creator_id_user_id_fk",
"tableFrom": "legacy_custom_widget_definition",
"tableTo": "user",
"columnsFrom": ["creator_id"],
"columnsTo": ["id"],
"onDelete": "set null",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"legacy_custom_widget_secret": {
"name": "legacy_custom_widget_secret",
"columns": {
"kind": {
"name": "kind",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"definition_id": {
"name": "definition_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"legacy_cw_secret_definition_id_fk": {
"name": "legacy_cw_secret_definition_id_fk",
"tableFrom": "legacy_custom_widget_secret",
"tableTo": "legacy_custom_widget_definition",
"columnsFrom": ["definition_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"legacy_custom_widget_secret_definition_id_kind_pk": {
"columns": ["definition_id", "kind"],
"name": "legacy_custom_widget_secret_definition_id_kind_pk"
}
},
"uniqueConstraints": {},
"checkConstraints": {}
},
"custom_widget_definition": {
"name": "custom_widget_definition",
"custom_widget_v2_definition": {
"name": "custom_widget_v2_definition",
"columns": {
"id": {
"name": "id",
@@ -793,9 +608,9 @@
},
"indexes": {},
"foreignKeys": {
"custom_widget_definition_creator_id_user_id_fk": {
"name": "custom_widget_definition_creator_id_user_id_fk",
"tableFrom": "custom_widget_definition",
"custom_widget_v2_definition_creator_id_user_id_fk": {
"name": "custom_widget_v2_definition_creator_id_user_id_fk",
"tableFrom": "custom_widget_v2_definition",
"tableTo": "user",
"columnsFrom": ["creator_id"],
"columnsTo": ["id"],
@@ -807,8 +622,8 @@
"uniqueConstraints": {},
"checkConstraints": {}
},
"custom_widget_secret": {
"name": "custom_widget_secret",
"custom_widget_v2_secret": {
"name": "custom_widget_v2_secret",
"columns": {
"source_id": {
"name": "source_id",
@@ -848,10 +663,10 @@
},
"indexes": {},
"foreignKeys": {
"cw_secret_definition_id_fk": {
"name": "cw_secret_definition_id_fk",
"tableFrom": "custom_widget_secret",
"tableTo": "custom_widget_definition",
"custom_widget_v2_secret_definition_id_fk": {
"name": "custom_widget_v2_secret_definition_id_fk",
"tableFrom": "custom_widget_v2_secret",
"tableTo": "custom_widget_v2_definition",
"columnsFrom": ["definition_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
@@ -859,9 +674,9 @@
}
},
"compositePrimaryKeys": {
"custom_widget_secret_definition_id_source_id_kind_pk": {
"custom_widget_v2_secret_definition_id_source_id_kind_pk": {
"columns": ["definition_id", "source_id", "kind"],
"name": "custom_widget_secret_definition_id_source_id_kind_pk"
"name": "custom_widget_v2_secret_definition_id_source_id_kind_pk"
}
},
"uniqueConstraints": {},
@@ -1656,6 +1471,191 @@
"uniqueConstraints": {},
"checkConstraints": {}
},
"custom_widget_definition": {
"name": "custom_widget_definition",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"icon_url": {
"name": "icon_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"auth_type": {
"name": "auth_type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'none'"
},
"header_name": {
"name": "header_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"method": {
"name": "method",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'GET'"
},
"request_body": {
"name": "request_body",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"display_type": {
"name": "display_type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'singleValue'"
},
"display_config": {
"name": "display_config",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'{\"json\": {}}'"
},
"enabled": {
"name": "enabled",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": true
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"creator_id": {
"name": "creator_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"custom_widget_definition_creator_id_user_id_fk": {
"name": "custom_widget_definition_creator_id_user_id_fk",
"tableFrom": "custom_widget_definition",
"tableTo": "user",
"columnsFrom": ["creator_id"],
"columnsTo": ["id"],
"onDelete": "set null",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"custom_widget_secret": {
"name": "custom_widget_secret",
"columns": {
"kind": {
"name": "kind",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"definition_id": {
"name": "definition_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"custom_widget_secret_definition_id_custom_widget_definition_id_fk": {
"name": "custom_widget_secret_definition_id_custom_widget_definition_id_fk",
"tableFrom": "custom_widget_secret",
"tableTo": "custom_widget_definition",
"columnsFrom": ["definition_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"custom_widget_secret_definition_id_kind_pk": {
"columns": ["definition_id", "kind"],
"name": "custom_widget_secret_definition_id_kind_pk"
}
},
"uniqueConstraints": {},
"checkConstraints": {}
},
"media": {
"name": "media",
"columns": {
File diff suppressed because it is too large. Load diff
@@ -300,14 +300,7 @@
"idx": 42,
"version": "6",
"when": 1784305283910,
"tag": "0042_custom_widget_v2_reset",
"breakpoints": true
},
{
"idx": 43,
"version": "6",
"when": 1785225790467,
"tag": "0043_custom_widget_v1_compatibility",
"tag": "0042_custom_widget_v2_tables",
"breakpoints": true
}
]
+4 -5
View File
@@ -60,7 +60,7 @@ describe("Mysql Migration", () => {
await mysqlContainer.stop();
}, 90_000);
test("preserves v1 and already-created v2 custom widgets, secrets, and board references", async () => {
test("Custom Widget v2 migration preserves v1 data and board references", async () => {
const mysqlContainer = await new MySqlContainer("mysql:latest").start();
const connection = mysql.createConnection({
host: mysqlContainer.getHost(),
@@ -132,20 +132,19 @@ describe("Mysql Migration", () => {
legacyPlacementOptions,
]);
await applyMigration(connection, "0044_custom_widget_v2_reset.sql");
await applyMigration(connection, "0044_custom_widget_v2_tables.sql");
await sql.query(`
INSERT INTO \`custom_widget_definition\` (
INSERT INTO \`custom_widget_v2_definition\` (
\`id\`, \`name\`, \`sources\`, \`requests\`, \`options\`, \`template\`, \`enabled\`,
\`created_at\`, \`updated_at\`, \`creator_id\`
) VALUES (
'legacy-weather', 'Weather v2', '[]', '[]', '[]', '<Text>Weather</Text>', true,
'2023-11-14 00:00:02', '2023-11-14 00:00:03', 'owner'
);
INSERT INTO \`custom_widget_secret\` (
INSERT INTO \`custom_widget_v2_secret\` (
\`source_id\`, \`kind\`, \`encrypted_value\`, \`updated_at\`, \`definition_id\`
) VALUES ('weather', 'apiKey', 'encrypted.v2-value', '2023-11-14 00:00:03', 'legacy-weather');
`);
await applyMigration(connection, "0045_custom_widget_v1_compatibility.sql");
const [definitions] = await sql.query<mysql.RowDataPacket[]>(
"SELECT id, name, url, enabled, creator_id FROM custom_widget_definition",
@@ -70,7 +70,7 @@ describe("PostgreSql Migration", () => {
await postgreSqlContainer.stop();
}, 40_000);
test("preserves v1 and already-created v2 custom widgets, secrets, and board references", async () => {
test("Custom Widget v2 migration preserves v1 data and board references", async () => {
const postgreSqlContainer = await new PostgreSqlContainer("postgres:latest").start();
const pool = new Pool({
user: postgreSqlContainer.getUsername(),
@@ -140,20 +140,19 @@ describe("PostgreSql Migration", () => {
legacyPlacementOptions,
]);
await applyMigration(pool, "0010_custom_widget_v2_reset.sql");
await applyMigration(pool, "0010_custom_widget_v2_tables.sql");
await pool.query(`
INSERT INTO "custom_widget_definition" (
INSERT INTO "custom_widget_v2_definition" (
"id", "name", "sources", "requests", "options", "template", "enabled",
"created_at", "updated_at", "creator_id"
) VALUES (
'legacy-weather', 'Weather v2', '[]', '[]', '[]', '<Text>Weather</Text>', true,
'2023-11-14 00:00:02', '2023-11-14 00:00:03', 'owner'
);
INSERT INTO "custom_widget_secret" (
INSERT INTO "custom_widget_v2_secret" (
"source_id", "kind", "encrypted_value", "updated_at", "definition_id"
) VALUES ('weather', 'apiKey', 'encrypted.v2-value', '2023-11-14 00:00:03', 'legacy-weather');
`);
await applyMigration(pool, "0011_custom_widget_v1_compatibility.sql");
expect(
(await pool.query("SELECT id, name, url, enabled, creator_id FROM custom_widget_definition")).rows,
+4 -5
View File
@@ -45,7 +45,7 @@ test("SQLite migrations seed the five disabled bundled custom widgets", async ()
connection.close();
});
test("Custom JSX compatibility migration preserves v1 and already-created v2 data", () => {
test("Custom Widget v2 migration preserves v1 data and board references", () => {
const connection = new BetterSqlite3(":memory:");
const legacyPlacementOptions = SuperJSON.stringify({ definitionId: "legacy-weather", refreshInterval: 30 });
connection.exec(`
@@ -99,18 +99,17 @@ test("Custom JSX compatibility migration preserves v1 and already-created v2 dat
.prepare("INSERT INTO item (id, kind, options) VALUES ('weather-item', 'customApi', ?)")
.run(legacyPlacementOptions);
applyMigration(connection, "0042_custom_widget_v2_reset.sql");
applyMigration(connection, "0042_custom_widget_v2_tables.sql");
connection.exec(`
INSERT INTO custom_widget_definition (
INSERT INTO custom_widget_v2_definition (
id, name, sources, requests, options, template, enabled, created_at, updated_at, creator_id
) VALUES (
'legacy-weather', 'Weather v2', '[]', '[]', '[]', '<Text>Weather</Text>', true,
1700000002, 1700000003, 'owner'
);
INSERT INTO custom_widget_secret (source_id, kind, encrypted_value, updated_at, definition_id)
INSERT INTO custom_widget_v2_secret (source_id, kind, encrypted_value, updated_at, definition_id)
VALUES ('weather', 'apiKey', 'encrypted.v2-value', 1700000003, 'legacy-weather');
`);
applyMigration(connection, "0043_custom_widget_v1_compatibility.sql");
expect(connection.prepare("SELECT * FROM custom_widget_definition").get()).toMatchObject({
id: "legacy-weather",