infoalloggi-monorepo/apps/db/migrations/014_prezziario.up.sql
Marco Pedone 66ef4a7fbd feat(database): Add migrations for chat labels, messages, services, interests, announcements, pricing, orders, payments, and miscellaneous data
- Created tables for `chats_etichette`, `messages`, `servizio`, `servizio_interessi`, `servizio_annunci`, `prezziario`, `ordini`, `payments`, and `banlist`.
- Established primary and foreign key constraints for data integrity.
- Introduced enums for various types including `TipologiaPosizioneEnum`, `OrderTypeEnum`, and `PaymentStatusEnum`.
- Seeded initial data for banners, labels, flags, pricing, strings, and users.
- Implemented unique constraints where necessary to prevent duplicate entries.
2025-10-29 16:59:20 +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 $$;