zkt26/z1/sql/init_db.sql
2026-03-31 20:24:20 +02:00

603 lines
18 KiB
SQL

--
-- PostgreSQL database dump
--
-- Dumped from database version 17.4
-- Dumped by pg_dump version 17.4
-- Started on 2025-04-13 23:02:35
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;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 226 (class 1259 OID 32826)
-- Name: categories; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.categories (
id integer NOT NULL,
name text NOT NULL
);
ALTER TABLE public.categories OWNER TO postgres;
--
-- TOC entry 225 (class 1259 OID 32825)
-- Name: categories_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.categories_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.categories_id_seq OWNER TO postgres;
--
-- TOC entry 4963 (class 0 OID 0)
-- Dependencies: 225
-- Name: categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.categories_id_seq OWNED BY public.categories.id;
--
-- TOC entry 228 (class 1259 OID 32925)
-- Name: deletion_requests; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.deletion_requests (
id integer NOT NULL,
object_id integer NOT NULL,
requested_by integer NOT NULL,
request_date timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
status character varying(50) DEFAULT 'pending'::character varying
);
ALTER TABLE public.deletion_requests OWNER TO postgres;
--
-- TOC entry 227 (class 1259 OID 32924)
-- Name: deletion_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.deletion_requests_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.deletion_requests_id_seq OWNER TO postgres;
--
-- TOC entry 4964 (class 0 OID 0)
-- Dependencies: 227
-- Name: deletion_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.deletion_requests_id_seq OWNED BY public.deletion_requests.id;
--
-- TOC entry 222 (class 1259 OID 32768)
-- Name: range_data; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.range_data (
station_id integer NOT NULL,
temperature_min numeric,
temperature_max numeric,
pressure_min numeric,
pressure_max numeric,
humidity_min numeric,
humidity_max numeric
);
ALTER TABLE public.range_data OWNER TO postgres;
--
-- TOC entry 224 (class 1259 OID 32789)
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.users (
id integer NOT NULL,
name character varying(100) NOT NULL,
surname character varying(100) NOT NULL,
email character varying(255) NOT NULL,
gender character varying(10) NOT NULL,
password character varying(255) NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
points integer DEFAULT 0 NOT NULL,
pseudo character varying(100)
);
ALTER TABLE public.users OWNER TO postgres;
--
-- TOC entry 223 (class 1259 OID 32788)
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.users_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.users_id_seq OWNER TO postgres;
--
-- TOC entry 4965 (class 0 OID 0)
-- Dependencies: 223
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
--
-- TOC entry 221 (class 1259 OID 16479)
-- Name: weather_data; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.weather_data (
id integer NOT NULL,
station_id integer NOT NULL,
temperature numeric(5,2),
humidity numeric(5,2),
pressure numeric(7,2),
wind_speed numeric(5,2),
wind_direction character varying(50),
"timestamp" timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.weather_data OWNER TO postgres;
--
-- TOC entry 220 (class 1259 OID 16478)
-- Name: weather_data_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.weather_data_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.weather_data_id_seq OWNER TO postgres;
--
-- TOC entry 4966 (class 0 OID 0)
-- Dependencies: 220
-- Name: weather_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.weather_data_id_seq OWNED BY public.weather_data.id;
--
-- TOC entry 219 (class 1259 OID 16468)
-- Name: weather_objects; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.weather_objects (
id integer NOT NULL,
name character varying(500) NOT NULL,
description text,
type character varying(100) NOT NULL,
location character varying(255),
last_update timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
status character varying(50) DEFAULT 'active'::character varying,
batterie integer DEFAULT 100,
type_batterie character varying(50),
proprio_id integer,
CONSTRAINT weather_objects_batterie_check CHECK (((batterie >= 0) AND (batterie <= 100)))
);
ALTER TABLE public.weather_objects OWNER TO postgres;
--
-- TOC entry 217 (class 1259 OID 16466)
-- Name: weather_objects_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.weather_objects_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.weather_objects_id_seq OWNER TO postgres;
--
-- TOC entry 218 (class 1259 OID 16467)
-- Name: weather_objects_id_seq1; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.weather_objects_id_seq1
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.weather_objects_id_seq1 OWNER TO postgres;
--
-- TOC entry 4967 (class 0 OID 0)
-- Dependencies: 218
-- Name: weather_objects_id_seq1; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.weather_objects_id_seq1 OWNED BY public.weather_objects.id;
--
-- TOC entry 4776 (class 2604 OID 32829)
-- Name: categories id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.categories ALTER COLUMN id SET DEFAULT nextval('public.categories_id_seq'::regclass);
--
-- TOC entry 4777 (class 2604 OID 32928)
-- Name: deletion_requests id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.deletion_requests ALTER COLUMN id SET DEFAULT nextval('public.deletion_requests_id_seq'::regclass);
--
-- TOC entry 4773 (class 2604 OID 32792)
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
--
-- TOC entry 4771 (class 2604 OID 16482)
-- Name: weather_data id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.weather_data ALTER COLUMN id SET DEFAULT nextval('public.weather_data_id_seq'::regclass);
--
-- TOC entry 4767 (class 2604 OID 16471)
-- Name: weather_objects id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.weather_objects ALTER COLUMN id SET DEFAULT nextval('public.weather_objects_id_seq1'::regclass);
--
-- TOC entry 4955 (class 0 OID 32826)
-- Dependencies: 226
-- Data for Name: categories; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.categories (id, name) FROM stdin;
1 station
2 capteur
\.
--
-- TOC entry 4957 (class 0 OID 32925)
-- Dependencies: 228
-- Data for Name: deletion_requests; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.deletion_requests (id, object_id, requested_by, request_date, status) FROM stdin;
\.
--
-- TOC entry 4951 (class 0 OID 32768)
-- Dependencies: 222
-- Data for Name: range_data; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.range_data (station_id, temperature_min, temperature_max, pressure_min, pressure_max, humidity_min, humidity_max) FROM stdin;
1 -33 33 980 1040 30 84
3 -15 39 980 1040 30 90
9 -15 49 980 1040 30 90
2 -15 50 980 1040 30 90
4 -15 50 980 1040 30 90
5 -15 50 980 1040 30 90
6 -15 50 980 1040 30 90
7 -15 50 980 1040 30 90
8 -15 50 980 1040 30 90
10 -15 50 980 1040 30 90
\.
--
-- TOC entry 4953 (class 0 OID 32789)
-- Dependencies: 224
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.users (id, name, surname, email, gender, password, created_at, points, pseudo) FROM stdin;
9 complexe complexe complexe@gmail.com homme $2a$12$LC/9EhIC9z/5IF8y/SjFVuDWqeQbkkafhRtytNJ9VWIvx6lCgHDfq 2025-04-12 13:10:50.562087 100 complexe
7 admin admin admin@a.com homme $2a$12$cugJ4JNxHjL.GE0ONZlkVerXRlKGc3jtVNlo9qQrck1Kahgnz6Fj2 2025-04-11 21:08:47.705738 247 admin
10 user user user@gmail.com homme $2a$12$wja3M3Lc254Ooge7mE5hwuzHEP35YbVzMYYH6WXs5sKc2q4fvlBei 2025-04-12 14:18:22.728679 0 user
11 admin super admin.a@gmail.com homme $2a$12$LC/9EhIC9z/5IF8y/SjFVuDWqeQbkkafhRtytNJ9VWIvx6lCgHDfq 2025-04-13 12:00:00.000000 999999 admin
\.
--
-- TOC entry 4950 (class 0 OID 16479)
-- Dependencies: 221
-- Data for Name: weather_data; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.weather_data (id, station_id, temperature, humidity, pressure, wind_speed, wind_direction, "timestamp") FROM stdin;
1 1 21.50 60.20 1013.10 5.40 Nord-Ouest 2025-03-29 18:47:46.685241
2 2 22.30 55.00 1012.50 3.20 Sud-Ouest 2025-03-29 18:47:46.685241
3 3 24.10 50.00 1010.80 6.00 Est 2025-03-29 18:47:46.685241
4 1 19.80 65.40 1014.00 4.50 Ouest 2025-03-29 18:47:46.685241
5 2 20.60 59.30 1013.50 2.80 Nord 2025-03-29 18:47:46.685241
6 1 22.50 60.00 1012.50 12.30 Nord-Ouest 2025-03-29 08:00:00
7 1 23.00 65.00 1013.25 14.00 Ouest 2025-03-29 09:00:00
8 1 24.00 70.00 1014.75 15.20 Nord 2025-03-29 10:00:00
9 2 21.50 55.00 1011.30 11.00 Sud 2025-03-29 08:30:00
10 2 22.00 60.00 1012.80 13.00 Est 2025-03-29 09:30:00
11 2 23.50 63.00 1013.50 14.50 Sud-Est 2025-03-29 10:30:00
12 3 26.00 58.00 1012.90 17.00 Ouest 2025-03-29 11:00:00
13 3 27.00 60.00 1014.00 18.50 Nord-Ouest 2025-03-29 12:00:00
14 3 28.00 62.00 1015.10 16.00 Nord 2025-03-29 13:00:00
15 4 19.50 75.00 1010.00 9.50 Sud-Ouest 2025-03-29 08:00:00
16 4 20.00 80.00 1010.50 10.00 Sud 2025-03-29 09:00:00
17 4 21.50 85.00 1011.00 11.50 Est 2025-03-29 10:00:00
18 5 18.00 90.00 1010.70 8.00 Ouest 2025-03-29 08:30:00
19 5 18.50 92.00 1011.20 7.00 Nord-Ouest 2025-03-29 09:30:00
20 5 19.00 95.00 1011.80 6.50 Nord 2025-03-29 10:30:00
21 6 24.50 65.00 1013.90 13.00 Sud 2025-03-29 11:00:00
22 6 25.00 66.00 1014.20 14.50 Ouest 2025-03-29 12:00:00
23 6 26.50 68.00 1015.50 16.00 Sud-Ouest 2025-03-29 13:00:00
24 7 21.00 60.00 1012.50 11.50 Est 2025-03-29 08:00:00
25 7 22.50 62.00 1013.00 12.00 Nord-Ouest 2025-03-29 09:00:00
26 7 23.00 64.00 1013.75 13.50 Sud-Est 2025-03-29 10:00:00
27 8 25.00 58.00 1012.10 16.50 Nord 2025-03-29 08:30:00
28 8 26.00 60.00 1013.30 17.50 Ouest 2025-03-29 09:30:00
29 8 27.00 62.00 1014.50 18.00 Sud-Ouest 2025-03-29 10:30:00
30 9 22.00 67.00 1011.40 14.00 Est 2025-03-29 11:00:00
31 9 23.00 69.00 1012.60 15.00 Nord-Ouest 2025-03-29 12:00:00
32 9 24.00 72.00 1013.80 16.00 Nord 2025-03-29 13:00:00
33 10 18.00 55.00 1010.20 10.00 Ouest 2025-03-29 08:00:00
34 10 19.00 58.00 1011.00 11.50 Sud-Ouest 2025-03-29 09:00:00
35 10 20.00 60.00 1011.70 12.50 Est 2025-03-29 10:00:00
\.
--
-- TOC entry 4948 (class 0 OID 16468)
-- Dependencies: 219
-- Data for Name: weather_objects; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.weather_objects (id, name, description, type, location, last_update, status, batterie, type_batterie, proprio_id) FROM stdin;
3 Station Marseille Station météo située à Marseille, France. Mesures de température, humidité, pression et vent. station Marseille, France 2025-03-30 17:01:10.631653 inactive 100 solaire 7
4 Capteur Bordeaux Capteur de température et d'humidité à Bordeaux. capteur Bordeaux, France 2025-03-30 17:53:01.42853 active 100 solaire 7
5 Capteur Lille Capteur de pression atmosphérique à Lille. capteur Lille, France 2025-03-31 21:32:04.955306 inactive 100 solaire 7
6 Capteur Nantes Capteur de vent à Nantes. capteur Nantes, France 2025-03-30 20:10:18.547523 active 100 solaire 7
7 Station Toulouse Station météo à Toulouse mesurant la température, l'humidité, la pression et la vitesse du vent. station Toulouse, France 2025-04-02 15:43:34.803703 active 100 solaire 7
10 Capteur Paris Sud Capteur de température et humidité à Paris Sud. capteur Paris, France 2025-04-02 23:09:38.725522 inactive 100 solaire 7
8 Capteur Grenoble Capteur de température à Grenoble. capteur Grenoble, France 2025-04-04 10:40:08.247433 active 100 solaire 7
1 Station Paris Station météo située à Paris, France. Mesures de température, humidité, pression et vent. station Paris, France 2025-04-11 10:40:57.350173 active 100 solaire 7
2 Station Lyon Station météo située à Lyon, France. Mesures de température, humidité, pression et vent. station Lyon, France 2025-04-11 23:08:56.344369 inactive 100 solaire 7
9 Station Nice Station météo située à Nice, France. Elle mesure la température, l'humidité et la pression. station Nice, France 2025-04-13 19:26:43.601141 active 100 solaire 7
\.
--
-- TOC entry 4968 (class 0 OID 0)
-- Dependencies: 225
-- Name: categories_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.categories_id_seq', 9, true);
--
-- TOC entry 4969 (class 0 OID 0)
-- Dependencies: 227
-- Name: deletion_requests_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.deletion_requests_id_seq', 31, true);
--
-- TOC entry 4970 (class 0 OID 0)
-- Dependencies: 223
-- Name: users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.users_id_seq', 14, true);
--
-- TOC entry 4971 (class 0 OID 0)
-- Dependencies: 220
-- Name: weather_data_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.weather_data_id_seq', 35, true);
--
-- TOC entry 4972 (class 0 OID 0)
-- Dependencies: 217
-- Name: weather_objects_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.weather_objects_id_seq', 1, false);
--
-- TOC entry 4973 (class 0 OID 0)
-- Dependencies: 218
-- Name: weather_objects_id_seq1; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.weather_objects_id_seq1', 44, true);
--
-- TOC entry 4792 (class 2606 OID 32835)
-- Name: categories categories_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.categories
ADD CONSTRAINT categories_name_key UNIQUE (name);
--
-- TOC entry 4794 (class 2606 OID 32833)
-- Name: categories categories_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.categories
ADD CONSTRAINT categories_pkey PRIMARY KEY (id);
--
-- TOC entry 4796 (class 2606 OID 32932)
-- Name: deletion_requests deletion_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.deletion_requests
ADD CONSTRAINT deletion_requests_pkey PRIMARY KEY (id);
--
-- TOC entry 4786 (class 2606 OID 32774)
-- Name: range_data station_meteo_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.range_data
ADD CONSTRAINT station_meteo_pkey PRIMARY KEY (station_id);
--
-- TOC entry 4788 (class 2606 OID 32799)
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_email_key UNIQUE (email);
--
-- TOC entry 4790 (class 2606 OID 32797)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- TOC entry 4784 (class 2606 OID 16485)
-- Name: weather_data weather_data_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.weather_data
ADD CONSTRAINT weather_data_pkey PRIMARY KEY (id);
--
-- TOC entry 4782 (class 2606 OID 16477)
-- Name: weather_objects weather_objects_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.weather_objects
ADD CONSTRAINT weather_objects_pkey PRIMARY KEY (id);
--
-- TOC entry 4799 (class 2606 OID 32933)
-- Name: deletion_requests deletion_requests_object_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.deletion_requests
ADD CONSTRAINT deletion_requests_object_id_fkey FOREIGN KEY (object_id) REFERENCES public.weather_objects(id) ON DELETE CASCADE;
--
-- TOC entry 4800 (class 2606 OID 32938)
-- Name: deletion_requests deletion_requests_requested_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.deletion_requests
ADD CONSTRAINT deletion_requests_requested_by_fkey FOREIGN KEY (requested_by) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- TOC entry 4797 (class 2606 OID 32820)
-- Name: weather_objects fk_proprio; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.weather_objects
ADD CONSTRAINT fk_proprio FOREIGN KEY (proprio_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- TOC entry 4798 (class 2606 OID 32836)
-- Name: weather_data weather_data_station_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.weather_data
ADD CONSTRAINT weather_data_station_id_fkey FOREIGN KEY (station_id) REFERENCES public.weather_objects(id) ON DELETE CASCADE;
-- Completed on 2025-04-13 23:02:36
--
-- PostgreSQL database dump complete
--