Move drizzle/, dist/, and coverage/ into apps/server/ so all server-specific artifacts live alongside the source they belong to. - git mv drizzle/ → apps/server/drizzle/ - drizzle.config.ts: out → ./apps/server/drizzle - tsconfig.json: outDir → ./apps/server/dist, exclude drizzle dir - package.json: main/bin/clean point to apps/server/dist/ - vitest.config.ts: reportsDirectory → ./apps/server/coverage - .gitignore: add coverage/ entry - ensure-schema.ts: update getMigrationsPath() for new layout - docs/database-migrations.md: update drizzle/ references
33 lines
1.3 KiB
SQL
33 lines
1.3 KiB
SQL
-- Fix agents table FK constraints: initiative_id and account_id need ON DELETE SET NULL
|
|
-- SQLite cannot ALTER column constraints, so we must recreate the table
|
|
|
|
CREATE TABLE `agents_new` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`name` text NOT NULL,
|
|
`task_id` text REFERENCES `tasks`(`id`) ON DELETE SET NULL,
|
|
`initiative_id` text REFERENCES `initiatives`(`id`) ON DELETE SET NULL,
|
|
`session_id` text,
|
|
`worktree_id` text NOT NULL,
|
|
`provider` text DEFAULT 'claude' NOT NULL,
|
|
`account_id` text REFERENCES `accounts`(`id`) ON DELETE SET NULL,
|
|
`status` text DEFAULT 'idle' NOT NULL,
|
|
`mode` text DEFAULT 'execute' NOT NULL,
|
|
`pid` integer,
|
|
`exit_code` integer,
|
|
`output_file_path` text,
|
|
`result` text,
|
|
`pending_questions` text,
|
|
`created_at` integer NOT NULL,
|
|
`updated_at` integer NOT NULL,
|
|
`user_dismissed_at` integer
|
|
);--> statement-breakpoint
|
|
INSERT INTO `agents_new` SELECT
|
|
`id`, `name`, `task_id`, `initiative_id`, `session_id`, `worktree_id`,
|
|
`provider`, `account_id`, `status`, `mode`, `pid`, `exit_code`,
|
|
`output_file_path`, `result`, `pending_questions`,
|
|
`created_at`, `updated_at`, `user_dismissed_at`
|
|
FROM `agents`;--> statement-breakpoint
|
|
DROP TABLE `agents`;--> statement-breakpoint
|
|
ALTER TABLE `agents_new` RENAME TO `agents`;--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `agents_name_unique` ON `agents` (`name`);
|