infoalloggi-monorepo/apps/db/migrations/15_prezziario.up.sql
Marco Pedone 3d70810937 feat(migrations): Add multiple database migrations for new tables and data seeding
- 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.
2025-10-30 19:14:31 +01:00

25 lines
No EOL
847 B
SQL

-- Prezziario
CREATE TABLE IF NOT EXISTS public.prezziario (
idprezziario TEXT NOT NULL,
prezzo_cent integer NOT NULL,
testo_condizioni TEXT,
"isActive" boolean DEFAULT TRUE NOT NULL,
nome_it TEXT NOT NULL,
nome_en TEXT NOT NULL,
desc_it TEXT NOT NULL,
desc_en TEXT NOT NULL,
sconto integer DEFAULT 0 NOT NULL,
"isAcconto" boolean DEFAULT FALSE NOT NULL,
"isSaldo" boolean DEFAULT FALSE NOT NULL,
"isConsulenza" boolean DEFAULT FALSE NOT NULL,
"isStabile" boolean DEFAULT FALSE NOT NULL,
"isTransitorio" boolean DEFAULT FALSE NOT NULL
);
-- Primary Key
DO $$ BEGIN
ALTER TABLE public.prezziario
ADD CONSTRAINT prezziario_pkey PRIMARY KEY (idprezziario);
EXCEPTION
WHEN invalid_table_definition THEN
RAISE NOTICE 'Primary key already exists. Ignoring...';
END $$;