mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-27 11:20:42 +01:00
Add built-in resources migration journal entry
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
a9d17267d7
commit
8d5cbb9f5e
3 files changed
+50
-26
No files matched your search
@@ -1,26 +0,0 @@
|
||||
CREATE TABLE "built_in_managed_resources" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"company_id" uuid NOT NULL,
|
||||
"bundle_key" text NOT NULL,
|
||||
"resource_kind" text NOT NULL,
|
||||
"resource_key" text NOT NULL,
|
||||
"resource_id" uuid NOT NULL,
|
||||
"stock_version" text NOT NULL,
|
||||
"stock_hash" text NOT NULL,
|
||||
"defaults_json" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE "built_in_managed_resources"
|
||||
ADD CONSTRAINT "built_in_managed_resources_company_id_companies_id_fk"
|
||||
FOREIGN KEY ("company_id") REFERENCES "companies"("id") ON DELETE cascade ON UPDATE no action;
|
||||
|
||||
CREATE INDEX "built_in_managed_resources_company_idx"
|
||||
ON "built_in_managed_resources" ("company_id");
|
||||
|
||||
CREATE INDEX "built_in_managed_resources_resource_idx"
|
||||
ON "built_in_managed_resources" ("resource_kind", "resource_id");
|
||||
|
||||
CREATE UNIQUE INDEX "built_in_managed_resources_company_bundle_resource_uq"
|
||||
ON "built_in_managed_resources" ("company_id", "bundle_key", "resource_kind", "resource_key");
|
||||
@@ -0,0 +1,43 @@
|
||||
CREATE TABLE IF NOT EXISTS "built_in_managed_resources" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"company_id" uuid NOT NULL,
|
||||
"bundle_key" text NOT NULL,
|
||||
"resource_kind" text NOT NULL,
|
||||
"resource_key" text NOT NULL,
|
||||
"resource_id" uuid NOT NULL,
|
||||
"stock_version" text NOT NULL,
|
||||
"stock_hash" text NOT NULL,
|
||||
"defaults_json" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM "pg_constraint" c
|
||||
JOIN "pg_class" t ON t.oid = c.conrelid
|
||||
JOIN "pg_namespace" n ON n.oid = t.relnamespace
|
||||
WHERE n.nspname = 'public'
|
||||
AND t.relname = 'built_in_managed_resources'
|
||||
AND c.conname = 'built_in_managed_resources_company_id_companies_id_fk'
|
||||
) THEN
|
||||
ALTER TABLE "built_in_managed_resources"
|
||||
ADD CONSTRAINT "built_in_managed_resources_company_id_companies_id_fk"
|
||||
FOREIGN KEY ("company_id") REFERENCES "companies"("id") ON DELETE cascade ON UPDATE no action;
|
||||
END IF;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "built_in_managed_resources_company_idx"
|
||||
ON "built_in_managed_resources" ("company_id");
|
||||
--> statement-breakpoint
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "built_in_managed_resources_resource_idx"
|
||||
ON "built_in_managed_resources" ("resource_kind", "resource_id");
|
||||
--> statement-breakpoint
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "built_in_managed_resources_company_bundle_resource_uq"
|
||||
ON "built_in_managed_resources" ("company_id", "bundle_key", "resource_kind", "resource_key");
|
||||
@@ -967,6 +967,13 @@
|
||||
"when": 1783555203000,
|
||||
"tag": "0139_skill_studio_run_templates",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 140,
|
||||
"version": "7",
|
||||
"when": 1783555300000,
|
||||
"tag": "0140_built_in_managed_resources",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user