\restrict dbmate -- Dumped from database version 18.3 -- Dumped by pg_dump version 18.6 SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET transaction_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; -- -- Name: bike_size; Type: TYPE; Schema: public; Owner: - -- CREATE TYPE public.bike_size AS ENUM ( 'large', 'small' ); -- -- Name: bike_status; Type: TYPE; Schema: public; Owner: - -- CREATE TYPE public.bike_status AS ENUM ( 'in_service', 'out_of_service' ); -- -- Name: reservation_status; Type: TYPE; Schema: public; Owner: - -- CREATE TYPE public.reservation_status AS ENUM ( 'requested', 'refused', 'approved', 'cancelled', 'ongoing', 'archived' ); SET default_tablespace = ''; SET default_table_access_method = heap; -- -- Name: bikes; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.bikes ( id integer NOT NULL, name text NOT NULL, key_number text, key_quantity integer DEFAULT 0 NOT NULL, drivetrain text, battery text, status public.bike_status DEFAULT 'in_service'::public.bike_status NOT NULL, size public.bike_size NOT NULL, CONSTRAINT bikes_key_quantity_positive CHECK ((key_quantity >= 0)) ); -- -- Name: bikes_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.bikes_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: bikes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.bikes_id_seq OWNED BY public.bikes.id; -- -- Name: oidc_states; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.oidc_states ( key text NOT NULL, data text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL ); -- -- Name: reservations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.reservations ( id integer NOT NULL, start_time timestamp with time zone NOT NULL, end_time timestamp with time zone NOT NULL, requester_id integer NOT NULL, telegram text NOT NULL, description text DEFAULT ''::text NOT NULL, status public.reservation_status DEFAULT 'requested'::public.reservation_status NOT NULL, unit_id integer, unit_label text, CONSTRAINT reservations_telegram_handle CHECK ((telegram ~ '^@[A-Za-z][A-Za-z0-9_]{4,31}$'::text)), CONSTRAINT reservations_time_order CHECK ((end_time > start_time)), CONSTRAINT reservations_unit_label_not_blank CHECK (((unit_label IS NULL) OR (btrim(unit_label) <> ''::text))), CONSTRAINT reservations_unit_xor CHECK (((unit_id IS NULL) <> (unit_label IS NULL))) ); -- -- Name: reservations_bikes; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.reservations_bikes ( reservation_id integer NOT NULL, bike_id integer NOT NULL ); -- -- Name: reservations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.reservations_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: reservations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.reservations_id_seq OWNED BY public.reservations.id; -- -- Name: reservations_users; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.reservations_users ( reservation_id integer NOT NULL, user_id integer NOT NULL ); -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.schema_migrations ( version character varying NOT NULL ); -- -- Name: units; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.units ( id integer NOT NULL, name text NOT NULL ); -- -- Name: units_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.units_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: units_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.units_id_seq OWNED BY public.units.id; -- -- Name: units_users; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.units_users ( user_id integer NOT NULL, unit_id integer NOT NULL ); -- -- Name: users; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.users ( id integer NOT NULL, external_id text, firstname text NOT NULL, name text NOT NULL, email text NOT NULL, oidc_sub text NOT NULL, admin boolean DEFAULT false NOT NULL ); -- -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.users_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; -- -- Name: bikes id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.bikes ALTER COLUMN id SET DEFAULT nextval('public.bikes_id_seq'::regclass); -- -- Name: reservations id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.reservations ALTER COLUMN id SET DEFAULT nextval('public.reservations_id_seq'::regclass); -- -- Name: units id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.units ALTER COLUMN id SET DEFAULT nextval('public.units_id_seq'::regclass); -- -- Name: users id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); -- -- Name: bikes bikes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.bikes ADD CONSTRAINT bikes_pkey PRIMARY KEY (id); -- -- Name: oidc_states oidc_states_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.oidc_states ADD CONSTRAINT oidc_states_pkey PRIMARY KEY (key); -- -- Name: reservations_bikes reservations_bikes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.reservations_bikes ADD CONSTRAINT reservations_bikes_pkey PRIMARY KEY (reservation_id, bike_id); -- -- Name: reservations reservations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.reservations ADD CONSTRAINT reservations_pkey PRIMARY KEY (id); -- -- Name: reservations_users reservations_users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.reservations_users ADD CONSTRAINT reservations_users_pkey PRIMARY KEY (reservation_id, user_id); -- -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.schema_migrations ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); -- -- Name: units units_name_key; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.units ADD CONSTRAINT units_name_key UNIQUE (name); -- -- Name: units units_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.units ADD CONSTRAINT units_pkey PRIMARY KEY (id); -- -- Name: units_users units_users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.units_users ADD CONSTRAINT units_users_pkey PRIMARY KEY (unit_id, user_id); -- -- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ADD CONSTRAINT users_email_key UNIQUE (email); -- -- Name: users users_external_id_key; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ADD CONSTRAINT users_external_id_key UNIQUE (external_id); -- -- Name: users users_oidc_sub_key; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ADD CONSTRAINT users_oidc_sub_key UNIQUE (oidc_sub); -- -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id); -- -- Name: oidc_states_created_at_idx; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX oidc_states_created_at_idx ON public.oidc_states USING btree (created_at); -- -- Name: reservations_bikes_bike_id_idx; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX reservations_bikes_bike_id_idx ON public.reservations_bikes USING btree (bike_id); -- -- Name: reservations_period_idx; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX reservations_period_idx ON public.reservations USING btree (start_time, end_time); -- -- Name: reservations_status_idx; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX reservations_status_idx ON public.reservations USING btree (status); -- -- Name: reservations_unit_id_idx; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX reservations_unit_id_idx ON public.reservations USING btree (unit_id); -- -- Name: units_users_user_id_idx; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX units_users_user_id_idx ON public.units_users USING btree (user_id); -- -- Name: reservations_bikes reservations_bikes_bike_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.reservations_bikes ADD CONSTRAINT reservations_bikes_bike_id_fkey FOREIGN KEY (bike_id) REFERENCES public.bikes(id) ON DELETE RESTRICT; -- -- Name: reservations_bikes reservations_bikes_reservation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.reservations_bikes ADD CONSTRAINT reservations_bikes_reservation_id_fkey FOREIGN KEY (reservation_id) REFERENCES public.reservations(id) ON DELETE CASCADE; -- -- Name: reservations reservations_requester_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.reservations ADD CONSTRAINT reservations_requester_id_fkey FOREIGN KEY (requester_id) REFERENCES public.users(id); -- -- Name: reservations reservations_unit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.reservations ADD CONSTRAINT reservations_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES public.units(id); -- -- Name: reservations_users reservations_users_reservation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.reservations_users ADD CONSTRAINT reservations_users_reservation_id_fkey FOREIGN KEY (reservation_id) REFERENCES public.reservations(id) ON DELETE CASCADE; -- -- Name: reservations_users reservations_users_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.reservations_users ADD CONSTRAINT reservations_users_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: units_users units_users_unit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.units_users ADD CONSTRAINT units_users_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES public.units(id) ON DELETE CASCADE; -- -- Name: units_users units_users_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.units_users ADD CONSTRAINT units_users_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- PostgreSQL database dump complete -- \unrestrict dbmate -- -- Dbmate schema migrations -- INSERT INTO public.schema_migrations (version) VALUES ('20260823153300'), ('20260823153310'), ('20260823153320'), ('20260823170000'), ('20260823210000'), ('20260823230000'), ('20260824120000');