feat: add migration for experience table and update payload_locked_documents_rels
This commit is contained in:
parent
9cc08c386a
commit
ade5616c68
3 changed files with 9274 additions and 1 deletions
9237
src/migrations/20260109_065519.json
Normal file
9237
src/migrations/20260109_065519.json
Normal file
File diff suppressed because it is too large
Load diff
30
src/migrations/20260109_065519.ts
Normal file
30
src/migrations/20260109_065519.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
||||
|
||||
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||
await db.execute(sql`
|
||||
CREATE TABLE "experience" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
"required_points" numeric NOT NULL,
|
||||
"description" jsonb NOT NULL,
|
||||
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "experience_id" integer;
|
||||
CREATE UNIQUE INDEX "experience_name_idx" ON "experience" USING btree ("name");
|
||||
CREATE INDEX "experience_updated_at_idx" ON "experience" USING btree ("updated_at");
|
||||
CREATE INDEX "experience_created_at_idx" ON "experience" USING btree ("created_at");
|
||||
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_experience_fk" FOREIGN KEY ("experience_id") REFERENCES "public"."experience"("id") ON DELETE cascade ON UPDATE no action;
|
||||
CREATE INDEX "payload_locked_documents_rels_experience_id_idx" ON "payload_locked_documents_rels" USING btree ("experience_id");`)
|
||||
}
|
||||
|
||||
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
||||
await db.execute(sql`
|
||||
ALTER TABLE "experience" DISABLE ROW LEVEL SECURITY;
|
||||
DROP TABLE "experience" CASCADE;
|
||||
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_experience_fk";
|
||||
|
||||
DROP INDEX "payload_locked_documents_rels_experience_id_idx";
|
||||
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "experience_id";`)
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ import * as migration_20251212_183607 from './20251212_183607';
|
|||
import * as migration_20251219_061127 from './20251219_061127';
|
||||
import * as migration_20251222_200320 from './20251222_200320';
|
||||
import * as migration_20251223_055859 from './20251223_055859';
|
||||
import * as migration_20260109_065519 from './20260109_065519';
|
||||
|
||||
export const migrations = [
|
||||
{
|
||||
|
|
@ -28,6 +29,11 @@ export const migrations = [
|
|||
{
|
||||
up: migration_20251223_055859.up,
|
||||
down: migration_20251223_055859.down,
|
||||
name: '20251223_055859'
|
||||
name: '20251223_055859',
|
||||
},
|
||||
{
|
||||
up: migration_20260109_065519.up,
|
||||
down: migration_20260109_065519.down,
|
||||
name: '20260109_065519'
|
||||
},
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in a new issue