From d19772f6d5fad0c86325eaeabe1613cec4b9046f Mon Sep 17 00:00:00 2001 From: volodymyrrozdolsky Date: Sun, 3 Dec 2023 00:05:57 -0500 Subject: [PATCH] adding migration scrips --- .gitignore | 3 +- ...20231203000801_create_user_table.down.fizz | 1 + .../20231203000801_create_user_table.up.fizz | 8 + ...3004218_create_reservation_table.down.fizz | 1 + ...203004218_create_reservation_table.up.fizz | 10 + ...0231203025147_create_rooms_table.down.fizz | 1 + .../20231203025147_create_rooms_table.up.fizz | 4 + ...025611_create_restrictions_table.down.fizz | 1 + ...03025611_create_restrictions_table.up.fizz | 4 + ...5_create_room_restrictions_table.down.fizz | 1 + ...315_create_room_restrictions_table.up.fizz | 8 + ..._create_fkfor_reservations_table.down.fizz | 1 + ...28_create_fkfor_reservations_table.up.fizz | 4 + ...9_create_fkfor_room_restrictions.down.fizz | 2 + ...639_create_fkfor_room_restrictions.up.fizz | 9 + ...ate_unique_index_for_users_table.down.fizz | 1 + ...reate_unique_index_for_users_table.up.fizz | 1 + ...ate_indices_on_room_restrictions.down.fizz | 3 + ...reate_indices_on_room_restrictions.up.fizz | 3 + ...and_indices_to_reservation_table.down.fizz | 5 + ...fkand_indices_to_reservation_table.up.fizz | 7 + migrations/schema.sql | 395 ++++++++++++++++++ 22 files changed, 471 insertions(+), 2 deletions(-) create mode 100644 migrations/20231203000801_create_user_table.down.fizz create mode 100644 migrations/20231203000801_create_user_table.up.fizz create mode 100644 migrations/20231203004218_create_reservation_table.down.fizz create mode 100644 migrations/20231203004218_create_reservation_table.up.fizz create mode 100644 migrations/20231203025147_create_rooms_table.down.fizz create mode 100644 migrations/20231203025147_create_rooms_table.up.fizz create mode 100644 migrations/20231203025611_create_restrictions_table.down.fizz create mode 100644 migrations/20231203025611_create_restrictions_table.up.fizz create mode 100644 migrations/20231203031315_create_room_restrictions_table.down.fizz create mode 100644 migrations/20231203031315_create_room_restrictions_table.up.fizz create mode 100644 migrations/20231203031628_create_fkfor_reservations_table.down.fizz create mode 100644 migrations/20231203031628_create_fkfor_reservations_table.up.fizz create mode 100644 migrations/20231203032639_create_fkfor_room_restrictions.down.fizz create mode 100644 migrations/20231203032639_create_fkfor_room_restrictions.up.fizz create mode 100644 migrations/20231203034514_create_unique_index_for_users_table.down.fizz create mode 100644 migrations/20231203034514_create_unique_index_for_users_table.up.fizz create mode 100644 migrations/20231203034814_create_indices_on_room_restrictions.down.fizz create mode 100644 migrations/20231203034814_create_indices_on_room_restrictions.up.fizz create mode 100644 migrations/20231203035521_add_fkand_indices_to_reservation_table.down.fizz create mode 100644 migrations/20231203035521_add_fkand_indices_to_reservation_table.up.fizz create mode 100644 migrations/schema.sql diff --git a/.gitignore b/.gitignore index 091a7bb..28bd472 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ main web .idea booking-app -database.yml -migrations \ No newline at end of file +database.yml \ No newline at end of file diff --git a/migrations/20231203000801_create_user_table.down.fizz b/migrations/20231203000801_create_user_table.down.fizz new file mode 100644 index 0000000..15124c5 --- /dev/null +++ b/migrations/20231203000801_create_user_table.down.fizz @@ -0,0 +1 @@ +sql("drop table users") \ No newline at end of file diff --git a/migrations/20231203000801_create_user_table.up.fizz b/migrations/20231203000801_create_user_table.up.fizz new file mode 100644 index 0000000..5fb02cb --- /dev/null +++ b/migrations/20231203000801_create_user_table.up.fizz @@ -0,0 +1,8 @@ +create_table("users") { + t.Column("id", "integer", {primary: true}) + t.Column("first_name", "string", {"default": ""}) + t.Column("last_name", "string", {"default": ""}) + t.Column("email", "string", {"default": ""}) + t.Column("password", "string", {"size": 60}) + t.Column("access_level", "integer", {"default": 1}) +} \ No newline at end of file diff --git a/migrations/20231203004218_create_reservation_table.down.fizz b/migrations/20231203004218_create_reservation_table.down.fizz new file mode 100644 index 0000000..e1a677a --- /dev/null +++ b/migrations/20231203004218_create_reservation_table.down.fizz @@ -0,0 +1 @@ +drop_table("reservations"); diff --git a/migrations/20231203004218_create_reservation_table.up.fizz b/migrations/20231203004218_create_reservation_table.up.fizz new file mode 100644 index 0000000..215aa70 --- /dev/null +++ b/migrations/20231203004218_create_reservation_table.up.fizz @@ -0,0 +1,10 @@ +create_table("reservations") { + t.Column("id", "integer", {primary: true}) + t.Column("first_name", "string", {"default": ""}) + t.Column("last_name", "string", {"default": ""}) + t.Column("email", "string", {}) + t.Column("phone", "string", {"default": ""}) + t.Column("start_date", "date", {}) + t.Column("end_date", "date", {}) + t.Column("room_id", "integer", {}) +} \ No newline at end of file diff --git a/migrations/20231203025147_create_rooms_table.down.fizz b/migrations/20231203025147_create_rooms_table.down.fizz new file mode 100644 index 0000000..1d064f1 --- /dev/null +++ b/migrations/20231203025147_create_rooms_table.down.fizz @@ -0,0 +1 @@ +drop_table("rooms"); \ No newline at end of file diff --git a/migrations/20231203025147_create_rooms_table.up.fizz b/migrations/20231203025147_create_rooms_table.up.fizz new file mode 100644 index 0000000..4cc428a --- /dev/null +++ b/migrations/20231203025147_create_rooms_table.up.fizz @@ -0,0 +1,4 @@ +create_table("rooms") { + t.Column("id", "integer", {primary: true}) + t.Column("room_name", "string", {"default": ""}) +} \ No newline at end of file diff --git a/migrations/20231203025611_create_restrictions_table.down.fizz b/migrations/20231203025611_create_restrictions_table.down.fizz new file mode 100644 index 0000000..e801748 --- /dev/null +++ b/migrations/20231203025611_create_restrictions_table.down.fizz @@ -0,0 +1 @@ +drop_table("restrictions"); \ No newline at end of file diff --git a/migrations/20231203025611_create_restrictions_table.up.fizz b/migrations/20231203025611_create_restrictions_table.up.fizz new file mode 100644 index 0000000..e819d88 --- /dev/null +++ b/migrations/20231203025611_create_restrictions_table.up.fizz @@ -0,0 +1,4 @@ +create_table("restrictions") { + t.Column("id", "integer", {primary: true}) + t.Column("room_name", "string", {"default": ""}) +} \ No newline at end of file diff --git a/migrations/20231203031315_create_room_restrictions_table.down.fizz b/migrations/20231203031315_create_room_restrictions_table.down.fizz new file mode 100644 index 0000000..6317488 --- /dev/null +++ b/migrations/20231203031315_create_room_restrictions_table.down.fizz @@ -0,0 +1 @@ +drop_table("room_restrictions"); \ No newline at end of file diff --git a/migrations/20231203031315_create_room_restrictions_table.up.fizz b/migrations/20231203031315_create_room_restrictions_table.up.fizz new file mode 100644 index 0000000..00ee513 --- /dev/null +++ b/migrations/20231203031315_create_room_restrictions_table.up.fizz @@ -0,0 +1,8 @@ +create_table("room_restrictions") { + t.Column("id", "integer", {primary: true}) + t.Column("start_date", "date", {}) + t.Column("end_date", "date", {}) + t.Column("room_id", "integer", {}) + t.Column("reservation_id", "integer", {}) + t.Column("restriction_id", "integer", {}) +} \ No newline at end of file diff --git a/migrations/20231203031628_create_fkfor_reservations_table.down.fizz b/migrations/20231203031628_create_fkfor_reservations_table.down.fizz new file mode 100644 index 0000000..e017519 --- /dev/null +++ b/migrations/20231203031628_create_fkfor_reservations_table.down.fizz @@ -0,0 +1 @@ +drop_foreign_key("reservations", "reservations_rooms_id_fk", {}) \ No newline at end of file diff --git a/migrations/20231203031628_create_fkfor_reservations_table.up.fizz b/migrations/20231203031628_create_fkfor_reservations_table.up.fizz new file mode 100644 index 0000000..db2a72d --- /dev/null +++ b/migrations/20231203031628_create_fkfor_reservations_table.up.fizz @@ -0,0 +1,4 @@ +add_foreign_key("reservations", "room_id", {"rooms": ["id"]}, { + "on_delete": "cascade", + "on_update": "cascade", +}) diff --git a/migrations/20231203032639_create_fkfor_room_restrictions.down.fizz b/migrations/20231203032639_create_fkfor_room_restrictions.down.fizz new file mode 100644 index 0000000..93f9e93 --- /dev/null +++ b/migrations/20231203032639_create_fkfor_room_restrictions.down.fizz @@ -0,0 +1,2 @@ +drop_foreign_key("room_restrictions", "room_restrictions_restrictions_id_fk", {}) +drop_foreign_key("room_restrictions", "room_restrictions_rooms_id_fk", {}) \ No newline at end of file diff --git a/migrations/20231203032639_create_fkfor_room_restrictions.up.fizz b/migrations/20231203032639_create_fkfor_room_restrictions.up.fizz new file mode 100644 index 0000000..6580cee --- /dev/null +++ b/migrations/20231203032639_create_fkfor_room_restrictions.up.fizz @@ -0,0 +1,9 @@ +add_foreign_key("room_restrictions", "room_id", {"rooms": ["id"]}, { + "on_delete": "cascade", + "on_update": "cascade", +}) + +add_foreign_key("room_restrictions", "restriction_id", {"restrictions": ["id"]}, { + "on_delete": "cascade", + "on_update": "cascade", +}) diff --git a/migrations/20231203034514_create_unique_index_for_users_table.down.fizz b/migrations/20231203034514_create_unique_index_for_users_table.down.fizz new file mode 100644 index 0000000..189db56 --- /dev/null +++ b/migrations/20231203034514_create_unique_index_for_users_table.down.fizz @@ -0,0 +1 @@ +drop_index("users", "users_email_idx") \ No newline at end of file diff --git a/migrations/20231203034514_create_unique_index_for_users_table.up.fizz b/migrations/20231203034514_create_unique_index_for_users_table.up.fizz new file mode 100644 index 0000000..0429385 --- /dev/null +++ b/migrations/20231203034514_create_unique_index_for_users_table.up.fizz @@ -0,0 +1 @@ +add_index("users", "email", {"unique": true}) \ No newline at end of file diff --git a/migrations/20231203034814_create_indices_on_room_restrictions.down.fizz b/migrations/20231203034814_create_indices_on_room_restrictions.down.fizz new file mode 100644 index 0000000..de13826 --- /dev/null +++ b/migrations/20231203034814_create_indices_on_room_restrictions.down.fizz @@ -0,0 +1,3 @@ +drop_index("room_restrictions", "room_restrictions_reservation_id_idx") +drop_index("room_restrictions", "room_restrictions_room_id_idx") +drop_index("room_restrictions", "room_restrictions_start_date_end_date_idx") \ No newline at end of file diff --git a/migrations/20231203034814_create_indices_on_room_restrictions.up.fizz b/migrations/20231203034814_create_indices_on_room_restrictions.up.fizz new file mode 100644 index 0000000..7f88b0b --- /dev/null +++ b/migrations/20231203034814_create_indices_on_room_restrictions.up.fizz @@ -0,0 +1,3 @@ +add_index("room_restrictions", ["start_date", "end_date"], {}) +add_index("room_restrictions", ["room_id"], {}) +add_index("room_restrictions", ["reservation_id"], {}) \ No newline at end of file diff --git a/migrations/20231203035521_add_fkand_indices_to_reservation_table.down.fizz b/migrations/20231203035521_add_fkand_indices_to_reservation_table.down.fizz new file mode 100644 index 0000000..62dfc42 --- /dev/null +++ b/migrations/20231203035521_add_fkand_indices_to_reservation_table.down.fizz @@ -0,0 +1,5 @@ +drop_foreign_key("room_restrictions", "room_restrictions_restrictions_id_fk", {}) + +drop_index("reservation", "reservations_email_idx") +drop_index("reservation", "reservations_last_name_idx") + diff --git a/migrations/20231203035521_add_fkand_indices_to_reservation_table.up.fizz b/migrations/20231203035521_add_fkand_indices_to_reservation_table.up.fizz new file mode 100644 index 0000000..4ae52e8 --- /dev/null +++ b/migrations/20231203035521_add_fkand_indices_to_reservation_table.up.fizz @@ -0,0 +1,7 @@ +add_foreign_key("room_restrictions", "reservation_id", {"reservations": ["id"]}, { + "on_delete": "cascade", + "on_update": "cascade", +}) + +add_index("reservations", "email", {}) +add_index("reservations", "last_name", {}) \ No newline at end of file diff --git a/migrations/schema.sql b/migrations/schema.sql new file mode 100644 index 0000000..0e3336b --- /dev/null +++ b/migrations/schema.sql @@ -0,0 +1,395 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 14.10 (Homebrew) +-- Dumped by pg_dump version 14.10 (Homebrew) + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: reservations; Type: TABLE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE TABLE public.reservations ( + id integer NOT NULL, + first_name character varying(255) DEFAULT ''::character varying NOT NULL, + last_name character varying(255) DEFAULT ''::character varying NOT NULL, + email character varying(255) NOT NULL, + phone character varying(255) DEFAULT ''::character varying NOT NULL, + start_date date NOT NULL, + end_date date NOT NULL, + room_id integer NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +ALTER TABLE public.reservations OWNER TO volodymyrrozdolsky; + +-- +-- Name: reservations_id_seq; Type: SEQUENCE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE SEQUENCE public.reservations_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.reservations_id_seq OWNER TO volodymyrrozdolsky; + +-- +-- Name: reservations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER SEQUENCE public.reservations_id_seq OWNED BY public.reservations.id; + + +-- +-- Name: restrictions; Type: TABLE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE TABLE public.restrictions ( + id integer NOT NULL, + room_name character varying(255) DEFAULT ''::character varying NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +ALTER TABLE public.restrictions OWNER TO volodymyrrozdolsky; + +-- +-- Name: restrictions_id_seq; Type: SEQUENCE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE SEQUENCE public.restrictions_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.restrictions_id_seq OWNER TO volodymyrrozdolsky; + +-- +-- Name: restrictions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER SEQUENCE public.restrictions_id_seq OWNED BY public.restrictions.id; + + +-- +-- Name: room_restrictions; Type: TABLE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE TABLE public.room_restrictions ( + id integer NOT NULL, + start_date date NOT NULL, + end_date date NOT NULL, + room_id integer NOT NULL, + reservation_id integer NOT NULL, + restriction_id integer NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +ALTER TABLE public.room_restrictions OWNER TO volodymyrrozdolsky; + +-- +-- Name: room_restrictions_id_seq; Type: SEQUENCE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE SEQUENCE public.room_restrictions_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.room_restrictions_id_seq OWNER TO volodymyrrozdolsky; + +-- +-- Name: room_restrictions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER SEQUENCE public.room_restrictions_id_seq OWNED BY public.room_restrictions.id; + + +-- +-- Name: rooms; Type: TABLE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE TABLE public.rooms ( + id integer NOT NULL, + room_name character varying(255) DEFAULT ''::character varying NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +ALTER TABLE public.rooms OWNER TO volodymyrrozdolsky; + +-- +-- Name: rooms_id_seq; Type: SEQUENCE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE SEQUENCE public.rooms_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.rooms_id_seq OWNER TO volodymyrrozdolsky; + +-- +-- Name: rooms_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER SEQUENCE public.rooms_id_seq OWNED BY public.rooms.id; + + +-- +-- Name: schema_migration; Type: TABLE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE TABLE public.schema_migration ( + version character varying(14) NOT NULL +); + + +ALTER TABLE public.schema_migration OWNER TO volodymyrrozdolsky; + +-- +-- Name: users; Type: TABLE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE TABLE public.users ( + id integer NOT NULL, + first_name character varying(255) DEFAULT ''::character varying NOT NULL, + last_name character varying(255) DEFAULT ''::character varying NOT NULL, + email character varying(255) DEFAULT ''::character varying NOT NULL, + password character varying(60) NOT NULL, + access_level integer DEFAULT 1 NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +ALTER TABLE public.users OWNER TO volodymyrrozdolsky; + +-- +-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE SEQUENCE public.users_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.users_id_seq OWNER TO volodymyrrozdolsky; + +-- +-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; + + +-- +-- Name: reservations id; Type: DEFAULT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.reservations ALTER COLUMN id SET DEFAULT nextval('public.reservations_id_seq'::regclass); + + +-- +-- Name: restrictions id; Type: DEFAULT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.restrictions ALTER COLUMN id SET DEFAULT nextval('public.restrictions_id_seq'::regclass); + + +-- +-- Name: room_restrictions id; Type: DEFAULT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.room_restrictions ALTER COLUMN id SET DEFAULT nextval('public.room_restrictions_id_seq'::regclass); + + +-- +-- Name: rooms id; Type: DEFAULT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.rooms ALTER COLUMN id SET DEFAULT nextval('public.rooms_id_seq'::regclass); + + +-- +-- Name: users id; Type: DEFAULT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); + + +-- +-- Name: reservations reservations_pkey; Type: CONSTRAINT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.reservations + ADD CONSTRAINT reservations_pkey PRIMARY KEY (id); + + +-- +-- Name: restrictions restrictions_pkey; Type: CONSTRAINT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.restrictions + ADD CONSTRAINT restrictions_pkey PRIMARY KEY (id); + + +-- +-- Name: room_restrictions room_restrictions_pkey; Type: CONSTRAINT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.room_restrictions + ADD CONSTRAINT room_restrictions_pkey PRIMARY KEY (id); + + +-- +-- Name: rooms rooms_pkey; Type: CONSTRAINT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.rooms + ADD CONSTRAINT rooms_pkey PRIMARY KEY (id); + + +-- +-- Name: schema_migration schema_migration_pkey; Type: CONSTRAINT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.schema_migration + ADD CONSTRAINT schema_migration_pkey PRIMARY KEY (version); + + +-- +-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_pkey PRIMARY KEY (id); + + +-- +-- Name: reservations_email_idx; Type: INDEX; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE INDEX reservations_email_idx ON public.reservations USING btree (email); + + +-- +-- Name: reservations_last_name_idx; Type: INDEX; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE INDEX reservations_last_name_idx ON public.reservations USING btree (last_name); + + +-- +-- Name: room_restrictions_reservation_id_idx; Type: INDEX; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE INDEX room_restrictions_reservation_id_idx ON public.room_restrictions USING btree (reservation_id); + + +-- +-- Name: room_restrictions_room_id_idx; Type: INDEX; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE INDEX room_restrictions_room_id_idx ON public.room_restrictions USING btree (room_id); + + +-- +-- Name: room_restrictions_start_date_end_date_idx; Type: INDEX; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE INDEX room_restrictions_start_date_end_date_idx ON public.room_restrictions USING btree (start_date, end_date); + + +-- +-- Name: schema_migration_version_idx; Type: INDEX; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE UNIQUE INDEX schema_migration_version_idx ON public.schema_migration USING btree (version); + + +-- +-- Name: users_email_idx; Type: INDEX; Schema: public; Owner: volodymyrrozdolsky +-- + +CREATE UNIQUE INDEX users_email_idx ON public.users USING btree (email); + + +-- +-- Name: reservations reservations_rooms_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.reservations + ADD CONSTRAINT reservations_rooms_id_fk FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: room_restrictions room_restrictions_reservations_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.room_restrictions + ADD CONSTRAINT room_restrictions_reservations_id_fk FOREIGN KEY (reservation_id) REFERENCES public.reservations(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: room_restrictions room_restrictions_restrictions_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.room_restrictions + ADD CONSTRAINT room_restrictions_restrictions_id_fk FOREIGN KEY (restriction_id) REFERENCES public.restrictions(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: room_restrictions room_restrictions_rooms_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: volodymyrrozdolsky +-- + +ALTER TABLE ONLY public.room_restrictions + ADD CONSTRAINT room_restrictions_rooms_id_fk FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- PostgreSQL database dump complete +-- +