All checks were successful
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
21 lines
1.0 KiB
TypeScript
21 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 \`site_settings_book_photos\` (
|
|
\`_order\` integer NOT NULL,
|
|
\`_parent_id\` integer NOT NULL,
|
|
\`id\` text PRIMARY KEY NOT NULL,
|
|
\`photo_id\` integer,
|
|
FOREIGN KEY (\`photo_id\`) REFERENCES \`media\`(\`id\`) ON UPDATE no action ON DELETE set null,
|
|
FOREIGN KEY (\`_parent_id\`) REFERENCES \`site_settings\`(\`id\`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
`)
|
|
await db.run(sql`CREATE INDEX \`site_settings_book_photos_order_idx\` ON \`site_settings_book_photos\` (\`_order\`);`)
|
|
await db.run(sql`CREATE INDEX \`site_settings_book_photos_parent_id_idx\` ON \`site_settings_book_photos\` (\`_parent_id\`);`)
|
|
await db.run(sql`CREATE INDEX \`site_settings_book_photos_photo_idx\` ON \`site_settings_book_photos\` (\`photo_id\`);`)
|
|
}
|
|
|
|
export async function down({ db }: MigrateDownArgs): Promise<void> {
|
|
await db.run(sql`DROP TABLE \`site_settings_book_photos\`;`)
|
|
}
|