From 22b324c1b39098279092c4970a3e986476fc8801 Mon Sep 17 00:00:00 2001 From: Caleb Adepitan Date: Mon, 11 Nov 2024 14:30:18 +0100 Subject: [PATCH] fix: invalid migration query --- ..._chemical_zuras.sql => 0001_fixed_secret_warriors.sql} | 2 +- packages/io/drizzle/meta/0001_snapshot.json | 4 ++-- packages/io/drizzle/meta/_journal.json | 4 ++-- packages/io/src/migrations/deployment.json | 8 ++++---- packages/io/src/schema/schedules.schema.ts | 3 ++- 5 files changed, 11 insertions(+), 10 deletions(-) rename packages/io/drizzle/{0001_chemical_zuras.sql => 0001_fixed_secret_warriors.sql} (99%) diff --git a/packages/io/drizzle/0001_chemical_zuras.sql b/packages/io/drizzle/0001_fixed_secret_warriors.sql similarity index 99% rename from packages/io/drizzle/0001_chemical_zuras.sql rename to packages/io/drizzle/0001_fixed_secret_warriors.sql index 593490a..7148c58 100644 --- a/packages/io/drizzle/0001_chemical_zuras.sql +++ b/packages/io/drizzle/0001_fixed_secret_warriors.sql @@ -1,7 +1,7 @@ CREATE TABLE `custom_frequencies` ( `id` text PRIMARY KEY NOT NULL, `schedule_id` text NOT NULL, - `type` text GENERATED ALWAYS AS (custom) VIRTUAL NOT NULL, + `type` text GENERATED ALWAYS AS ('custom') VIRTUAL NOT NULL, `crons` text NOT NULL, `created_at` integer DEFAULT (strftime('%s', 'now') || substr(strftime('%f', 'now'), -3)) NOT NULL, `updated_at` integer DEFAULT (strftime('%s', 'now') || substr(strftime('%f', 'now'), -3)) NOT NULL, diff --git a/packages/io/drizzle/meta/0001_snapshot.json b/packages/io/drizzle/meta/0001_snapshot.json index ca06f5e..fdaf6a6 100644 --- a/packages/io/drizzle/meta/0001_snapshot.json +++ b/packages/io/drizzle/meta/0001_snapshot.json @@ -1,7 +1,7 @@ { "version": "6", "dialect": "sqlite", - "id": "40451eb9-8369-488e-99f7-a45a255bdbfa", + "id": "fc4f447b-277d-45cb-b93a-003c491ec30a", "prevId": "2357a61f-629f-4cd4-b46e-2908bc1191d4", "tables": { "custom_frequencies": { @@ -28,7 +28,7 @@ "notNull": true, "autoincrement": false, "generated": { - "as": "(custom)", + "as": "('custom')", "type": "virtual" } }, diff --git a/packages/io/drizzle/meta/_journal.json b/packages/io/drizzle/meta/_journal.json index cc0bbb3..7d02f1c 100644 --- a/packages/io/drizzle/meta/_journal.json +++ b/packages/io/drizzle/meta/_journal.json @@ -12,8 +12,8 @@ { "idx": 1, "version": "6", - "when": 1731323500543, - "tag": "0001_chemical_zuras", + "when": 1731331713157, + "tag": "0001_fixed_secret_warriors", "breakpoints": true } ] diff --git a/packages/io/src/migrations/deployment.json b/packages/io/src/migrations/deployment.json index a4b0118..d655404 100644 --- a/packages/io/src/migrations/deployment.json +++ b/packages/io/src/migrations/deployment.json @@ -14,11 +14,11 @@ }, { "idx": 1, - "when": 1731323500543, - "tag": "0001_chemical_zuras", - "hash": "447369c5b8e4f2ef0864a738b592a9f0c4edfbb2b1de4848d280f6dfdb5bdc2e", + "when": 1731331713157, + "tag": "0001_fixed_secret_warriors", + "hash": "44ba53773a2821fb15d94f8aae7f0f183eb3d36621919657be91c776e1de0df6", "sql": [ - "CREATE TABLE `custom_frequencies` (`id` text PRIMARY KEY NOT NULL,`schedule_id` text NOT NULL,`type` text GENERATED ALWAYS AS (custom) VIRTUAL NOT NULL,`crons` text NOT NULL,`created_at` integer DEFAULT (strftime('%s', 'now') || substr(strftime('%f', 'now'), -3)) NOT NULL,`updated_at` integer DEFAULT (strftime('%s', 'now') || substr(strftime('%f', 'now'), -3)) NOT NULL,`deleted_at` integer,FOREIGN KEY (`schedule_id`) REFERENCES `schedules`(`id`) ON UPDATE no action ON DELETE cascade);", + "CREATE TABLE `custom_frequencies` (`id` text PRIMARY KEY NOT NULL,`schedule_id` text NOT NULL,`type` text GENERATED ALWAYS AS ('custom') VIRTUAL NOT NULL,`crons` text NOT NULL,`created_at` integer DEFAULT (strftime('%s', 'now') || substr(strftime('%f', 'now'), -3)) NOT NULL,`updated_at` integer DEFAULT (strftime('%s', 'now') || substr(strftime('%f', 'now'), -3)) NOT NULL,`deleted_at` integer,FOREIGN KEY (`schedule_id`) REFERENCES `schedules`(`id`) ON UPDATE no action ON DELETE cascade);", "CREATE UNIQUE INDEX `custom_frequencies_scheduleId_unique` ON `custom_frequencies` (`schedule_id`);", "CREATE TABLE `regular_frequencies` (`id` text PRIMARY KEY NOT NULL,`schedule_id` text NOT NULL,`type` text NOT NULL,`created_at` integer DEFAULT (strftime('%s', 'now') || substr(strftime('%f', 'now'), -3)) NOT NULL,`updated_at` integer DEFAULT (strftime('%s', 'now') || substr(strftime('%f', 'now'), -3)) NOT NULL,`deleted_at` integer,FOREIGN KEY (`schedule_id`) REFERENCES `schedules`(`id`) ON UPDATE no action ON DELETE cascade);", "CREATE UNIQUE INDEX `regular_frequencies_scheduleId_unique` ON `regular_frequencies` (`schedule_id`);", diff --git a/packages/io/src/schema/schedules.schema.ts b/packages/io/src/schema/schedules.schema.ts index 0902539..67f63a9 100644 --- a/packages/io/src/schema/schedules.schema.ts +++ b/packages/io/src/schema/schedules.schema.ts @@ -1,3 +1,4 @@ +import { sql } from 'drizzle-orm' import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core' import { withDefaults } from './common' @@ -122,7 +123,7 @@ export const customFrequencies = sqliteTable( */ type: text({ enum: ['custom'] }) .notNull() - .generatedAlwaysAs('custom'), + .generatedAlwaysAs(sql.raw(`'custom'`)), /** * The cron expressions, about 3 or less, for this schedule