diff options
Diffstat (limited to 'db/migrations/0215_secret_old_lace.sql')
| -rw-r--r-- | db/migrations/0215_secret_old_lace.sql | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/db/migrations/0215_secret_old_lace.sql b/db/migrations/0215_secret_old_lace.sql new file mode 100644 index 00000000..1069ab62 --- /dev/null +++ b/db/migrations/0215_secret_old_lace.sql @@ -0,0 +1,42 @@ +CREATE TABLE "template_history" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "template_id" uuid NOT NULL, + "version" integer NOT NULL, + "content" text NOT NULL, + "change_description" text, + "changed_by" uuid NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "template_variables" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "template_id" uuid NOT NULL, + "variable_name" text NOT NULL, + "variable_type" text NOT NULL, + "default_value" text, + "is_required" boolean DEFAULT false, + "description" text, + "validation_rule" jsonb, + "display_order" integer DEFAULT 0, + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "templates" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "name" text NOT NULL, + "slug" text NOT NULL, + "content" text NOT NULL, + "description" text, + "category" text, + "sample_data" jsonb DEFAULT '{}'::jsonb, + "is_active" boolean DEFAULT true, + "version" integer DEFAULT 1, + "created_by" uuid NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "templates_slug_unique" UNIQUE("slug") +); +--> statement-breakpoint +ALTER TABLE "template_history" ADD CONSTRAINT "template_history_template_id_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."templates"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "template_variables" ADD CONSTRAINT "template_variables_template_id_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."templates"("id") ON DELETE cascade ON UPDATE no action;
\ No newline at end of file |
