shawon_majid

20260108160839_add_flow_nodes_table/migration.sql

Jan 8th, 2026 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PostgreSQL 1.64 KB | Source Code | 0 0
  1. /*
  2.   Warnings:
  3.  
  4.   - Changed the type of `node_id` on the `flow_filters` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
  5.   - Changed the type of `node_id` on the `flow_messages` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
  6.  
  7. */
  8. -- CreateEnum
  9. CREATE TYPE "t_flow_nodes_type" AS ENUM ('trigger', 'action');
  10.  
  11. -- AlterTable
  12. ALTER TABLE "flow_filters" DROP COLUMN "node_id",
  13. ADD COLUMN     "node_id" UUID NOT NULL;
  14.  
  15. -- AlterTable
  16. ALTER TABLE "flow_messages" DROP COLUMN "node_id",
  17. ADD COLUMN     "node_id" UUID NOT NULL;
  18.  
  19. -- CreateTable
  20. CREATE TABLE "flow_nodes" (
  21.     "id" UUID NOT NULL DEFAULT gen_random_uuid(),
  22.     "name" TEXT NOT NULL,
  23.     "flow_id" UUID NOT NULL,
  24.     "external_id" TEXT,
  25.     "type" "t_flow_nodes_type" NOT NULL,
  26.     "created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  27.     "updated_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  28.  
  29.     CONSTRAINT "flow_nodes_pkey" PRIMARY KEY ("id")
  30. );
  31.  
  32. -- AddForeignKey
  33. ALTER TABLE "flow_filters" ADD CONSTRAINT "flow_filters_node_id_fkey" FOREIGN KEY ("node_id") REFERENCES "flow_nodes"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
  34.  
  35. -- AddForeignKey
  36. ALTER TABLE "flow_nodes" ADD CONSTRAINT "flow_nodes_flow_id_fkey" FOREIGN KEY ("flow_id") REFERENCES "workflows"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
  37.  
  38. -- AddForeignKey
  39. ALTER TABLE "flow_messages" ADD CONSTRAINT "flow_messages_node_id_fkey" FOREIGN KEY ("node_id") REFERENCES "flow_nodes"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
  40.  
Advertisement
Add Comment
Please, Sign In to add comment