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
|
|
|
-- Servizio Annunci
|
|
|
|
|
CREATE TABLE IF NOT EXISTS public.servizio_annunci (
|
|
|
|
|
servizio_id UUID NOT NULL,
|
|
|
|
|
annunci_id integer NOT NULL,
|
|
|
|
|
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT now() NOT NULL,
|
|
|
|
|
open_contatti_at TIMESTAMP WITHOUT TIME ZONE,
|
|
|
|
|
doc_conferma_ref TEXT,
|
|
|
|
|
user_confirmed_at TIMESTAMP WITHOUT TIME ZONE,
|
|
|
|
|
accettato_conferma_at TIMESTAMP WITHOUT TIME ZONE,
|
|
|
|
|
caparra_causale TEXT,
|
|
|
|
|
caparra_iban TEXT,
|
|
|
|
|
caparra_importo TEXT,
|
|
|
|
|
caparra_intestazione TEXT,
|
|
|
|
|
"hasConfermaAdmin" boolean DEFAULT FALSE NOT NULL,
|
|
|
|
|
doc_contratto_ref TEXT,
|
|
|
|
|
gestionale_id integer,
|
|
|
|
|
contratto_decorrenza date,
|
|
|
|
|
contratto_scadenza date,
|
|
|
|
|
contratto_tipo TEXT,
|
|
|
|
|
doc_registrazione_ref TEXT,
|
|
|
|
|
doc_conferma_added boolean DEFAULT FALSE NOT NULL,
|
|
|
|
|
doc_contratto_added boolean DEFAULT FALSE NOT NULL,
|
|
|
|
|
doc_registrazione_added boolean DEFAULT FALSE NOT NULL
|
|
|
|
|
);
|
2025-11-14 18:23:38 +01:00
|
|
|
|
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
|
|
|
-- Unique Constraint
|
2025-11-14 18:23:38 +01:00
|
|
|
DO $$ BEGIN
|
|
|
|
|
IF NOT EXISTS (
|
|
|
|
|
SELECT 1 FROM pg_constraint
|
|
|
|
|
WHERE conname = 'uniq_annuncio_servizio'
|
|
|
|
|
AND conrelid = 'public.servizio_annunci'::regclass
|
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
|
|
|
) THEN
|
2025-11-14 18:23:38 +01:00
|
|
|
ALTER TABLE public.servizio_annunci
|
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
|
|
|
ADD CONSTRAINT uniq_annuncio_servizio UNIQUE (annunci_id, servizio_id);
|
|
|
|
|
END IF;
|
|
|
|
|
END $$;
|
2025-11-14 18:23:38 +01:00
|
|
|
|
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
|
|
|
-- Foreign Key to Annunci
|
2025-11-14 18:23:38 +01:00
|
|
|
DO $$ BEGIN
|
|
|
|
|
IF NOT EXISTS (
|
|
|
|
|
SELECT 1 FROM pg_constraint
|
|
|
|
|
WHERE conname = 'servizio_annuncio_j_annuncio' -- LOWERCASE
|
|
|
|
|
AND conrelid = 'public.servizio_annunci'::regclass
|
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
|
|
|
) THEN
|
2025-11-14 18:23:38 +01:00
|
|
|
ALTER TABLE public.servizio_annunci
|
|
|
|
|
ADD CONSTRAINT servizio_annuncio_j_annuncio -- LOWERCASE
|
|
|
|
|
FOREIGN KEY (annunci_id) REFERENCES public.annunci (id)
|
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
|
|
|
ON UPDATE CASCADE ON DELETE CASCADE;
|
|
|
|
|
END IF;
|
|
|
|
|
END $$;
|
2025-11-14 18:23:38 +01:00
|
|
|
|
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
|
|
|
-- Foreign Key to Servizio
|
2025-11-14 18:23:38 +01:00
|
|
|
DO $$ BEGIN
|
|
|
|
|
IF NOT EXISTS (
|
|
|
|
|
SELECT 1 FROM pg_constraint
|
|
|
|
|
WHERE conname = 'servizio_annuncio_j_servizio' -- LOWERCASE
|
|
|
|
|
AND conrelid = 'public.servizio_annunci'::regclass
|
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
|
|
|
) THEN
|
2025-11-14 18:23:38 +01:00
|
|
|
ALTER TABLE public.servizio_annunci
|
|
|
|
|
ADD CONSTRAINT servizio_annuncio_j_servizio -- LOWERCASE
|
|
|
|
|
FOREIGN KEY (servizio_id) REFERENCES public.servizio (servizio_id)
|
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
|
|
|
ON UPDATE CASCADE ON DELETE CASCADE;
|
|
|
|
|
END IF;
|
|
|
|
|
END $$;
|