You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
senzapaura_es/drizzle/0027_yielding_sentry.sql

21 lines
1.0 KiB

CREATE SEQUENCE "public"."artista_virtual_codigo_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1;--> statement-breakpoint
ALTER TABLE "artista" DROP CONSTRAINT "artista_tipo_conocido";--> statement-breakpoint
ALTER TABLE "artista" ADD COLUMN "secciones" jsonb DEFAULT '[]'::jsonb NOT NULL;--> statement-breakpoint
UPDATE "artista"
SET "secciones" = jsonb_build_array(
jsonb_build_object(
'id', 'biografia-principal',
'tipo', 'texto',
'texto', "biografia"
)
)
WHERE btrim("biografia") <> '';--> statement-breakpoint
SELECT setval(
'artista_virtual_codigo_seq',
coalesce(max(substring("codigo" from '^AV-([0-9]+)$')::bigint), 1),
count(*) FILTER (WHERE "codigo" ~ '^AV-[0-9]+$') > 0
)
FROM "artista";--> statement-breakpoint
ALTER TABLE "artista" ADD CONSTRAINT "artista_secciones_array" CHECK (jsonb_typeof("artista"."secciones") = 'array');--> statement-breakpoint
ALTER TABLE "artista" ADD CONSTRAINT "artista_tipo_conocido" CHECK ("artista"."tipo" in ('persona', 'grupo', 'proyecto', 'virtual'));

Powered by TurnKey Linux.