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_timelines_events_deliverables_type" AS ENUM('output', 'input', 'document');
  CREATE TYPE "public"."enum_timelines_events_action_required" AS ENUM('customer', 'internal', 'both', 'automatic');
  CREATE TYPE "public"."enum_workflows_phases_steps_resources_type" AS ENUM('document', 'template', 'link', 'tool', 'video');
  CREATE TYPE "public"."enum_workflows_phases_steps_step_type" AS ENUM('task', 'decision', 'milestone', 'approval', 'wait', 'automatic');
  CREATE TYPE "public"."enum_workflows_phases_steps_priority" AS ENUM('critical', 'high', 'normal', 'low', 'optional');
  CREATE TYPE "public"."enum_workflows_global_resources_type" AS ENUM('document', 'template', 'checklist', 'link', 'tool');
  CREATE TYPE "public"."enum_workflows_type" AS ENUM('project', 'business', 'approval', 'onboarding', 'support', 'development', 'marketing', 'other');
  CREATE TYPE "public"."enum_workflows_status" AS ENUM('draft', 'published', 'archived');
  CREATE TYPE "public"."enum_workflows_properties_complexity" AS ENUM('simple', 'medium', 'complex', 'very_complex');
  CREATE TYPE "public"."enum_workflows_display_options_layout" AS ENUM('vertical', 'horizontal', 'flowchart', 'kanban', 'gantt');
  CREATE TYPE "public"."enum_workflows_display_options_color_scheme" AS ENUM('phase', 'status', 'priority', 'brand');
  CREATE TABLE "timelines_events_deliverables" (
  	"_order" integer NOT NULL,
  	"_parent_id" varchar NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"type" "enum_timelines_events_deliverables_type" DEFAULT 'output'
  );
  
  CREATE TABLE "timelines_events_deliverables_locales" (
  	"name" varchar,
  	"id" serial PRIMARY KEY NOT NULL,
  	"_locale" "_locales" NOT NULL,
  	"_parent_id" varchar NOT NULL
  );
  
  CREATE TABLE "workflows_phases_steps_conditions" (
  	"_order" integer NOT NULL,
  	"_parent_id" varchar NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"next_step" varchar,
  	"color" varchar
  );
  
  CREATE TABLE "workflows_phases_steps_conditions_locales" (
  	"condition" varchar,
  	"id" serial PRIMARY KEY NOT NULL,
  	"_locale" "_locales" NOT NULL,
  	"_parent_id" varchar NOT NULL
  );
  
  CREATE TABLE "workflows_phases_steps_checklist" (
  	"_order" integer NOT NULL,
  	"_parent_id" varchar NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"is_required" boolean DEFAULT true
  );
  
  CREATE TABLE "workflows_phases_steps_checklist_locales" (
  	"item" varchar NOT NULL,
  	"id" serial PRIMARY KEY NOT NULL,
  	"_locale" "_locales" NOT NULL,
  	"_parent_id" varchar NOT NULL
  );
  
  CREATE TABLE "workflows_phases_steps_resources" (
  	"_order" integer NOT NULL,
  	"_parent_id" varchar NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"type" "enum_workflows_phases_steps_resources_type" DEFAULT 'document',
  	"file_id" integer,
  	"url" varchar
  );
  
  CREATE TABLE "workflows_phases_steps_resources_locales" (
  	"name" varchar NOT NULL,
  	"description" varchar,
  	"id" serial PRIMARY KEY NOT NULL,
  	"_locale" "_locales" NOT NULL,
  	"_parent_id" varchar NOT NULL
  );
  
  CREATE TABLE "workflows_phases_steps_outputs" (
  	"_order" integer NOT NULL,
  	"_parent_id" varchar NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL
  );
  
  CREATE TABLE "workflows_phases_steps_outputs_locales" (
  	"name" varchar NOT NULL,
  	"description" varchar,
  	"id" serial PRIMARY KEY NOT NULL,
  	"_locale" "_locales" NOT NULL,
  	"_parent_id" varchar NOT NULL
  );
  
  CREATE TABLE "workflows_phases_steps" (
  	"_order" integer NOT NULL,
  	"_parent_id" varchar NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"step_type" "enum_workflows_phases_steps_step_type" DEFAULT 'task',
  	"priority" "enum_workflows_phases_steps_priority" DEFAULT 'normal',
  	"icon" varchar,
  	"dependencies_depends_on_steps" varchar,
  	"dependencies_can_run_parallel" boolean DEFAULT false,
  	"dependencies_is_blocking" boolean DEFAULT true,
  	"metadata" jsonb
  );
  
  CREATE TABLE "workflows_phases_steps_locales" (
  	"name" varchar NOT NULL,
  	"description" jsonb,
  	"short_description" varchar,
  	"estimated_duration" varchar,
  	"responsible" varchar,
  	"id" serial PRIMARY KEY NOT NULL,
  	"_locale" "_locales" NOT NULL,
  	"_parent_id" varchar NOT NULL
  );
  
  CREATE TABLE "workflows_phases_deliverables" (
  	"_order" integer NOT NULL,
  	"_parent_id" varchar NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL
  );
  
  CREATE TABLE "workflows_phases_deliverables_locales" (
  	"name" varchar NOT NULL,
  	"description" varchar,
  	"id" serial PRIMARY KEY NOT NULL,
  	"_locale" "_locales" NOT NULL,
  	"_parent_id" varchar NOT NULL
  );
  
  CREATE TABLE "workflows_phases" (
  	"_order" integer NOT NULL,
  	"_parent_id" integer NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"icon" varchar,
  	"color" varchar
  );
  
  CREATE TABLE "workflows_phases_locales" (
  	"name" varchar NOT NULL,
  	"description" varchar,
  	"estimated_duration" varchar,
  	"responsible" varchar,
  	"id" serial PRIMARY KEY NOT NULL,
  	"_locale" "_locales" NOT NULL,
  	"_parent_id" varchar NOT NULL
  );
  
  CREATE TABLE "workflows_global_resources" (
  	"_order" integer NOT NULL,
  	"_parent_id" integer NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"type" "enum_workflows_global_resources_type" DEFAULT 'document',
  	"file_id" integer,
  	"url" varchar
  );
  
  CREATE TABLE "workflows_global_resources_locales" (
  	"name" varchar NOT NULL,
  	"description" varchar,
  	"id" serial PRIMARY KEY NOT NULL,
  	"_locale" "_locales" NOT NULL,
  	"_parent_id" varchar NOT NULL
  );
  
  CREATE TABLE "workflows" (
  	"id" serial PRIMARY KEY NOT NULL,
  	"tenant_id" integer,
  	"slug" varchar NOT NULL,
  	"type" "enum_workflows_type" DEFAULT 'project' NOT NULL,
  	"status" "enum_workflows_status" DEFAULT 'draft' NOT NULL,
  	"image_id" integer,
  	"properties_complexity" "enum_workflows_properties_complexity",
  	"properties_is_iterative" boolean DEFAULT false,
  	"properties_allow_parallel_phases" boolean DEFAULT false,
  	"display_options_layout" "enum_workflows_display_options_layout" DEFAULT 'vertical',
  	"display_options_show_phase_numbers" boolean DEFAULT true,
  	"display_options_show_step_numbers" boolean DEFAULT true,
  	"display_options_show_durations" boolean DEFAULT true,
  	"display_options_show_responsible" boolean DEFAULT true,
  	"display_options_show_progress" boolean DEFAULT false,
  	"display_options_color_scheme" "enum_workflows_display_options_color_scheme" DEFAULT 'phase',
  	"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
  	"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
  );
  
  CREATE TABLE "workflows_locales" (
  	"name" varchar NOT NULL,
  	"description" jsonb,
  	"short_description" varchar,
  	"properties_estimated_duration" varchar,
  	"seo_meta_title" varchar,
  	"seo_meta_description" varchar,
  	"id" serial PRIMARY KEY NOT NULL,
  	"_locale" "_locales" NOT NULL,
  	"_parent_id" integer NOT NULL
  );
  
  ALTER TABLE "timelines_events" ADD COLUMN "step_number" numeric;
  ALTER TABLE "timelines_events" ADD COLUMN "action_required" "enum_timelines_events_action_required";
  ALTER TABLE "timelines_events_locales" ADD COLUMN "duration" varchar;
  ALTER TABLE "timelines_events_locales" ADD COLUMN "responsible" varchar;
  ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "workflows_id" integer;
  ALTER TABLE "timelines_events_deliverables" ADD CONSTRAINT "timelines_events_deliverables_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."timelines_events"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "timelines_events_deliverables_locales" ADD CONSTRAINT "timelines_events_deliverables_locales_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."timelines_events_deliverables"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps_conditions" ADD CONSTRAINT "workflows_phases_steps_conditions_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases_steps"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps_conditions_locales" ADD CONSTRAINT "workflows_phases_steps_conditions_locales_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases_steps_conditions"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps_checklist" ADD CONSTRAINT "workflows_phases_steps_checklist_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases_steps"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps_checklist_locales" ADD CONSTRAINT "workflows_phases_steps_checklist_locales_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases_steps_checklist"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps_resources" ADD CONSTRAINT "workflows_phases_steps_resources_file_id_media_id_fk" FOREIGN KEY ("file_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps_resources" ADD CONSTRAINT "workflows_phases_steps_resources_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases_steps"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps_resources_locales" ADD CONSTRAINT "workflows_phases_steps_resources_locales_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases_steps_resources"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps_outputs" ADD CONSTRAINT "workflows_phases_steps_outputs_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases_steps"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps_outputs_locales" ADD CONSTRAINT "workflows_phases_steps_outputs_locales_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases_steps_outputs"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps" ADD CONSTRAINT "workflows_phases_steps_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_steps_locales" ADD CONSTRAINT "workflows_phases_steps_locales_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases_steps"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_deliverables" ADD CONSTRAINT "workflows_phases_deliverables_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_deliverables_locales" ADD CONSTRAINT "workflows_phases_deliverables_locales_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases_deliverables"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases" ADD CONSTRAINT "workflows_phases_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_phases_locales" ADD CONSTRAINT "workflows_phases_locales_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_phases"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_global_resources" ADD CONSTRAINT "workflows_global_resources_file_id_media_id_fk" FOREIGN KEY ("file_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
  ALTER TABLE "workflows_global_resources" ADD CONSTRAINT "workflows_global_resources_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows_global_resources_locales" ADD CONSTRAINT "workflows_global_resources_locales_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows_global_resources"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "workflows" ADD CONSTRAINT "workflows_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE set null ON UPDATE no action;
  ALTER TABLE "workflows" ADD CONSTRAINT "workflows_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
  ALTER TABLE "workflows_locales" ADD CONSTRAINT "workflows_locales_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."workflows"("id") ON DELETE cascade ON UPDATE no action;
  CREATE INDEX "timelines_events_deliverables_order_idx" ON "timelines_events_deliverables" USING btree ("_order");
  CREATE INDEX "timelines_events_deliverables_parent_id_idx" ON "timelines_events_deliverables" USING btree ("_parent_id");
  CREATE UNIQUE INDEX "timelines_events_deliverables_locales_locale_parent_id_uniqu" ON "timelines_events_deliverables_locales" USING btree ("_locale","_parent_id");
  CREATE INDEX "workflows_phases_steps_conditions_order_idx" ON "workflows_phases_steps_conditions" USING btree ("_order");
  CREATE INDEX "workflows_phases_steps_conditions_parent_id_idx" ON "workflows_phases_steps_conditions" USING btree ("_parent_id");
  CREATE UNIQUE INDEX "workflows_phases_steps_conditions_locales_locale_parent_id_u" ON "workflows_phases_steps_conditions_locales" USING btree ("_locale","_parent_id");
  CREATE INDEX "workflows_phases_steps_checklist_order_idx" ON "workflows_phases_steps_checklist" USING btree ("_order");
  CREATE INDEX "workflows_phases_steps_checklist_parent_id_idx" ON "workflows_phases_steps_checklist" USING btree ("_parent_id");
  CREATE UNIQUE INDEX "workflows_phases_steps_checklist_locales_locale_parent_id_un" ON "workflows_phases_steps_checklist_locales" USING btree ("_locale","_parent_id");
  CREATE INDEX "workflows_phases_steps_resources_order_idx" ON "workflows_phases_steps_resources" USING btree ("_order");
  CREATE INDEX "workflows_phases_steps_resources_parent_id_idx" ON "workflows_phases_steps_resources" USING btree ("_parent_id");
  CREATE INDEX "workflows_phases_steps_resources_file_idx" ON "workflows_phases_steps_resources" USING btree ("file_id");
  CREATE UNIQUE INDEX "workflows_phases_steps_resources_locales_locale_parent_id_un" ON "workflows_phases_steps_resources_locales" USING btree ("_locale","_parent_id");
  CREATE INDEX "workflows_phases_steps_outputs_order_idx" ON "workflows_phases_steps_outputs" USING btree ("_order");
  CREATE INDEX "workflows_phases_steps_outputs_parent_id_idx" ON "workflows_phases_steps_outputs" USING btree ("_parent_id");
  CREATE UNIQUE INDEX "workflows_phases_steps_outputs_locales_locale_parent_id_uniq" ON "workflows_phases_steps_outputs_locales" USING btree ("_locale","_parent_id");
  CREATE INDEX "workflows_phases_steps_order_idx" ON "workflows_phases_steps" USING btree ("_order");
  CREATE INDEX "workflows_phases_steps_parent_id_idx" ON "workflows_phases_steps" USING btree ("_parent_id");
  CREATE UNIQUE INDEX "workflows_phases_steps_locales_locale_parent_id_unique" ON "workflows_phases_steps_locales" USING btree ("_locale","_parent_id");
  CREATE INDEX "workflows_phases_deliverables_order_idx" ON "workflows_phases_deliverables" USING btree ("_order");
  CREATE INDEX "workflows_phases_deliverables_parent_id_idx" ON "workflows_phases_deliverables" USING btree ("_parent_id");
  CREATE UNIQUE INDEX "workflows_phases_deliverables_locales_locale_parent_id_uniqu" ON "workflows_phases_deliverables_locales" USING btree ("_locale","_parent_id");
  CREATE INDEX "workflows_phases_order_idx" ON "workflows_phases" USING btree ("_order");
  CREATE INDEX "workflows_phases_parent_id_idx" ON "workflows_phases" USING btree ("_parent_id");
  CREATE UNIQUE INDEX "workflows_phases_locales_locale_parent_id_unique" ON "workflows_phases_locales" USING btree ("_locale","_parent_id");
  CREATE INDEX "workflows_global_resources_order_idx" ON "workflows_global_resources" USING btree ("_order");
  CREATE INDEX "workflows_global_resources_parent_id_idx" ON "workflows_global_resources" USING btree ("_parent_id");
  CREATE INDEX "workflows_global_resources_file_idx" ON "workflows_global_resources" USING btree ("file_id");
  CREATE UNIQUE INDEX "workflows_global_resources_locales_locale_parent_id_unique" ON "workflows_global_resources_locales" USING btree ("_locale","_parent_id");
  CREATE INDEX "workflows_tenant_idx" ON "workflows" USING btree ("tenant_id");
  CREATE UNIQUE INDEX "workflows_slug_idx" ON "workflows" USING btree ("slug");
  CREATE INDEX "workflows_image_idx" ON "workflows" USING btree ("image_id");
  CREATE INDEX "workflows_updated_at_idx" ON "workflows" USING btree ("updated_at");
  CREATE INDEX "workflows_created_at_idx" ON "workflows" USING btree ("created_at");
  CREATE UNIQUE INDEX "workflows_locales_locale_parent_id_unique" ON "workflows_locales" USING btree ("_locale","_parent_id");
  ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_workflows_fk" FOREIGN KEY ("workflows_id") REFERENCES "public"."workflows"("id") ON DELETE cascade ON UPDATE no action;
  CREATE INDEX "payload_locked_documents_rels_workflows_id_idx" ON "payload_locked_documents_rels" USING btree ("workflows_id");`)
}

export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
  await db.execute(sql`
   ALTER TABLE "timelines_events_deliverables" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "timelines_events_deliverables_locales" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_steps_conditions" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_steps_conditions_locales" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_steps_checklist" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_steps_checklist_locales" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_steps_resources" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_steps_resources_locales" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_steps_outputs" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_steps_outputs_locales" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_steps" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_steps_locales" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_deliverables" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_deliverables_locales" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_phases_locales" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_global_resources" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_global_resources_locales" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "workflows_locales" DISABLE ROW LEVEL SECURITY;
  DROP TABLE "timelines_events_deliverables" CASCADE;
  DROP TABLE "timelines_events_deliverables_locales" CASCADE;
  DROP TABLE "workflows_phases_steps_conditions" CASCADE;
  DROP TABLE "workflows_phases_steps_conditions_locales" CASCADE;
  DROP TABLE "workflows_phases_steps_checklist" CASCADE;
  DROP TABLE "workflows_phases_steps_checklist_locales" CASCADE;
  DROP TABLE "workflows_phases_steps_resources" CASCADE;
  DROP TABLE "workflows_phases_steps_resources_locales" CASCADE;
  DROP TABLE "workflows_phases_steps_outputs" CASCADE;
  DROP TABLE "workflows_phases_steps_outputs_locales" CASCADE;
  DROP TABLE "workflows_phases_steps" CASCADE;
  DROP TABLE "workflows_phases_steps_locales" CASCADE;
  DROP TABLE "workflows_phases_deliverables" CASCADE;
  DROP TABLE "workflows_phases_deliverables_locales" CASCADE;
  DROP TABLE "workflows_phases" CASCADE;
  DROP TABLE "workflows_phases_locales" CASCADE;
  DROP TABLE "workflows_global_resources" CASCADE;
  DROP TABLE "workflows_global_resources_locales" CASCADE;
  DROP TABLE "workflows" CASCADE;
  DROP TABLE "workflows_locales" CASCADE;
  ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_workflows_fk";
  
  DROP INDEX "payload_locked_documents_rels_workflows_id_idx";
  ALTER TABLE "timelines_events" DROP COLUMN "step_number";
  ALTER TABLE "timelines_events" DROP COLUMN "action_required";
  ALTER TABLE "timelines_events_locales" DROP COLUMN "duration";
  ALTER TABLE "timelines_events_locales" DROP COLUMN "responsible";
  ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "workflows_id";
  DROP TYPE "public"."enum_timelines_events_deliverables_type";
  DROP TYPE "public"."enum_timelines_events_action_required";
  DROP TYPE "public"."enum_workflows_phases_steps_resources_type";
  DROP TYPE "public"."enum_workflows_phases_steps_step_type";
  DROP TYPE "public"."enum_workflows_phases_steps_priority";
  DROP TYPE "public"."enum_workflows_global_resources_type";
  DROP TYPE "public"."enum_workflows_type";
  DROP TYPE "public"."enum_workflows_status";
  DROP TYPE "public"."enum_workflows_properties_complexity";
  DROP TYPE "public"."enum_workflows_display_options_layout";
  DROP TYPE "public"."enum_workflows_display_options_color_scheme";`)
}
