GeneIT/geneit_backend/migrations/2024-05-23-163128_accommodation_module/up.sql
Pierre HUBERT 2f1df6c117
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Can toggle accommodations module
2024-05-23 19:28:29 +02:00

31 lines
1.1 KiB
SQL

-- Add column to toggle accommodations module
ALTER TABLE public.families
ADD enable_accommodations boolean NOT NULL DEFAULT false;
COMMENT
ON COLUMN public.families.enable_accommodations IS 'Specify whether accommodations feature is enabled for the family';
-- Create tables
CREATE TABLE IF NOT EXISTS accommodations_list
(
id SERIAL PRIMARY KEY,
family_id integer NOT NULL REFERENCES families,
time_create BIGINT NOT NULL,
time_update BIGINT NOT NULL,
need_validation BOOLEAN,
description text NULL,
open_to_reservation BOOLEAN
);
CREATE TABLE IF NOT EXISTS accommodations_reservations
(
id SERIAL PRIMARY KEY,
family_id integer NOT NULL REFERENCES families ON DELETE CASCADE,
accommodation_id integer NOT NULL REFERENCES accommodations_list ON DELETE CASCADE,
user_id INTEGER NOT NULL REFERENCES users ON DELETE CASCADE,
time_create BIGINT NOT NULL,
time_update BIGINT NOT NULL,
reservation_start BIGINT NOT NULL,
reservation_end BIGINT NOT NULL,
validated BOOLEAN
);