mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-16 03:03:06 +00:00
Local dev and the test suite previously defaulted to the live production Neon database, and running the tests mutated prod data. Add guardrails plus a proper local Postgres + migrations workflow so production can't be hit by mistake: - docker-compose: local Postgres 17 (matches prod) + auto-created teqo_test - dev guard refuses a non-local DATABASE_URL; tests refuse non-_test databases - .env.test isolates the suite; vitest/playwright load it and fail closed - Payload migrations set up (push disabled); build runs `payload migrate`, so deploys apply pending migrations to prod automatically - baseline `initial` migration + idempotent consent.text varchar->jsonb fix - `pnpm db:pull` copies prod content locally, excluding supporter PII - docs (README, AGENTS.md) + agent skills for the local-db/migration workflow
415 lines
23 KiB
TypeScript
415 lines
23 KiB
TypeScript
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
|
|
|
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|
await db.execute(sql`
|
|
CREATE TYPE "public"."enum_petition_status" AS ENUM('draft', 'published');
|
|
CREATE TYPE "public"."enum__petition_v_version_status" AS ENUM('draft', 'published');
|
|
CREATE TYPE "public"."enum_contact_state" AS ENUM('AC', 'AL', 'AM', 'AP', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA', 'MG', 'MS', 'MT', 'PA', 'PB', 'PE', 'PI', 'PR', 'RJ', 'RN', 'RO', 'RR', 'RS', 'SC', 'SE', 'SP', 'TO');
|
|
CREATE TYPE "public"."enum_payload_jobs_log_task_slug" AS ENUM('inline', 'schedulePublish');
|
|
CREATE TYPE "public"."enum_payload_jobs_log_state" AS ENUM('failed', 'succeeded');
|
|
CREATE TYPE "public"."enum_payload_jobs_task_slug" AS ENUM('inline', 'schedulePublish');
|
|
CREATE TYPE "public"."enum_site_settings_social_links_platform" AS ENUM('instagram', 'facebook', 'youtube', 'whatsapp');
|
|
CREATE TYPE "public"."enum_site_settings_status" AS ENUM('draft', 'published');
|
|
CREATE TYPE "public"."enum__site_settings_v_version_social_links_platform" AS ENUM('instagram', 'facebook', 'youtube', 'whatsapp');
|
|
CREATE TYPE "public"."enum__site_settings_v_version_status" AS ENUM('draft', 'published');
|
|
CREATE TABLE "users_sessions" (
|
|
"_order" integer NOT NULL,
|
|
"_parent_id" integer NOT NULL,
|
|
"id" varchar PRIMARY KEY NOT NULL,
|
|
"created_at" timestamp(3) with time zone,
|
|
"expires_at" timestamp(3) with time zone NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "users" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"email" varchar NOT NULL,
|
|
"reset_password_token" varchar,
|
|
"reset_password_expiration" timestamp(3) with time zone,
|
|
"salt" varchar,
|
|
"hash" varchar,
|
|
"login_attempts" numeric DEFAULT 0,
|
|
"lock_until" timestamp(3) with time zone
|
|
);
|
|
|
|
CREATE TABLE "media" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"alt" varchar NOT NULL,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"url" varchar,
|
|
"thumbnail_u_r_l" varchar,
|
|
"filename" varchar,
|
|
"mime_type" varchar,
|
|
"filesize" numeric,
|
|
"width" numeric,
|
|
"height" numeric,
|
|
"focal_x" numeric,
|
|
"focal_y" numeric
|
|
);
|
|
|
|
CREATE TABLE "petition" (
|
|
"id" varchar PRIMARY KEY NOT NULL,
|
|
"title" varchar,
|
|
"subtitle" varchar,
|
|
"enabled" boolean DEFAULT false,
|
|
"body" jsonb,
|
|
"form_title" varchar,
|
|
"form_subtitle" varchar,
|
|
"form_consent_id" integer,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"_status" "enum_petition_status" DEFAULT 'draft'
|
|
);
|
|
|
|
CREATE TABLE "_petition_v" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"parent_id" varchar,
|
|
"version_title" varchar,
|
|
"version_subtitle" varchar,
|
|
"version_enabled" boolean DEFAULT false,
|
|
"version_body" jsonb,
|
|
"version_form_title" varchar,
|
|
"version_form_subtitle" varchar,
|
|
"version_form_consent_id" integer,
|
|
"version_updated_at" timestamp(3) with time zone,
|
|
"version_created_at" timestamp(3) with time zone,
|
|
"version__status" "enum__petition_v_version_status" DEFAULT 'draft',
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"latest" boolean
|
|
);
|
|
|
|
CREATE TABLE "contact" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"name" varchar NOT NULL,
|
|
"email" varchar NOT NULL,
|
|
"phone" varchar NOT NULL,
|
|
"state" "enum_contact_state" NOT NULL,
|
|
"city" varchar NOT NULL,
|
|
"postal_code" varchar,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "consent" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"text" 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
|
|
);
|
|
|
|
CREATE TABLE "signature" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"contact_id" integer NOT NULL,
|
|
"petition_id" varchar NOT NULL,
|
|
"consent_id" integer NOT NULL,
|
|
"comment" varchar,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "subscription" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"contact_id" integer NOT NULL,
|
|
"consent_id" integer NOT NULL,
|
|
"comment" varchar,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "payload_kv" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"key" varchar NOT NULL,
|
|
"data" jsonb NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "payload_jobs_log" (
|
|
"_order" integer NOT NULL,
|
|
"_parent_id" integer NOT NULL,
|
|
"id" varchar PRIMARY KEY NOT NULL,
|
|
"executed_at" timestamp(3) with time zone NOT NULL,
|
|
"completed_at" timestamp(3) with time zone NOT NULL,
|
|
"task_slug" "enum_payload_jobs_log_task_slug" NOT NULL,
|
|
"task_i_d" varchar NOT NULL,
|
|
"input" jsonb,
|
|
"output" jsonb,
|
|
"state" "enum_payload_jobs_log_state" NOT NULL,
|
|
"error" jsonb
|
|
);
|
|
|
|
CREATE TABLE "payload_jobs" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"input" jsonb,
|
|
"completed_at" timestamp(3) with time zone,
|
|
"total_tried" numeric DEFAULT 0,
|
|
"has_error" boolean DEFAULT false,
|
|
"error" jsonb,
|
|
"task_slug" "enum_payload_jobs_task_slug",
|
|
"queue" varchar DEFAULT 'default',
|
|
"wait_until" timestamp(3) with time zone,
|
|
"processing" boolean DEFAULT false,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "payload_locked_documents" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"global_slug" varchar,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "payload_locked_documents_rels" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"order" integer,
|
|
"parent_id" integer NOT NULL,
|
|
"path" varchar NOT NULL,
|
|
"users_id" integer,
|
|
"media_id" integer,
|
|
"petition_id" varchar,
|
|
"contact_id" integer,
|
|
"consent_id" integer,
|
|
"signature_id" integer,
|
|
"subscription_id" integer
|
|
);
|
|
|
|
CREATE TABLE "payload_preferences" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"key" varchar,
|
|
"value" jsonb,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "payload_preferences_rels" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"order" integer,
|
|
"parent_id" integer NOT NULL,
|
|
"path" varchar NOT NULL,
|
|
"users_id" integer
|
|
);
|
|
|
|
CREATE TABLE "payload_migrations" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"name" varchar,
|
|
"batch" numeric,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "site_settings_social_links" (
|
|
"_order" integer NOT NULL,
|
|
"_parent_id" integer NOT NULL,
|
|
"id" varchar PRIMARY KEY NOT NULL,
|
|
"platform" "enum_site_settings_social_links_platform",
|
|
"url" varchar,
|
|
"label" varchar,
|
|
"enabled" boolean
|
|
);
|
|
|
|
CREATE TABLE "site_settings" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"header_title" varchar,
|
|
"_status" "enum_site_settings_status" DEFAULT 'draft',
|
|
"updated_at" timestamp(3) with time zone,
|
|
"created_at" timestamp(3) with time zone
|
|
);
|
|
|
|
CREATE TABLE "_site_settings_v_version_social_links" (
|
|
"_order" integer NOT NULL,
|
|
"_parent_id" integer NOT NULL,
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"platform" "enum__site_settings_v_version_social_links_platform",
|
|
"url" varchar,
|
|
"label" varchar,
|
|
"enabled" boolean,
|
|
"_uuid" varchar
|
|
);
|
|
|
|
CREATE TABLE "_site_settings_v" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"version_header_title" varchar,
|
|
"version__status" "enum__site_settings_v_version_status" DEFAULT 'draft',
|
|
"version_updated_at" timestamp(3) with time zone,
|
|
"version_created_at" timestamp(3) with time zone,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"latest" boolean,
|
|
"autosave" boolean
|
|
);
|
|
|
|
CREATE TABLE "home" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"image_id" integer NOT NULL,
|
|
"updated_at" timestamp(3) with time zone,
|
|
"created_at" timestamp(3) with time zone
|
|
);
|
|
|
|
CREATE TABLE "metadata_keywords" (
|
|
"_order" integer NOT NULL,
|
|
"_parent_id" integer NOT NULL,
|
|
"id" varchar PRIMARY KEY NOT NULL,
|
|
"keyword" varchar NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "metadata" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"url" varchar NOT NULL,
|
|
"title" varchar NOT NULL,
|
|
"description" varchar NOT NULL,
|
|
"open_graph_site_name" varchar NOT NULL,
|
|
"open_graph_description" varchar NOT NULL,
|
|
"twitter_creator" varchar NOT NULL,
|
|
"twitter_description" varchar NOT NULL,
|
|
"image_id" integer,
|
|
"updated_at" timestamp(3) with time zone,
|
|
"created_at" timestamp(3) with time zone
|
|
);
|
|
|
|
ALTER TABLE "users_sessions" ADD CONSTRAINT "users_sessions_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "petition" ADD CONSTRAINT "petition_form_consent_id_consent_id_fk" FOREIGN KEY ("form_consent_id") REFERENCES "public"."consent"("id") ON DELETE set null ON UPDATE no action;
|
|
ALTER TABLE "_petition_v" ADD CONSTRAINT "_petition_v_parent_id_petition_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."petition"("id") ON DELETE set null ON UPDATE no action;
|
|
ALTER TABLE "_petition_v" ADD CONSTRAINT "_petition_v_version_form_consent_id_consent_id_fk" FOREIGN KEY ("version_form_consent_id") REFERENCES "public"."consent"("id") ON DELETE set null ON UPDATE no action;
|
|
ALTER TABLE "signature" ADD CONSTRAINT "signature_contact_id_contact_id_fk" FOREIGN KEY ("contact_id") REFERENCES "public"."contact"("id") ON DELETE set null ON UPDATE no action;
|
|
ALTER TABLE "signature" ADD CONSTRAINT "signature_petition_id_petition_id_fk" FOREIGN KEY ("petition_id") REFERENCES "public"."petition"("id") ON DELETE set null ON UPDATE no action;
|
|
ALTER TABLE "signature" ADD CONSTRAINT "signature_consent_id_consent_id_fk" FOREIGN KEY ("consent_id") REFERENCES "public"."consent"("id") ON DELETE set null ON UPDATE no action;
|
|
ALTER TABLE "subscription" ADD CONSTRAINT "subscription_contact_id_contact_id_fk" FOREIGN KEY ("contact_id") REFERENCES "public"."contact"("id") ON DELETE set null ON UPDATE no action;
|
|
ALTER TABLE "subscription" ADD CONSTRAINT "subscription_consent_id_consent_id_fk" FOREIGN KEY ("consent_id") REFERENCES "public"."consent"("id") ON DELETE set null ON UPDATE no action;
|
|
ALTER TABLE "payload_jobs_log" ADD CONSTRAINT "payload_jobs_log_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."payload_jobs"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."payload_locked_documents"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_users_fk" FOREIGN KEY ("users_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_media_fk" FOREIGN KEY ("media_id") REFERENCES "public"."media"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_petition_fk" FOREIGN KEY ("petition_id") REFERENCES "public"."petition"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_contact_fk" FOREIGN KEY ("contact_id") REFERENCES "public"."contact"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_consent_fk" FOREIGN KEY ("consent_id") REFERENCES "public"."consent"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_signature_fk" FOREIGN KEY ("signature_id") REFERENCES "public"."signature"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_subscription_fk" FOREIGN KEY ("subscription_id") REFERENCES "public"."subscription"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "payload_preferences_rels" ADD CONSTRAINT "payload_preferences_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."payload_preferences"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "payload_preferences_rels" ADD CONSTRAINT "payload_preferences_rels_users_fk" FOREIGN KEY ("users_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "site_settings_social_links" ADD CONSTRAINT "site_settings_social_links_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."site_settings"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "_site_settings_v_version_social_links" ADD CONSTRAINT "_site_settings_v_version_social_links_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."_site_settings_v"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "home" ADD CONSTRAINT "home_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
|
|
ALTER TABLE "metadata_keywords" ADD CONSTRAINT "metadata_keywords_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."metadata"("id") ON DELETE cascade ON UPDATE no action;
|
|
ALTER TABLE "metadata" ADD CONSTRAINT "metadata_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
|
|
CREATE INDEX "users_sessions_order_idx" ON "users_sessions" USING btree ("_order");
|
|
CREATE INDEX "users_sessions_parent_id_idx" ON "users_sessions" USING btree ("_parent_id");
|
|
CREATE INDEX "users_updated_at_idx" ON "users" USING btree ("updated_at");
|
|
CREATE INDEX "users_created_at_idx" ON "users" USING btree ("created_at");
|
|
CREATE UNIQUE INDEX "users_email_idx" ON "users" USING btree ("email");
|
|
CREATE INDEX "media_updated_at_idx" ON "media" USING btree ("updated_at");
|
|
CREATE INDEX "media_created_at_idx" ON "media" USING btree ("created_at");
|
|
CREATE UNIQUE INDEX "media_filename_idx" ON "media" USING btree ("filename");
|
|
CREATE INDEX "petition_form_form_consent_idx" ON "petition" USING btree ("form_consent_id");
|
|
CREATE INDEX "petition_updated_at_idx" ON "petition" USING btree ("updated_at");
|
|
CREATE INDEX "petition_created_at_idx" ON "petition" USING btree ("created_at");
|
|
CREATE INDEX "petition__status_idx" ON "petition" USING btree ("_status");
|
|
CREATE INDEX "_petition_v_parent_idx" ON "_petition_v" USING btree ("parent_id");
|
|
CREATE INDEX "_petition_v_version_form_version_form_consent_idx" ON "_petition_v" USING btree ("version_form_consent_id");
|
|
CREATE INDEX "_petition_v_version_version_updated_at_idx" ON "_petition_v" USING btree ("version_updated_at");
|
|
CREATE INDEX "_petition_v_version_version_created_at_idx" ON "_petition_v" USING btree ("version_created_at");
|
|
CREATE INDEX "_petition_v_version_version__status_idx" ON "_petition_v" USING btree ("version__status");
|
|
CREATE INDEX "_petition_v_created_at_idx" ON "_petition_v" USING btree ("created_at");
|
|
CREATE INDEX "_petition_v_updated_at_idx" ON "_petition_v" USING btree ("updated_at");
|
|
CREATE INDEX "_petition_v_latest_idx" ON "_petition_v" USING btree ("latest");
|
|
CREATE INDEX "contact_updated_at_idx" ON "contact" USING btree ("updated_at");
|
|
CREATE INDEX "contact_created_at_idx" ON "contact" USING btree ("created_at");
|
|
CREATE INDEX "consent_updated_at_idx" ON "consent" USING btree ("updated_at");
|
|
CREATE INDEX "consent_created_at_idx" ON "consent" USING btree ("created_at");
|
|
CREATE INDEX "signature_contact_idx" ON "signature" USING btree ("contact_id");
|
|
CREATE INDEX "signature_petition_idx" ON "signature" USING btree ("petition_id");
|
|
CREATE INDEX "signature_consent_idx" ON "signature" USING btree ("consent_id");
|
|
CREATE INDEX "signature_updated_at_idx" ON "signature" USING btree ("updated_at");
|
|
CREATE INDEX "signature_created_at_idx" ON "signature" USING btree ("created_at");
|
|
CREATE INDEX "subscription_contact_idx" ON "subscription" USING btree ("contact_id");
|
|
CREATE INDEX "subscription_consent_idx" ON "subscription" USING btree ("consent_id");
|
|
CREATE INDEX "subscription_updated_at_idx" ON "subscription" USING btree ("updated_at");
|
|
CREATE INDEX "subscription_created_at_idx" ON "subscription" USING btree ("created_at");
|
|
CREATE UNIQUE INDEX "payload_kv_key_idx" ON "payload_kv" USING btree ("key");
|
|
CREATE INDEX "payload_jobs_log_order_idx" ON "payload_jobs_log" USING btree ("_order");
|
|
CREATE INDEX "payload_jobs_log_parent_id_idx" ON "payload_jobs_log" USING btree ("_parent_id");
|
|
CREATE INDEX "payload_jobs_completed_at_idx" ON "payload_jobs" USING btree ("completed_at");
|
|
CREATE INDEX "payload_jobs_total_tried_idx" ON "payload_jobs" USING btree ("total_tried");
|
|
CREATE INDEX "payload_jobs_has_error_idx" ON "payload_jobs" USING btree ("has_error");
|
|
CREATE INDEX "payload_jobs_task_slug_idx" ON "payload_jobs" USING btree ("task_slug");
|
|
CREATE INDEX "payload_jobs_queue_idx" ON "payload_jobs" USING btree ("queue");
|
|
CREATE INDEX "payload_jobs_wait_until_idx" ON "payload_jobs" USING btree ("wait_until");
|
|
CREATE INDEX "payload_jobs_processing_idx" ON "payload_jobs" USING btree ("processing");
|
|
CREATE INDEX "payload_jobs_updated_at_idx" ON "payload_jobs" USING btree ("updated_at");
|
|
CREATE INDEX "payload_jobs_created_at_idx" ON "payload_jobs" USING btree ("created_at");
|
|
CREATE INDEX "payload_locked_documents_global_slug_idx" ON "payload_locked_documents" USING btree ("global_slug");
|
|
CREATE INDEX "payload_locked_documents_updated_at_idx" ON "payload_locked_documents" USING btree ("updated_at");
|
|
CREATE INDEX "payload_locked_documents_created_at_idx" ON "payload_locked_documents" USING btree ("created_at");
|
|
CREATE INDEX "payload_locked_documents_rels_order_idx" ON "payload_locked_documents_rels" USING btree ("order");
|
|
CREATE INDEX "payload_locked_documents_rels_parent_idx" ON "payload_locked_documents_rels" USING btree ("parent_id");
|
|
CREATE INDEX "payload_locked_documents_rels_path_idx" ON "payload_locked_documents_rels" USING btree ("path");
|
|
CREATE INDEX "payload_locked_documents_rels_users_id_idx" ON "payload_locked_documents_rels" USING btree ("users_id");
|
|
CREATE INDEX "payload_locked_documents_rels_media_id_idx" ON "payload_locked_documents_rels" USING btree ("media_id");
|
|
CREATE INDEX "payload_locked_documents_rels_petition_id_idx" ON "payload_locked_documents_rels" USING btree ("petition_id");
|
|
CREATE INDEX "payload_locked_documents_rels_contact_id_idx" ON "payload_locked_documents_rels" USING btree ("contact_id");
|
|
CREATE INDEX "payload_locked_documents_rels_consent_id_idx" ON "payload_locked_documents_rels" USING btree ("consent_id");
|
|
CREATE INDEX "payload_locked_documents_rels_signature_id_idx" ON "payload_locked_documents_rels" USING btree ("signature_id");
|
|
CREATE INDEX "payload_locked_documents_rels_subscription_id_idx" ON "payload_locked_documents_rels" USING btree ("subscription_id");
|
|
CREATE INDEX "payload_preferences_key_idx" ON "payload_preferences" USING btree ("key");
|
|
CREATE INDEX "payload_preferences_updated_at_idx" ON "payload_preferences" USING btree ("updated_at");
|
|
CREATE INDEX "payload_preferences_created_at_idx" ON "payload_preferences" USING btree ("created_at");
|
|
CREATE INDEX "payload_preferences_rels_order_idx" ON "payload_preferences_rels" USING btree ("order");
|
|
CREATE INDEX "payload_preferences_rels_parent_idx" ON "payload_preferences_rels" USING btree ("parent_id");
|
|
CREATE INDEX "payload_preferences_rels_path_idx" ON "payload_preferences_rels" USING btree ("path");
|
|
CREATE INDEX "payload_preferences_rels_users_id_idx" ON "payload_preferences_rels" USING btree ("users_id");
|
|
CREATE INDEX "payload_migrations_updated_at_idx" ON "payload_migrations" USING btree ("updated_at");
|
|
CREATE INDEX "payload_migrations_created_at_idx" ON "payload_migrations" USING btree ("created_at");
|
|
CREATE INDEX "site_settings_social_links_order_idx" ON "site_settings_social_links" USING btree ("_order");
|
|
CREATE INDEX "site_settings_social_links_parent_id_idx" ON "site_settings_social_links" USING btree ("_parent_id");
|
|
CREATE INDEX "site_settings__status_idx" ON "site_settings" USING btree ("_status");
|
|
CREATE INDEX "_site_settings_v_version_social_links_order_idx" ON "_site_settings_v_version_social_links" USING btree ("_order");
|
|
CREATE INDEX "_site_settings_v_version_social_links_parent_id_idx" ON "_site_settings_v_version_social_links" USING btree ("_parent_id");
|
|
CREATE INDEX "_site_settings_v_version_version__status_idx" ON "_site_settings_v" USING btree ("version__status");
|
|
CREATE INDEX "_site_settings_v_created_at_idx" ON "_site_settings_v" USING btree ("created_at");
|
|
CREATE INDEX "_site_settings_v_updated_at_idx" ON "_site_settings_v" USING btree ("updated_at");
|
|
CREATE INDEX "_site_settings_v_latest_idx" ON "_site_settings_v" USING btree ("latest");
|
|
CREATE INDEX "_site_settings_v_autosave_idx" ON "_site_settings_v" USING btree ("autosave");
|
|
CREATE INDEX "home_image_idx" ON "home" USING btree ("image_id");
|
|
CREATE INDEX "metadata_keywords_order_idx" ON "metadata_keywords" USING btree ("_order");
|
|
CREATE INDEX "metadata_keywords_parent_id_idx" ON "metadata_keywords" USING btree ("_parent_id");
|
|
CREATE INDEX "metadata_image_idx" ON "metadata" USING btree ("image_id");`)
|
|
}
|
|
|
|
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
|
await db.execute(sql`
|
|
DROP TABLE "users_sessions" CASCADE;
|
|
DROP TABLE "users" CASCADE;
|
|
DROP TABLE "media" CASCADE;
|
|
DROP TABLE "petition" CASCADE;
|
|
DROP TABLE "_petition_v" CASCADE;
|
|
DROP TABLE "contact" CASCADE;
|
|
DROP TABLE "consent" CASCADE;
|
|
DROP TABLE "signature" CASCADE;
|
|
DROP TABLE "subscription" CASCADE;
|
|
DROP TABLE "payload_kv" CASCADE;
|
|
DROP TABLE "payload_jobs_log" CASCADE;
|
|
DROP TABLE "payload_jobs" CASCADE;
|
|
DROP TABLE "payload_locked_documents" CASCADE;
|
|
DROP TABLE "payload_locked_documents_rels" CASCADE;
|
|
DROP TABLE "payload_preferences" CASCADE;
|
|
DROP TABLE "payload_preferences_rels" CASCADE;
|
|
DROP TABLE "payload_migrations" CASCADE;
|
|
DROP TABLE "site_settings_social_links" CASCADE;
|
|
DROP TABLE "site_settings" CASCADE;
|
|
DROP TABLE "_site_settings_v_version_social_links" CASCADE;
|
|
DROP TABLE "_site_settings_v" CASCADE;
|
|
DROP TABLE "home" CASCADE;
|
|
DROP TABLE "metadata_keywords" CASCADE;
|
|
DROP TABLE "metadata" CASCADE;
|
|
DROP TYPE "public"."enum_petition_status";
|
|
DROP TYPE "public"."enum__petition_v_version_status";
|
|
DROP TYPE "public"."enum_contact_state";
|
|
DROP TYPE "public"."enum_payload_jobs_log_task_slug";
|
|
DROP TYPE "public"."enum_payload_jobs_log_state";
|
|
DROP TYPE "public"."enum_payload_jobs_task_slug";
|
|
DROP TYPE "public"."enum_site_settings_social_links_platform";
|
|
DROP TYPE "public"."enum_site_settings_status";
|
|
DROP TYPE "public"."enum__site_settings_v_version_social_links_platform";
|
|
DROP TYPE "public"."enum__site_settings_v_version_status";`)
|
|
}
|