Namespace company skill identities
Persist canonical namespaced skill keys, split adapter runtime names from skill keys, and update portability/import flows to carry the canonical identity end-to-end. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
27
packages/db/src/migrations/0035_colorful_rhino.sql
Normal file
27
packages/db/src/migrations/0035_colorful_rhino.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
ALTER TABLE "company_skills" ADD COLUMN "key" text;--> statement-breakpoint
|
||||
UPDATE "company_skills"
|
||||
SET "key" = CASE
|
||||
WHEN COALESCE("metadata"->>'sourceKind', '') = 'paperclip_bundled' THEN 'paperclipai/paperclip/' || "slug"
|
||||
WHEN (COALESCE("metadata"->>'sourceKind', '') = 'github' OR "source_type" = 'github')
|
||||
AND COALESCE("metadata"->>'owner', '') <> ''
|
||||
AND COALESCE("metadata"->>'repo', '') <> ''
|
||||
THEN lower("metadata"->>'owner') || '/' || lower("metadata"->>'repo') || '/' || "slug"
|
||||
WHEN COALESCE("metadata"->>'sourceKind', '') = 'managed_local' THEN 'company/' || "company_id"::text || '/' || "slug"
|
||||
WHEN (COALESCE("metadata"->>'sourceKind', '') = 'url' OR "source_type" = 'url')
|
||||
THEN 'url/'
|
||||
|| COALESCE(
|
||||
NULLIF(regexp_replace(lower(regexp_replace(COALESCE("source_locator", ''), '^https?://([^/]+).*$','\1')), '[^a-z0-9._-]+', '-', 'g'), ''),
|
||||
'unknown'
|
||||
)
|
||||
|| '/'
|
||||
|| substr(md5(COALESCE("source_locator", "slug")), 1, 10)
|
||||
|| '/'
|
||||
|| "slug"
|
||||
WHEN "source_type" = 'local_path' AND COALESCE("source_locator", '') <> ''
|
||||
THEN 'local/' || substr(md5("source_locator"), 1, 10) || '/' || "slug"
|
||||
ELSE 'company/' || "company_id"::text || '/' || "slug"
|
||||
END
|
||||
WHERE "key" IS NULL;--> statement-breakpoint
|
||||
ALTER TABLE "company_skills" ALTER COLUMN "key" SET NOT NULL;--> statement-breakpoint
|
||||
DROP INDEX IF EXISTS "company_skills_company_slug_idx";--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "company_skills_company_key_idx" ON "company_skills" USING btree ("company_id","key");
|
||||
9212
packages/db/src/migrations/meta/0035_snapshot.json
Normal file
9212
packages/db/src/migrations/meta/0035_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -246,6 +246,13 @@
|
||||
"when": 1773697572188,
|
||||
"tag": "0034_fat_dormammu",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 35,
|
||||
"version": "7",
|
||||
"when": 1773703213570,
|
||||
"tag": "0035_colorful_rhino",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user