fix(foundry): use IF NOT EXISTS in org migration to handle pre-existing auth tables

Some org actors had auth tables created outside the migration system
(by earlier queue-based auth code). Migration m0001 fails with
"table auth_session_index already exists" on those actors, preventing
them from starting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nathan Flurry 2026-03-16 22:45:34 -07:00
parent 6ebe13cddd
commit eafe0f9fe4
2 changed files with 12 additions and 12 deletions

View file

@ -1,4 +1,4 @@
CREATE TABLE `auth_session_index` (
CREATE TABLE IF NOT EXISTS `auth_session_index` (
`session_id` text PRIMARY KEY NOT NULL,
`session_token` text NOT NULL,
`user_id` text NOT NULL,
@ -6,13 +6,13 @@ CREATE TABLE `auth_session_index` (
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `auth_email_index` (
CREATE TABLE IF NOT EXISTS `auth_email_index` (
`email` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `auth_account_index` (
CREATE TABLE IF NOT EXISTS `auth_account_index` (
`id` text PRIMARY KEY NOT NULL,
`provider_id` text NOT NULL,
`account_id` text NOT NULL,
@ -20,7 +20,7 @@ CREATE TABLE `auth_account_index` (
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `auth_verification` (
CREATE TABLE IF NOT EXISTS `auth_verification` (
`id` text PRIMARY KEY NOT NULL,
`identifier` text NOT NULL,
`value` text NOT NULL,
@ -29,7 +29,7 @@ CREATE TABLE `auth_verification` (
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `task_index` (
CREATE TABLE IF NOT EXISTS `task_index` (
`task_id` text PRIMARY KEY NOT NULL,
`repo_id` text NOT NULL,
`branch_name` text,
@ -37,7 +37,7 @@ CREATE TABLE `task_index` (
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `task_summaries` (
CREATE TABLE IF NOT EXISTS `task_summaries` (
`task_id` text PRIMARY KEY NOT NULL,
`repo_id` text NOT NULL,
`title` text NOT NULL,

View file

@ -121,7 +121,7 @@ CREATE TABLE \`stripe_lookup\` (
\`updated_at\` integer NOT NULL
);
`,
m0001: `CREATE TABLE \`auth_session_index\` (
m0001: `CREATE TABLE IF NOT EXISTS \`auth_session_index\` (
\`session_id\` text PRIMARY KEY NOT NULL,
\`session_token\` text NOT NULL,
\`user_id\` text NOT NULL,
@ -129,13 +129,13 @@ CREATE TABLE \`stripe_lookup\` (
\`updated_at\` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE \`auth_email_index\` (
CREATE TABLE IF NOT EXISTS \`auth_email_index\` (
\`email\` text PRIMARY KEY NOT NULL,
\`user_id\` text NOT NULL,
\`updated_at\` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE \`auth_account_index\` (
CREATE TABLE IF NOT EXISTS \`auth_account_index\` (
\`id\` text PRIMARY KEY NOT NULL,
\`provider_id\` text NOT NULL,
\`account_id\` text NOT NULL,
@ -143,7 +143,7 @@ CREATE TABLE \`auth_account_index\` (
\`updated_at\` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE \`auth_verification\` (
CREATE TABLE IF NOT EXISTS \`auth_verification\` (
\`id\` text PRIMARY KEY NOT NULL,
\`identifier\` text NOT NULL,
\`value\` text NOT NULL,
@ -152,7 +152,7 @@ CREATE TABLE \`auth_verification\` (
\`updated_at\` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE \`task_index\` (
CREATE TABLE IF NOT EXISTS \`task_index\` (
\`task_id\` text PRIMARY KEY NOT NULL,
\`repo_id\` text NOT NULL,
\`branch_name\` text,
@ -160,7 +160,7 @@ CREATE TABLE \`task_index\` (
\`updated_at\` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE \`task_summaries\` (
CREATE TABLE IF NOT EXISTS \`task_summaries\` (
\`task_id\` text PRIMARY KEY NOT NULL,
\`repo_id\` text NOT NULL,
\`title\` text NOT NULL,