- Created migration scripts for new tables including banlist, banners, event_queue, flags, testi_e_stringhe, and ratelimiter. - Added data seeding for banners, etichette, flags, prezziario, and testi_e_stringhe with idempotent inserts. - Initialized database with necessary extensions and user tables. - Updated servizio table to include new columns for managing service states. - Established foreign key relationships and unique constraints across various tables. - Implemented sequences for auto-incrementing primary keys in several tables.
29 lines
No EOL
786 B
SQL
29 lines
No EOL
786 B
SQL
-- Image Refs
|
|
CREATE TABLE IF NOT EXISTS public.images_refs (
|
|
codice TEXT NOT NULL,
|
|
ordine integer NOT NULL,
|
|
img TEXT NOT NULL,
|
|
thumb TEXT NOT NULL,
|
|
og_url TEXT NOT NULL
|
|
);
|
|
-- Unique Codice and Ordine
|
|
DO $$ BEGIN IF NOT EXISTS (
|
|
SELECT 1
|
|
FROM pg_constraint
|
|
WHERE conname = 'img_cod_order'
|
|
) THEN
|
|
ALTER TABLE public.images_refs
|
|
ADD CONSTRAINT img_cod_order UNIQUE (codice, ordine);
|
|
END IF;
|
|
END $$;
|
|
-- Foreign Key to Annunci
|
|
DO $$ BEGIN IF NOT EXISTS (
|
|
SELECT 1 FROM pg_constraint
|
|
WHERE conname = 'cod_image'
|
|
) THEN
|
|
ALTER TABLE public.images_refs
|
|
ADD CONSTRAINT cod_image
|
|
FOREIGN KEY (codice) REFERENCES public.annunci (codice)
|
|
ON UPDATE CASCADE ON DELETE CASCADE;
|
|
END IF;
|
|
END $$; |