Skip to content

Commit

Permalink
fix: invalid migration query
Browse files Browse the repository at this point in the history
  • Loading branch information
calebpitan committed Nov 11, 2024
1 parent 6f0640a commit 22b324c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/io/drizzle/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -28,7 +28,7 @@
"notNull": true,
"autoincrement": false,
"generated": {
"as": "(custom)",
"as": "('custom')",
"type": "virtual"
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/io/drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
{
"idx": 1,
"version": "6",
"when": 1731323500543,
"tag": "0001_chemical_zuras",
"when": 1731331713157,
"tag": "0001_fixed_secret_warriors",
"breakpoints": true
}
]
Expand Down
8 changes: 4 additions & 4 deletions packages/io/src/migrations/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -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`);",
Expand Down
3 changes: 2 additions & 1 deletion packages/io/src/schema/schedules.schema.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { sql } from 'drizzle-orm'
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'

import { withDefaults } from './common'
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 22b324c

Please sign in to comment.