All checks were successful
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
import { type MigrateUpArgs, type MigrateDownArgs, sql } from '@payloadcms/db-sqlite'
|
|
|
|
export async function up({ db }: MigrateUpArgs): Promise<void> {
|
|
await db.run(sql`CREATE TABLE \`foundation_board\` (
|
|
\`_order\` integer NOT NULL,
|
|
\`_parent_id\` integer NOT NULL,
|
|
\`id\` text PRIMARY KEY NOT NULL,
|
|
\`name\` text NOT NULL,
|
|
\`role\` text DEFAULT 'member' NOT NULL,
|
|
FOREIGN KEY (\`_parent_id\`) REFERENCES \`foundation\`(\`id\`) ON UPDATE no action ON DELETE cascade
|
|
);`)
|
|
await db.run(sql`CREATE INDEX \`foundation_board_order_idx\` ON \`foundation_board\` (\`_order\`);`)
|
|
await db.run(sql`CREATE INDEX \`foundation_board_parent_id_idx\` ON \`foundation_board\` (\`_parent_id\`);`)
|
|
await db.run(sql`CREATE TABLE \`foundation\` (
|
|
\`id\` integer PRIMARY KEY NOT NULL,
|
|
\`founder\` text,
|
|
\`director\` text,
|
|
\`updated_at\` text,
|
|
\`created_at\` text
|
|
);`)
|
|
}
|
|
|
|
export async function down({ db }: MigrateDownArgs): Promise<void> {
|
|
await db.run(sql`DROP TABLE \`foundation_board\``)
|
|
await db.run(sql`DROP TABLE \`foundation\``)
|
|
}
|