From a993859c62b21cf78843169aa9e6598eca536559 Mon Sep 17 00:00:00 2001 From: Hein Date: Thu, 7 May 2026 13:30:30 +0200 Subject: [PATCH] feat(db): add oauth_clients table for dynamic client registration * Introduced oauth_clients table with fields for client_id, client_name, redirect_uris, and created_at. * Updated agent_persona_parts, agent_persona_skills, agent_persona_guardrails, agent_persona_traits, and arc_stage_parts tables to use unique constraints instead of primary keys for composite indexes. --- assets/icon_sm.ico | Bin 0 -> 12862 bytes assets/icon_sm.jpg | Bin 0 -> 2160 bytes assets/icon_sm.png | Bin 0 -> 11079 bytes assets/icon_sm48.png | Bin 0 -> 6480 bytes internal/app/app.go | 4 +- internal/app/oauth.go | 8 +- internal/app/resolvespec_models_generated.go | 1 + internal/auth/dynamic_client_store.go | 6 + internal/auth/middleware.go | 18 + internal/auth/postgres_client_store.go | 50 + .../sql_public_agent_persona_guardrails.go | 28 + .../sql_public_agent_persona_parts.go | 40 +- .../sql_public_agent_persona_skills.go | 36 +- .../sql_public_agent_persona_traits.go | 36 +- .../sql_public_arc_stage_parts.go | 36 +- .../sql_public_oauth_clients.go | 62 + .../generatedmodels/sql_public_persona_arc.go | 9 +- internal/store/db.go | 7 + migrations/020_generated_schema.sql | 6268 +++-------------- schema/agent_personas.dbml | 14 +- schema/oauth_clients.dbml | 8 + 21 files changed, 1223 insertions(+), 5408 deletions(-) create mode 100644 assets/icon_sm.ico create mode 100644 assets/icon_sm.jpg create mode 100644 assets/icon_sm.png create mode 100644 assets/icon_sm48.png create mode 100644 internal/auth/postgres_client_store.go create mode 100644 internal/generatedmodels/sql_public_oauth_clients.go create mode 100644 schema/oauth_clients.dbml diff --git a/assets/icon_sm.ico b/assets/icon_sm.ico new file mode 100644 index 0000000000000000000000000000000000000000..b81ad37962e8690035043adf73b947852f9e464d GIT binary patch literal 12862 zcmeIZ^;er&^e#U4&a}8&a0?JDK+q7}2?@a=!AXJ#2<{Tx-QC^Yp=hxJrL>d^?bKax zI&<&a`TTtUg6|hj-o?sVglF&bY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R| zGJdGG@fzXZUs+ELTS&*8ZK+vBAi7>ZbAZG&rcAwT4=bR0Xe0J%5 z6vj1vUc1Q6r_76u~(Usi9M;5!7&~-tZQ;0liz;-q$BEhlF!+R zxOR>zq@oE^na8p*I;e2DStLajLujy2C_A%nY(I9XYUroV+<`FJj~ z8p`()<-DmN#Ir^X)jq{$7$Cm^C2iL^{<4girBJUKwb_uC($J88jpR4#XLoE{G4&j! zO4+Q{ z-Ex_^HWt>SAMEhc!4}tyvHM>(2TV9o5y8(ZYNh)y5(`paLtctS+b5J)8G?+M1!|Cc zX*gF!cUxs3ijKBMg5-0P_j`{hSB@}dyZ#1HW?kk0 literal 0 HcmV?d00001 diff --git a/assets/icon_sm.png b/assets/icon_sm.png new file mode 100644 index 0000000000000000000000000000000000000000..dbea13734923152c6ec7391762643defe548d301 GIT binary patch literal 11079 zcmV-NE4b8&P)z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy32;bRa{vG?BLDy{BLR4&KXw2B00(qQO+^Rl1qTZYA&v9{`2YYQ z07*naRCwA=yLqf+*?r&lIm=yZfBWm#d-rUdo`th=$RS50P0|uAnvx9JlDsL7k-+vJ zjuHP8_>Tbu0|A5}h+#yrlPHcP%a$xT5=BcCB@JnjGaPcZX3x_5`num%ul8HF?sm?} zANNuA9~XrxR26W3=lquQU4#lcPIv)AYfuV-KuUq~LUh=`Z}o_K8$>I|370qV+N)SU zqAU%I$&~DHhsEJ8`QSdqa2s1DNUx1y#T8{r1DW(<7-XmYhqs!`HH}k_@2b`G*T+c%8_Ih zqh!J1bk5;)!7R-wiV|lnIM70SNH0M7AxMR@6;vg{8Ju-EXK^^BlxWW*2z*o&AU#W& z1!TUDR01hMNQn@l4hFV(_WNC{3NrRB_1=lJa3`&nAYwzz(IM9_(O=BrkBVpn=S6&ow9p#!ok@#d6x0s{SMu~@;?$i^a6Xo|G&a` zABV$PQKzQ%jsoDLl}F@zG(3H@cu8<{D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Gt$ zl0Sq57!?NPX@W*TsXUZlfq*2peE4X{mF*R#rC{$YL(iua{SzMl)n9Y^-usxULbw4a z2W!CE3R4zTd5S4gwDv<}R^d1v##(GTC%?$a_#*I73a8$pO6DAl6Ow0B$}cao-u79P zicWQD3LI(404NJ+yMoQ_2Iox|?PzRPQ92&NgGBo{p`@k-+r1h==<;lsk_b&Sjz~Ve z$L_OxBxm~+S&H;RlwSwsV)7J|mslZDUVy4K(K>9Q(j1w3*kn#IpHUSVCeHwi6Slv| zku6o0kd4Poo?S4#vxIwdnXPt>_0n)RD=|_LNI~6N7Nj6+xp)->fkUYk#_{MZc34n` zmZwPz!IQBiB0;2M;-{Zs(+J}Rh(-^`3D98^U29whdsRW!KPDevfa@c*i!O`e(u0`} z$wucC$rMwSfIx?BWY_@hQk4Z}I;Koh$}}b!O&LBJvi+3}n%g~EN>Q^GWlGMazhK%k1T;^?6iBcM; zR>!HgiT3V-b`jb`PmUflJ=$e*`iwlDT;_e+Mb+AAzr2kO9UdElDhwHr3&BW0ebGTLdW6%0^P`N}&}ZqIPuf4BI=zQb4sNG| z-(4V^MA$Qll@irxlJ(Ch&X1@B2q}<$o%(aHp}ZQEwWwwges{3@3G@Clius5tpM!Ss zIx8sG$7C@kOAtz<{2D0zMOG^iQelN=7{SvBmOPCO9nOR$FqWEu%0dkYts(amX{bpi zF{4NOJp6wj5g$CJN@Il9=vJFDFUW>Ns&tOf4pot2qA6f0qX}SfJ4=}PnDlH9oy8NZ zR7fubYf-fp{`yUn7g9!Jgp@doSMb-iP+=33rdU%Uv0RZ qKsg>&mQtQPrP}RNj!r1Y7yN(IOuS*x&};ty0000 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN compiled_at TYPE timestamptz USING compiled_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'compiled_detail' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN compiled_detail TYPE text USING compiled_detail::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'compiled_summary' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN compiled_summary TYPE text USING compiled_summary::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'description' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN description TYPE text USING description::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'detail' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN detail TYPE text USING detail::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'name' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN name TYPE text USING name::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'summary' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN summary TYPE text USING summary::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN tags TYPE text[] USING tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_personas' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_personas - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_parts' - AND a.attname = 'content' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_parts - ALTER COLUMN content TYPE text USING content::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_parts' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_parts - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_parts' - AND a.attname = 'description' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_parts - ALTER COLUMN description TYPE text USING description::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_parts' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.agent_parts - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_parts' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_parts - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_parts' - AND a.attname = 'name' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_parts - ALTER COLUMN name TYPE text USING name::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_parts' - AND a.attname = 'part_type' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_parts - ALTER COLUMN part_type TYPE text USING part_type::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_parts' - AND a.attname = 'summary' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_parts - ALTER COLUMN summary TYPE text USING summary::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_parts' - AND a.attname = 'tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.agent_parts - ALTER COLUMN tags TYPE text[] USING tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_parts' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_parts - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_persona_parts' - AND a.attname = 'part_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_persona_parts - ALTER COLUMN part_id TYPE bigint USING part_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_persona_parts' - AND a.attname = 'part_order' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['integer']) THEN - ALTER TABLE public.agent_persona_parts - ALTER COLUMN part_order TYPE integer USING part_order::integer; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_persona_parts' - AND a.attname = 'persona_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_persona_parts - ALTER COLUMN persona_id TYPE bigint USING persona_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_persona_parts' - AND a.attname = 'priority' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['integer']) THEN - ALTER TABLE public.agent_persona_parts - ALTER COLUMN priority TYPE integer USING priority::integer; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_persona_skills' - AND a.attname = 'persona_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_persona_skills - ALTER COLUMN persona_id TYPE bigint USING persona_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_persona_skills' - AND a.attname = 'skill_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_persona_skills - ALTER COLUMN skill_id TYPE bigint USING skill_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_persona_guardrails' - AND a.attname = 'guardrail_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_persona_guardrails - ALTER COLUMN guardrail_id TYPE bigint USING guardrail_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_persona_guardrails' - AND a.attname = 'persona_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_persona_guardrails - ALTER COLUMN persona_id TYPE bigint USING persona_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_traits' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_traits - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_traits' - AND a.attname = 'description' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_traits - ALTER COLUMN description TYPE text USING description::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_traits' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.agent_traits - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_traits' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_traits - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_traits' - AND a.attname = 'instruction' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_traits - ALTER COLUMN instruction TYPE text USING instruction::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_traits' - AND a.attname = 'name' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_traits - ALTER COLUMN name TYPE text USING name::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_traits' - AND a.attname = 'tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.agent_traits - ALTER COLUMN tags TYPE text[] USING tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_traits' - AND a.attname = 'trait_type' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_traits - ALTER COLUMN trait_type TYPE text USING trait_type::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_traits' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_traits - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_persona_traits' - AND a.attname = 'persona_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_persona_traits - ALTER COLUMN persona_id TYPE bigint USING persona_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_persona_traits' - AND a.attname = 'trait_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_persona_traits - ALTER COLUMN trait_id TYPE bigint USING trait_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'character_arcs' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.character_arcs - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'character_arcs' - AND a.attname = 'description' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.character_arcs - ALTER COLUMN description TYPE text USING description::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'character_arcs' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.character_arcs - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'character_arcs' - AND a.attname = 'name' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.character_arcs - ALTER COLUMN name TYPE text USING name::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'character_arcs' - AND a.attname = 'summary' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.character_arcs - ALTER COLUMN summary TYPE text USING summary::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'character_arcs' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.character_arcs - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'arc_stages' - AND a.attname = 'arc_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.arc_stages - ALTER COLUMN arc_id TYPE bigint USING arc_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'arc_stages' - AND a.attname = 'condition' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.arc_stages - ALTER COLUMN condition TYPE text USING condition::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'arc_stages' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.arc_stages - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'arc_stages' - AND a.attname = 'description' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.arc_stages - ALTER COLUMN description TYPE text USING description::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'arc_stages' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.arc_stages - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'arc_stages' - AND a.attname = 'name' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.arc_stages - ALTER COLUMN name TYPE text USING name::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'arc_stages' - AND a.attname = 'stage_order' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['integer']) THEN - ALTER TABLE public.arc_stages - ALTER COLUMN stage_order TYPE integer USING stage_order::integer; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'arc_stage_parts' - AND a.attname = 'part_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.arc_stage_parts - ALTER COLUMN part_id TYPE bigint USING part_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'arc_stage_parts' - AND a.attname = 'stage_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.arc_stage_parts - ALTER COLUMN stage_id TYPE bigint USING stage_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'persona_arc' - AND a.attname = 'arc_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.persona_arc - ALTER COLUMN arc_id TYPE bigint USING arc_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'persona_arc' - AND a.attname = 'current_stage_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.persona_arc - ALTER COLUMN current_stage_id TYPE bigint USING current_stage_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'persona_arc' - AND a.attname = 'persona_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.persona_arc - ALTER COLUMN persona_id TYPE bigint USING persona_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'persona_arc' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.persona_arc - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thoughts' - AND a.attname = 'archived_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.thoughts - ALTER COLUMN archived_at TYPE timestamptz USING archived_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thoughts' - AND a.attname = 'content' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.thoughts - ALTER COLUMN content TYPE text USING content::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thoughts' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.thoughts - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thoughts' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.thoughts - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thoughts' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.thoughts - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thoughts' - AND a.attname = 'metadata' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['jsonb']) THEN - ALTER TABLE public.thoughts - ALTER COLUMN metadata TYPE jsonb USING metadata::jsonb; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thoughts' - AND a.attname = 'project_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.thoughts - ALTER COLUMN project_id TYPE bigint USING project_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thoughts' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.thoughts - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'projects' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.projects - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'projects' - AND a.attname = 'description' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.projects - ALTER COLUMN description TYPE text USING description::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'projects' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.projects - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'projects' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.projects - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'projects' - AND a.attname = 'last_active_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.projects - ALTER COLUMN last_active_at TYPE timestamptz USING last_active_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'projects' - AND a.attname = 'name' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.projects - ALTER COLUMN name TYPE text USING name::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thought_links' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.thought_links - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thought_links' - AND a.attname = 'from_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.thought_links - ALTER COLUMN from_id TYPE bigint USING from_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thought_links' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.thought_links - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thought_links' - AND a.attname = 'relation' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.thought_links - ALTER COLUMN relation TYPE text USING relation::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'thought_links' - AND a.attname = 'to_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.thought_links - ALTER COLUMN to_id TYPE bigint USING to_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'embeddings' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.embeddings - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'embeddings' - AND a.attname = 'dim' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['integer']) THEN - ALTER TABLE public.embeddings - ALTER COLUMN dim TYPE integer USING dim::integer; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'embeddings' - AND a.attname = 'embedding' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['vector']) THEN - ALTER TABLE public.embeddings - ALTER COLUMN embedding TYPE vector USING embedding::vector; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'embeddings' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.embeddings - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'embeddings' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.embeddings - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'embeddings' - AND a.attname = 'model' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.embeddings - ALTER COLUMN model TYPE text USING model::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'embeddings' - AND a.attname = 'thought_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.embeddings - ALTER COLUMN thought_id TYPE bigint USING thought_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'embeddings' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.embeddings - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'content' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bytea']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN content TYPE bytea USING content::bytea; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'encoding' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN encoding TYPE text USING encoding::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'kind' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN kind TYPE text USING kind::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'media_type' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN media_type TYPE text USING media_type::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'name' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN name TYPE text USING name::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'project_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN project_id TYPE bigint USING project_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'sha256' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN sha256 TYPE text USING sha256::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'size_bytes' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN size_bytes TYPE bigint USING size_bytes::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'thought_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN thought_id TYPE bigint USING thought_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'stored_files' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.stored_files - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'agent_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN agent_id TYPE text USING agent_id::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'channel' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN channel TYPE text USING channel::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'messages' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['jsonb']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN messages TYPE jsonb USING messages::jsonb; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'metadata' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['jsonb']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN metadata TYPE jsonb USING metadata::jsonb; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'project_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN project_id TYPE bigint USING project_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'session_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN session_id TYPE text USING session_id::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'summary' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN summary TYPE text USING summary::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'title' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN title TYPE text USING title::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'chat_histories' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.chat_histories - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'tool_annotations' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.tool_annotations - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'tool_annotations' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.tool_annotations - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'tool_annotations' - AND a.attname = 'notes' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.tool_annotations - ALTER COLUMN notes TYPE text USING notes::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'tool_annotations' - AND a.attname = 'tool_name' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.tool_annotations - ALTER COLUMN tool_name TYPE text USING tool_name::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'tool_annotations' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.tool_annotations - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'action_required' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['boolean']) THEN - ALTER TABLE public.learnings - ALTER COLUMN action_required TYPE boolean USING action_required::boolean; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'area' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.learnings - ALTER COLUMN area TYPE text USING area::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'category' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.learnings - ALTER COLUMN category TYPE text USING category::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'confidence' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.learnings - ALTER COLUMN confidence TYPE text USING confidence::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.learnings - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'details' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.learnings - ALTER COLUMN details TYPE text USING details::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'duplicate_of_learning_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.learnings - ALTER COLUMN duplicate_of_learning_id TYPE bigint USING duplicate_of_learning_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.learnings - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.learnings - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'priority' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.learnings - ALTER COLUMN priority TYPE text USING priority::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'project_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.learnings - ALTER COLUMN project_id TYPE bigint USING project_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'related_skill_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.learnings - ALTER COLUMN related_skill_id TYPE bigint USING related_skill_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'related_thought_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.learnings - ALTER COLUMN related_thought_id TYPE bigint USING related_thought_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'reviewed_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.learnings - ALTER COLUMN reviewed_at TYPE timestamptz USING reviewed_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'reviewed_by' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.learnings - ALTER COLUMN reviewed_by TYPE text USING reviewed_by::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'source_ref' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.learnings - ALTER COLUMN source_ref TYPE text USING source_ref::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'source_type' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.learnings - ALTER COLUMN source_type TYPE text USING source_type::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'status' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.learnings - ALTER COLUMN status TYPE text USING status::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'summary' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.learnings - ALTER COLUMN summary TYPE text USING summary::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'supersedes_learning_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.learnings - ALTER COLUMN supersedes_learning_id TYPE bigint USING supersedes_learning_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.learnings - ALTER COLUMN tags TYPE text[] USING tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'learnings' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.learnings - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'completed_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.plans - ALTER COLUMN completed_at TYPE timestamptz USING completed_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.plans - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'description' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.plans - ALTER COLUMN description TYPE text USING description::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'due_date' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.plans - ALTER COLUMN due_date TYPE timestamptz USING due_date::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.plans - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plans - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'last_reviewed_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.plans - ALTER COLUMN last_reviewed_at TYPE timestamptz USING last_reviewed_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'owner' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.plans - ALTER COLUMN owner TYPE text USING owner::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'priority' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.plans - ALTER COLUMN priority TYPE text USING priority::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'project_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plans - ALTER COLUMN project_id TYPE bigint USING project_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'reviewed_by' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.plans - ALTER COLUMN reviewed_by TYPE text USING reviewed_by::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'status' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.plans - ALTER COLUMN status TYPE text USING status::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'supersedes_plan_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plans - ALTER COLUMN supersedes_plan_id TYPE bigint USING supersedes_plan_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.plans - ALTER COLUMN tags TYPE text[] USING tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'title' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.plans - ALTER COLUMN title TYPE text USING title::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plans' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.plans - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_dependencies' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.plan_dependencies - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_dependencies' - AND a.attname = 'depends_on_plan_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_dependencies - ALTER COLUMN depends_on_plan_id TYPE bigint USING depends_on_plan_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_dependencies' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_dependencies - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_dependencies' - AND a.attname = 'plan_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_dependencies - ALTER COLUMN plan_id TYPE bigint USING plan_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_related_plans' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.plan_related_plans - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_related_plans' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_related_plans - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_related_plans' - AND a.attname = 'plan_a_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_related_plans - ALTER COLUMN plan_a_id TYPE bigint USING plan_a_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_related_plans' - AND a.attname = 'plan_b_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_related_plans - ALTER COLUMN plan_b_id TYPE bigint USING plan_b_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_skills' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.plan_skills - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_skills' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_skills - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_skills' - AND a.attname = 'plan_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_skills - ALTER COLUMN plan_id TYPE bigint USING plan_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_skills' - AND a.attname = 'skill_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_skills - ALTER COLUMN skill_id TYPE bigint USING skill_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_guardrails' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.plan_guardrails - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_guardrails' - AND a.attname = 'guardrail_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_guardrails - ALTER COLUMN guardrail_id TYPE bigint USING guardrail_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_guardrails' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_guardrails - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'plan_guardrails' - AND a.attname = 'plan_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.plan_guardrails - ALTER COLUMN plan_id TYPE bigint USING plan_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'content' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN content TYPE text USING content::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'description' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN description TYPE text USING description::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'domain_tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN domain_tags TYPE text[] USING domain_tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'framework_tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN framework_tags TYPE text[] USING framework_tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'language_tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN language_tags TYPE text[] USING language_tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'library_tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN library_tags TYPE text[] USING library_tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'name' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN name TYPE text USING name::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN tags TYPE text[] USING tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_skills' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_skills - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_guardrails' - AND a.attname = 'content' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_guardrails - ALTER COLUMN content TYPE text USING content::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_guardrails' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_guardrails - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_guardrails' - AND a.attname = 'description' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_guardrails - ALTER COLUMN description TYPE text USING description::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_guardrails' - AND a.attname = 'guid' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['uuid']) THEN - ALTER TABLE public.agent_guardrails - ALTER COLUMN guid TYPE uuid USING guid::uuid; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_guardrails' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.agent_guardrails - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_guardrails' - AND a.attname = 'name' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_guardrails - ALTER COLUMN name TYPE text USING name::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_guardrails' - AND a.attname = 'severity' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text']) THEN - ALTER TABLE public.agent_guardrails - ALTER COLUMN severity TYPE text USING severity::text; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_guardrails' - AND a.attname = 'tags' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['text[]']) THEN - ALTER TABLE public.agent_guardrails - ALTER COLUMN tags TYPE text[] USING tags::text[]; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'agent_guardrails' - AND a.attname = 'updated_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.agent_guardrails - ALTER COLUMN updated_at TYPE timestamptz USING updated_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'project_skills' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.project_skills - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'project_skills' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.project_skills - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'project_skills' - AND a.attname = 'project_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.project_skills - ALTER COLUMN project_id TYPE bigint USING project_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'project_skills' - AND a.attname = 'skill_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.project_skills - ALTER COLUMN skill_id TYPE bigint USING skill_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'project_guardrails' - AND a.attname = 'created_at' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['timestamptz', 'timestamp with time zone']) THEN - ALTER TABLE public.project_guardrails - ALTER COLUMN created_at TYPE timestamptz USING created_at::timestamptz; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'project_guardrails' - AND a.attname = 'guardrail_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.project_guardrails - ALTER COLUMN guardrail_id TYPE bigint USING guardrail_id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'project_guardrails' - AND a.attname = 'id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.project_guardrails - ALTER COLUMN id TYPE bigint USING id::bigint; - END IF; -END; -$$; - -DO $$ -DECLARE - current_type text; -BEGIN - SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) - INTO current_type - FROM pg_attribute a - JOIN pg_class t ON t.oid = a.attrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - WHERE n.nspname = 'public' - AND t.relname = 'project_guardrails' - AND a.attname = 'project_id' - AND a.attnum > 0 - AND NOT a.attisdropped; - - IF current_type IS NOT NULL - AND current_type <> ALL(ARRAY['bigint']) THEN - ALTER TABLE public.project_guardrails - ALTER COLUMN project_id TYPE bigint USING project_id::bigint; - END IF; -END; -$$; - -- Primary keys for schema: public DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'agent_personas' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'agent_personas' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_personas' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('agent_personas_pkey', 'public_agent_personas_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('agent_personas_pkey', 'public_agent_personas_pkey') THEN - EXECUTE 'ALTER TABLE public.agent_personas DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.agent_personas DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('agent_personas_pkey', 'public_agent_personas_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_personas' + AND constraint_name = 'pk_public_agent_personas' + ) THEN ALTER TABLE public.agent_personas ADD CONSTRAINT pk_public_agent_personas PRIMARY KEY (id); END IF; END; @@ -7700,43 +3280,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'agent_parts' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'agent_parts' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_parts' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('agent_parts_pkey', 'public_agent_parts_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('agent_parts_pkey', 'public_agent_parts_pkey') THEN - EXECUTE 'ALTER TABLE public.agent_parts DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.agent_parts DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('agent_parts_pkey', 'public_agent_parts_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_parts' + AND constraint_name = 'pk_public_agent_parts' + ) THEN ALTER TABLE public.agent_parts ADD CONSTRAINT pk_public_agent_parts PRIMARY KEY (id); END IF; END; @@ -7744,43 +3308,111 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'agent_traits' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'agent_traits' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_persona_parts' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('agent_persona_parts_pkey', 'public_agent_persona_parts_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('agent_traits_pkey', 'public_agent_traits_pkey') THEN - EXECUTE 'ALTER TABLE public.agent_traits DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.agent_persona_parts DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('agent_traits_pkey', 'public_agent_traits_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_persona_parts' + AND constraint_name = 'pk_public_agent_persona_parts' + ) THEN + ALTER TABLE public.agent_persona_parts ADD CONSTRAINT pk_public_agent_persona_parts PRIMARY KEY (id); + END IF; +END; +$$; + +DO $$ +DECLARE + auto_pk_name text; +BEGIN + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_persona_skills' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('agent_persona_skills_pkey', 'public_agent_persona_skills_pkey'); + + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.agent_persona_skills DROP CONSTRAINT ' || quote_ident(auto_pk_name); + END IF; + + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_persona_skills' + AND constraint_name = 'pk_public_agent_persona_skills' + ) THEN + ALTER TABLE public.agent_persona_skills ADD CONSTRAINT pk_public_agent_persona_skills PRIMARY KEY (id); + END IF; +END; +$$; + +DO $$ +DECLARE + auto_pk_name text; +BEGIN + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_persona_guardrails' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('agent_persona_guardrails_pkey', 'public_agent_persona_guardrails_pkey'); + + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.agent_persona_guardrails DROP CONSTRAINT ' || quote_ident(auto_pk_name); + END IF; + + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_persona_guardrails' + AND constraint_name = 'pk_public_agent_persona_guardrails' + ) THEN + ALTER TABLE public.agent_persona_guardrails ADD CONSTRAINT pk_public_agent_persona_guardrails PRIMARY KEY (id); + END IF; +END; +$$; + +DO $$ +DECLARE + auto_pk_name text; +BEGIN + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_traits' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('agent_traits_pkey', 'public_agent_traits_pkey'); + + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.agent_traits DROP CONSTRAINT ' || quote_ident(auto_pk_name); + END IF; + + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_traits' + AND constraint_name = 'pk_public_agent_traits' + ) THEN ALTER TABLE public.agent_traits ADD CONSTRAINT pk_public_agent_traits PRIMARY KEY (id); END IF; END; @@ -7788,43 +3420,55 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'character_arcs' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'character_arcs' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_persona_traits' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('agent_persona_traits_pkey', 'public_agent_persona_traits_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('character_arcs_pkey', 'public_character_arcs_pkey') THEN - EXECUTE 'ALTER TABLE public.character_arcs DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.agent_persona_traits DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('character_arcs_pkey', 'public_character_arcs_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_persona_traits' + AND constraint_name = 'pk_public_agent_persona_traits' + ) THEN + ALTER TABLE public.agent_persona_traits ADD CONSTRAINT pk_public_agent_persona_traits PRIMARY KEY (id); + END IF; +END; +$$; + +DO $$ +DECLARE + auto_pk_name text; +BEGIN + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'character_arcs' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('character_arcs_pkey', 'public_character_arcs_pkey'); + + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.character_arcs DROP CONSTRAINT ' || quote_ident(auto_pk_name); + END IF; + + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'character_arcs' + AND constraint_name = 'pk_public_character_arcs' + ) THEN ALTER TABLE public.character_arcs ADD CONSTRAINT pk_public_character_arcs PRIMARY KEY (id); END IF; END; @@ -7832,43 +3476,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'arc_stages' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'arc_stages' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'arc_stages' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('arc_stages_pkey', 'public_arc_stages_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('arc_stages_pkey', 'public_arc_stages_pkey') THEN - EXECUTE 'ALTER TABLE public.arc_stages DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.arc_stages DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('arc_stages_pkey', 'public_arc_stages_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'arc_stages' + AND constraint_name = 'pk_public_arc_stages' + ) THEN ALTER TABLE public.arc_stages ADD CONSTRAINT pk_public_arc_stages PRIMARY KEY (id); END IF; END; @@ -7876,87 +3504,83 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'persona_arc' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['persona_id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'persona_arc' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'arc_stage_parts' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('arc_stage_parts_pkey', 'public_arc_stage_parts_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('persona_arc_pkey', 'public_persona_arc_pkey') THEN - EXECUTE 'ALTER TABLE public.persona_arc DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.arc_stage_parts DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('persona_arc_pkey', 'public_persona_arc_pkey')) THEN - ALTER TABLE public.persona_arc ADD CONSTRAINT pk_public_persona_arc PRIMARY KEY (persona_id); + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'arc_stage_parts' + AND constraint_name = 'pk_public_arc_stage_parts' + ) THEN + ALTER TABLE public.arc_stage_parts ADD CONSTRAINT pk_public_arc_stage_parts PRIMARY KEY (id); END IF; END; $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'thoughts' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'thoughts' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'persona_arc' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('persona_arc_pkey', 'public_persona_arc_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('thoughts_pkey', 'public_thoughts_pkey') THEN - EXECUTE 'ALTER TABLE public.thoughts DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.persona_arc DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('thoughts_pkey', 'public_thoughts_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'persona_arc' + AND constraint_name = 'pk_public_persona_arc' + ) THEN + ALTER TABLE public.persona_arc ADD CONSTRAINT pk_public_persona_arc PRIMARY KEY (id, persona_id); + END IF; +END; +$$; + +DO $$ +DECLARE + auto_pk_name text; +BEGIN + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'thoughts' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('thoughts_pkey', 'public_thoughts_pkey'); + + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.thoughts DROP CONSTRAINT ' || quote_ident(auto_pk_name); + END IF; + + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'thoughts' + AND constraint_name = 'pk_public_thoughts' + ) THEN ALTER TABLE public.thoughts ADD CONSTRAINT pk_public_thoughts PRIMARY KEY (id); END IF; END; @@ -7964,43 +3588,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'projects' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'projects' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'projects' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('projects_pkey', 'public_projects_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('projects_pkey', 'public_projects_pkey') THEN - EXECUTE 'ALTER TABLE public.projects DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.projects DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('projects_pkey', 'public_projects_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'projects' + AND constraint_name = 'pk_public_projects' + ) THEN ALTER TABLE public.projects ADD CONSTRAINT pk_public_projects PRIMARY KEY (id); END IF; END; @@ -8008,43 +3616,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'thought_links' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'thought_links' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'thought_links' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('thought_links_pkey', 'public_thought_links_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('thought_links_pkey', 'public_thought_links_pkey') THEN - EXECUTE 'ALTER TABLE public.thought_links DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.thought_links DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('thought_links_pkey', 'public_thought_links_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'thought_links' + AND constraint_name = 'pk_public_thought_links' + ) THEN ALTER TABLE public.thought_links ADD CONSTRAINT pk_public_thought_links PRIMARY KEY (id); END IF; END; @@ -8052,43 +3644,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'embeddings' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'embeddings' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'embeddings' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('embeddings_pkey', 'public_embeddings_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('embeddings_pkey', 'public_embeddings_pkey') THEN - EXECUTE 'ALTER TABLE public.embeddings DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.embeddings DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('embeddings_pkey', 'public_embeddings_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'embeddings' + AND constraint_name = 'pk_public_embeddings' + ) THEN ALTER TABLE public.embeddings ADD CONSTRAINT pk_public_embeddings PRIMARY KEY (id); END IF; END; @@ -8096,43 +3672,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'stored_files' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'stored_files' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'stored_files' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('stored_files_pkey', 'public_stored_files_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('stored_files_pkey', 'public_stored_files_pkey') THEN - EXECUTE 'ALTER TABLE public.stored_files DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.stored_files DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('stored_files_pkey', 'public_stored_files_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'stored_files' + AND constraint_name = 'pk_public_stored_files' + ) THEN ALTER TABLE public.stored_files ADD CONSTRAINT pk_public_stored_files PRIMARY KEY (id); END IF; END; @@ -8140,43 +3700,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'chat_histories' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'chat_histories' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'chat_histories' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('chat_histories_pkey', 'public_chat_histories_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('chat_histories_pkey', 'public_chat_histories_pkey') THEN - EXECUTE 'ALTER TABLE public.chat_histories DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.chat_histories DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('chat_histories_pkey', 'public_chat_histories_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'chat_histories' + AND constraint_name = 'pk_public_chat_histories' + ) THEN ALTER TABLE public.chat_histories ADD CONSTRAINT pk_public_chat_histories PRIMARY KEY (id); END IF; END; @@ -8184,43 +3728,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'tool_annotations' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'tool_annotations' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'tool_annotations' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('tool_annotations_pkey', 'public_tool_annotations_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('tool_annotations_pkey', 'public_tool_annotations_pkey') THEN - EXECUTE 'ALTER TABLE public.tool_annotations DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.tool_annotations DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('tool_annotations_pkey', 'public_tool_annotations_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'tool_annotations' + AND constraint_name = 'pk_public_tool_annotations' + ) THEN ALTER TABLE public.tool_annotations ADD CONSTRAINT pk_public_tool_annotations PRIMARY KEY (id); END IF; END; @@ -8228,43 +3756,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'learnings' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'learnings' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'learnings' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('learnings_pkey', 'public_learnings_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('learnings_pkey', 'public_learnings_pkey') THEN - EXECUTE 'ALTER TABLE public.learnings DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.learnings DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('learnings_pkey', 'public_learnings_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'learnings' + AND constraint_name = 'pk_public_learnings' + ) THEN ALTER TABLE public.learnings ADD CONSTRAINT pk_public_learnings PRIMARY KEY (id); END IF; END; @@ -8272,43 +3784,55 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'plans' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'plans' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'oauth_clients' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('oauth_clients_pkey', 'public_oauth_clients_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('plans_pkey', 'public_plans_pkey') THEN - EXECUTE 'ALTER TABLE public.plans DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.oauth_clients DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('plans_pkey', 'public_plans_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'oauth_clients' + AND constraint_name = 'pk_public_oauth_clients' + ) THEN + ALTER TABLE public.oauth_clients ADD CONSTRAINT pk_public_oauth_clients PRIMARY KEY (id); + END IF; +END; +$$; + +DO $$ +DECLARE + auto_pk_name text; +BEGIN + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'plans' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('plans_pkey', 'public_plans_pkey'); + + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.plans DROP CONSTRAINT ' || quote_ident(auto_pk_name); + END IF; + + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'plans' + AND constraint_name = 'pk_public_plans' + ) THEN ALTER TABLE public.plans ADD CONSTRAINT pk_public_plans PRIMARY KEY (id); END IF; END; @@ -8316,43 +3840,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'plan_dependencies' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'plan_dependencies' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'plan_dependencies' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('plan_dependencies_pkey', 'public_plan_dependencies_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('plan_dependencies_pkey', 'public_plan_dependencies_pkey') THEN - EXECUTE 'ALTER TABLE public.plan_dependencies DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.plan_dependencies DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('plan_dependencies_pkey', 'public_plan_dependencies_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'plan_dependencies' + AND constraint_name = 'pk_public_plan_dependencies' + ) THEN ALTER TABLE public.plan_dependencies ADD CONSTRAINT pk_public_plan_dependencies PRIMARY KEY (id); END IF; END; @@ -8360,43 +3868,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'plan_related_plans' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'plan_related_plans' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'plan_related_plans' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('plan_related_plans_pkey', 'public_plan_related_plans_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('plan_related_plans_pkey', 'public_plan_related_plans_pkey') THEN - EXECUTE 'ALTER TABLE public.plan_related_plans DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.plan_related_plans DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('plan_related_plans_pkey', 'public_plan_related_plans_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'plan_related_plans' + AND constraint_name = 'pk_public_plan_related_plans' + ) THEN ALTER TABLE public.plan_related_plans ADD CONSTRAINT pk_public_plan_related_plans PRIMARY KEY (id); END IF; END; @@ -8404,43 +3896,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'plan_skills' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'plan_skills' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'plan_skills' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('plan_skills_pkey', 'public_plan_skills_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('plan_skills_pkey', 'public_plan_skills_pkey') THEN - EXECUTE 'ALTER TABLE public.plan_skills DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.plan_skills DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('plan_skills_pkey', 'public_plan_skills_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'plan_skills' + AND constraint_name = 'pk_public_plan_skills' + ) THEN ALTER TABLE public.plan_skills ADD CONSTRAINT pk_public_plan_skills PRIMARY KEY (id); END IF; END; @@ -8448,43 +3924,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'plan_guardrails' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'plan_guardrails' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'plan_guardrails' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('plan_guardrails_pkey', 'public_plan_guardrails_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('plan_guardrails_pkey', 'public_plan_guardrails_pkey') THEN - EXECUTE 'ALTER TABLE public.plan_guardrails DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.plan_guardrails DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('plan_guardrails_pkey', 'public_plan_guardrails_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'plan_guardrails' + AND constraint_name = 'pk_public_plan_guardrails' + ) THEN ALTER TABLE public.plan_guardrails ADD CONSTRAINT pk_public_plan_guardrails PRIMARY KEY (id); END IF; END; @@ -8492,43 +3952,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'agent_skills' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'agent_skills' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_skills' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('agent_skills_pkey', 'public_agent_skills_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('agent_skills_pkey', 'public_agent_skills_pkey') THEN - EXECUTE 'ALTER TABLE public.agent_skills DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.agent_skills DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('agent_skills_pkey', 'public_agent_skills_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_skills' + AND constraint_name = 'pk_public_agent_skills' + ) THEN ALTER TABLE public.agent_skills ADD CONSTRAINT pk_public_agent_skills PRIMARY KEY (id); END IF; END; @@ -8536,43 +3980,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'agent_guardrails' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'agent_guardrails' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_guardrails' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('agent_guardrails_pkey', 'public_agent_guardrails_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('agent_guardrails_pkey', 'public_agent_guardrails_pkey') THEN - EXECUTE 'ALTER TABLE public.agent_guardrails DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.agent_guardrails DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('agent_guardrails_pkey', 'public_agent_guardrails_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'agent_guardrails' + AND constraint_name = 'pk_public_agent_guardrails' + ) THEN ALTER TABLE public.agent_guardrails ADD CONSTRAINT pk_public_agent_guardrails PRIMARY KEY (id); END IF; END; @@ -8580,43 +4008,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'project_skills' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'project_skills' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'project_skills' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('project_skills_pkey', 'public_project_skills_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('project_skills_pkey', 'public_project_skills_pkey') THEN - EXECUTE 'ALTER TABLE public.project_skills DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.project_skills DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('project_skills_pkey', 'public_project_skills_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'project_skills' + AND constraint_name = 'pk_public_project_skills' + ) THEN ALTER TABLE public.project_skills ADD CONSTRAINT pk_public_project_skills PRIMARY KEY (id); END IF; END; @@ -8624,43 +4036,27 @@ $$; DO $$ DECLARE - current_pk_name text; - current_pk_matches boolean := false; + auto_pk_name text; BEGIN - SELECT tc.constraint_name, - COALESCE( - ARRAY( - SELECT a.attname::text - FROM pg_constraint c - JOIN pg_class t ON t.oid = c.conrelid - JOIN pg_namespace n ON n.oid = t.relnamespace - JOIN unnest(c.conkey) WITH ORDINALITY AS cols(attnum, ord) - ON TRUE - JOIN pg_attribute a - ON a.attrelid = t.oid - AND a.attnum = cols.attnum - WHERE c.contype = 'p' - AND n.nspname = 'public' - AND t.relname = 'project_guardrails' - ORDER BY cols.ord - ), - ARRAY[]::text[] - ) = ARRAY['id'] - INTO current_pk_name, current_pk_matches - FROM information_schema.table_constraints tc - WHERE tc.table_schema = 'public' - AND tc.table_name = 'project_guardrails' - AND tc.constraint_type = 'PRIMARY KEY'; + -- Drop auto-generated primary key if it exists + SELECT constraint_name INTO auto_pk_name + FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'project_guardrails' + AND constraint_type = 'PRIMARY KEY' + AND constraint_name IN ('project_guardrails_pkey', 'public_project_guardrails_pkey'); - IF current_pk_name IS NOT NULL - AND NOT current_pk_matches - AND current_pk_name IN ('project_guardrails_pkey', 'public_project_guardrails_pkey') THEN - EXECUTE 'ALTER TABLE public.project_guardrails DROP CONSTRAINT ' || quote_ident(current_pk_name); + IF auto_pk_name IS NOT NULL THEN + EXECUTE 'ALTER TABLE public.project_guardrails DROP CONSTRAINT ' || quote_ident(auto_pk_name); END IF; - -- Add the desired primary key only when no matching primary key already exists. - IF current_pk_name IS NULL - OR (NOT current_pk_matches AND current_pk_name IN ('project_guardrails_pkey', 'public_project_guardrails_pkey')) THEN + -- Add named primary key if it doesn't exist + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'project_guardrails' + AND constraint_name = 'pk_public_project_guardrails' + ) THEN ALTER TABLE public.project_guardrails ADD CONSTRAINT pk_public_project_guardrails PRIMARY KEY (id); END IF; END; @@ -8673,12 +4069,6 @@ CREATE INDEX IF NOT EXISTS idx_agent_persona_parts_persona_id_part_id CREATE INDEX IF NOT EXISTS idx_agent_persona_skills_persona_id_skill_id ON public.agent_persona_skills USING btree (persona_id, skill_id); -CREATE INDEX IF NOT EXISTS idx_agent_persona_guardrails_persona_id_guardrail_id - ON public.agent_persona_guardrails USING btree (persona_id, guardrail_id); - -CREATE INDEX IF NOT EXISTS idx_agent_persona_traits_persona_id_trait_id - ON public.agent_persona_traits USING btree (persona_id, trait_id); - CREATE INDEX IF NOT EXISTS idx_arc_stage_parts_stage_id_part_id ON public.arc_stage_parts USING btree (stage_id, part_id); @@ -8695,10 +4085,10 @@ CREATE INDEX IF NOT EXISTS idx_learnings_summary ON public.learnings USING gin (summary gin_trgm_ops); CREATE INDEX IF NOT EXISTS idx_learnings_tags - ON public.learnings USING gin (tags array_ops); + ON public.learnings USING gin (tags gin_trgm_ops); CREATE INDEX IF NOT EXISTS idx_plans_tags - ON public.plans USING gin (tags array_ops); + ON public.plans USING gin (tags gin_trgm_ops); CREATE INDEX IF NOT EXISTS idx_plans_title ON public.plans USING gin (title gin_trgm_ops); @@ -8917,6 +4307,19 @@ BEGIN END; $$; +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT 1 FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'oauth_clients' + AND constraint_name = 'ukey_oauth_clients_client_id' + ) THEN + ALTER TABLE public.oauth_clients ADD CONSTRAINT ukey_oauth_clients_client_id UNIQUE (client_id); + END IF; +END; +$$; + DO $$ BEGIN IF NOT EXISTS ( @@ -9664,6 +5067,63 @@ BEGIN END; $$; DO $$ +DECLARE + m_cnt bigint; +BEGIN + IF EXISTS ( + SELECT 1 FROM pg_class c + INNER JOIN pg_namespace n ON n.oid = c.relnamespace + WHERE c.relname = 'identity_agent_persona_parts_id' + AND n.nspname = 'public' + AND c.relkind = 'S' + ) THEN + SELECT COALESCE(MAX(id), 0) + 1 + FROM public.agent_persona_parts + INTO m_cnt; + + PERFORM setval('public.identity_agent_persona_parts_id'::regclass, m_cnt); + END IF; +END; +$$; +DO $$ +DECLARE + m_cnt bigint; +BEGIN + IF EXISTS ( + SELECT 1 FROM pg_class c + INNER JOIN pg_namespace n ON n.oid = c.relnamespace + WHERE c.relname = 'identity_agent_persona_skills_id' + AND n.nspname = 'public' + AND c.relkind = 'S' + ) THEN + SELECT COALESCE(MAX(id), 0) + 1 + FROM public.agent_persona_skills + INTO m_cnt; + + PERFORM setval('public.identity_agent_persona_skills_id'::regclass, m_cnt); + END IF; +END; +$$; +DO $$ +DECLARE + m_cnt bigint; +BEGIN + IF EXISTS ( + SELECT 1 FROM pg_class c + INNER JOIN pg_namespace n ON n.oid = c.relnamespace + WHERE c.relname = 'identity_agent_persona_guardrails_id' + AND n.nspname = 'public' + AND c.relkind = 'S' + ) THEN + SELECT COALESCE(MAX(id), 0) + 1 + FROM public.agent_persona_guardrails + INTO m_cnt; + + PERFORM setval('public.identity_agent_persona_guardrails_id'::regclass, m_cnt); + END IF; +END; +$$; +DO $$ DECLARE m_cnt bigint; BEGIN @@ -9683,6 +5143,25 @@ BEGIN END; $$; DO $$ +DECLARE + m_cnt bigint; +BEGIN + IF EXISTS ( + SELECT 1 FROM pg_class c + INNER JOIN pg_namespace n ON n.oid = c.relnamespace + WHERE c.relname = 'identity_agent_persona_traits_id' + AND n.nspname = 'public' + AND c.relkind = 'S' + ) THEN + SELECT COALESCE(MAX(id), 0) + 1 + FROM public.agent_persona_traits + INTO m_cnt; + + PERFORM setval('public.identity_agent_persona_traits_id'::regclass, m_cnt); + END IF; +END; +$$; +DO $$ DECLARE m_cnt bigint; BEGIN @@ -9727,15 +5206,34 @@ BEGIN IF EXISTS ( SELECT 1 FROM pg_class c INNER JOIN pg_namespace n ON n.oid = c.relnamespace - WHERE c.relname = 'identity_persona_arc_persona_id' + WHERE c.relname = 'identity_arc_stage_parts_id' AND n.nspname = 'public' AND c.relkind = 'S' ) THEN - SELECT COALESCE(MAX(persona_id), 0) + 1 + SELECT COALESCE(MAX(id), 0) + 1 + FROM public.arc_stage_parts + INTO m_cnt; + + PERFORM setval('public.identity_arc_stage_parts_id'::regclass, m_cnt); + END IF; +END; +$$; +DO $$ +DECLARE + m_cnt bigint; +BEGIN + IF EXISTS ( + SELECT 1 FROM pg_class c + INNER JOIN pg_namespace n ON n.oid = c.relnamespace + WHERE c.relname = 'identity_persona_arc_id' + AND n.nspname = 'public' + AND c.relkind = 'S' + ) THEN + SELECT COALESCE(MAX(id), 0) + 1 FROM public.persona_arc INTO m_cnt; - PERFORM setval('public.identity_persona_arc_persona_id'::regclass, m_cnt); + PERFORM setval('public.identity_persona_arc_id'::regclass, m_cnt); END IF; END; $$; @@ -9892,6 +5390,25 @@ BEGIN END; $$; DO $$ +DECLARE + m_cnt bigint; +BEGIN + IF EXISTS ( + SELECT 1 FROM pg_class c + INNER JOIN pg_namespace n ON n.oid = c.relnamespace + WHERE c.relname = 'identity_oauth_clients_id' + AND n.nspname = 'public' + AND c.relkind = 'S' + ) THEN + SELECT COALESCE(MAX(id), 0) + 1 + FROM public.oauth_clients + INTO m_cnt; + + PERFORM setval('public.identity_oauth_clients_id'::regclass, m_cnt); + END IF; +END; +$$; +DO $$ DECLARE m_cnt bigint; BEGIN @@ -10089,5 +5606,6 @@ $$; + diff --git a/schema/agent_personas.dbml b/schema/agent_personas.dbml index c433591..b6877ba 100644 --- a/schema/agent_personas.dbml +++ b/schema/agent_personas.dbml @@ -27,33 +27,35 @@ Table agent_parts { } Table agent_persona_parts { + id bigserial [pk] persona_id bigint [not null, ref: > agent_personas.id] part_id bigint [not null, ref: > agent_parts.id] part_order int [not null, default: 0] priority int [not null, default: 0] indexes { - (persona_id, part_id) [pk] + (persona_id, part_id) [uk] persona_id } } Table agent_persona_skills { + id bigserial [pk] persona_id bigint [not null, ref: > agent_personas.id] skill_id bigint [not null, ref: > agent_skills.id] indexes { - (persona_id, skill_id) [pk] + (persona_id, skill_id) [uk] persona_id } } Table agent_persona_guardrails { + id bigserial [pk] persona_id bigint [not null, ref: > agent_personas.id] guardrail_id bigint [not null, ref: > agent_guardrails.id] indexes { - (persona_id, guardrail_id) [pk] persona_id } } @@ -71,11 +73,11 @@ Table agent_traits { } Table agent_persona_traits { + id bigserial [pk] persona_id bigint [not null, ref: > agent_personas.id] trait_id bigint [not null, ref: > agent_traits.id] indexes { - (persona_id, trait_id) [pk] persona_id } } @@ -100,15 +102,17 @@ Table arc_stages { } Table arc_stage_parts { + id bigserial [pk] stage_id bigint [not null, ref: > arc_stages.id] part_id bigint [not null, ref: > agent_parts.id] indexes { - (stage_id, part_id) [pk] + (stage_id, part_id) } } Table persona_arc { + id bigserial [pk] persona_id bigint [pk, ref: > agent_personas.id] arc_id bigint [not null, ref: > character_arcs.id] current_stage_id bigint [not null, ref: > arc_stages.id] diff --git a/schema/oauth_clients.dbml b/schema/oauth_clients.dbml new file mode 100644 index 0000000..37ed7a7 --- /dev/null +++ b/schema/oauth_clients.dbml @@ -0,0 +1,8 @@ +// OAuth 2.0 Dynamic Client Registration (RFC 7591) +Table oauth_clients { + id bigserial [pk] + client_id text [unique, not null] + client_name text [not null, default: ''] + redirect_uris "text[]" [not null, default: `'{}'`] + created_at timestamptz [not null, default: `now()`] +}