qazaq-legacy-foundation-web/src/migrations/20261117_190000_foundation.ts
Peppa fc2b5a4127
All checks were successful
peppa/lint lint: success за 1с
peppa/typecheck typecheck: success за 2с
peppa/test test: success за 0с
peppa/build build: success за 41с
ci / checks (pull_request) Successful in 1m12s
deploy / deploy (pull_request) Successful in 14s
QLFW-55: учредитель, директор и попечительский совет на странице «О фонде»
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 18:59:21 +05:00

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\``)
}