--
--

\restrict qy66XnLkTKWk7lyOecwWH8nZd79pD84h7gvN2fyyRUc9MaL68wUP0wAzsF0Wyqq


SELECT pg_catalog.set_config('search_path', '', false);

ALTER TABLE IF EXISTS ONLY public.scans DROP CONSTRAINT IF EXISTS scan_history_api_key_id_fkey;
ALTER TABLE IF EXISTS ONLY public.password_reset_codes DROP CONSTRAINT IF EXISTS password_reset_codes_user_id_fkey;
DROP INDEX IF EXISTS public.idx_subscription_lookup;
DROP INDEX IF EXISTS public.idx_password_reset_codes_user_id;
DROP INDEX IF EXISTS public.idx_password_reset_codes_expires_at;
DROP INDEX IF EXISTS public.idx_api_key_lookup;
ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS users_email_key;
ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS users_api_key_key;
ALTER TABLE IF EXISTS ONLY public.scans DROP CONSTRAINT IF EXISTS scan_history_pkey;
ALTER TABLE IF EXISTS ONLY public.password_reset_codes DROP CONSTRAINT IF EXISTS password_reset_codes_user_id_key;
ALTER TABLE IF EXISTS ONLY public.password_reset_codes DROP CONSTRAINT IF EXISTS password_reset_codes_pkey;
ALTER TABLE IF EXISTS ONLY public.api_key DROP CONSTRAINT IF EXISTS api_key_pkey1;
ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS api_key_pkey;
ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS api_key_key_hash_key;
ALTER TABLE IF EXISTS ONLY public.api_key DROP CONSTRAINT IF EXISTS api_key_api_key_key;
ALTER TABLE IF EXISTS public.users ALTER COLUMN id DROP DEFAULT;
ALTER TABLE IF EXISTS public.scans ALTER COLUMN id DROP DEFAULT;
ALTER TABLE IF EXISTS public.password_reset_codes ALTER COLUMN id DROP DEFAULT;
ALTER TABLE IF EXISTS public.api_key ALTER COLUMN id DROP DEFAULT;
DROP SEQUENCE IF EXISTS public.scan_history_id_seq;
DROP SEQUENCE IF EXISTS public.password_reset_codes_id_seq;
DROP SEQUENCE IF EXISTS public.api_key_id_seq1;
DROP SEQUENCE IF EXISTS public.api_key_id_seq;


--
-- Name: api_key; Type: TABLE; Schema: public; Owner: websentinel_user
--

CREATE TABLE public.api_key (
    id integer NOT NULL,
    email character varying(255) NOT NULL,
    api_key character varying(255) NOT NULL,
    tier character varying(32) DEFAULT 'FREE'::character varying NOT NULL,
    status character varying(32) DEFAULT 'active'::character varying NOT NULL,
    max_domains integer DEFAULT 10,
    max_users integer DEFAULT 1,
    stripe_customer_id character varying(255),
    stripe_subscription_id character varying(255),
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    expires_at timestamp with time zone,
    usage_count integer DEFAULT 0,
    last_used_at timestamp with time zone,
    events jsonb DEFAULT '[]'::jsonb
);


ALTER TABLE public.api_key OWNER TO websentinel_user;

--
-- Name: users; Type: TABLE; Schema: public; Owner: websentinel_user
--

CREATE TABLE public.users (
    id integer NOT NULL,
    key_hash character varying(64),
    name character varying(100) NOT NULL,
    email character varying(120) NOT NULL,
    tier character varying(20),
    created_at timestamp without time zone,
    last_used timestamp without time zone,
    is_active boolean,
    daily_limit integer,
    monthly_limit integer,
    password_hash character varying(255),
    api_key character varying(100),
    license_key character varying(100),
    license_purchased_at timestamp without time zone,
    license_expires_at timestamp without time zone,
    last_login timestamp without time zone,
    name_full character varying(255)
);


ALTER TABLE public.users OWNER TO websentinel_user;

--
-- Name: api_key_id_seq; Type: SEQUENCE; Schema: public; Owner: websentinel_user
--

CREATE SEQUENCE public.api_key_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.api_key_id_seq OWNER TO websentinel_user;

--
-- Name: api_key_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: websentinel_user
--

ALTER SEQUENCE public.api_key_id_seq OWNED BY public.users.id;


--
-- Name: api_key_id_seq1; Type: SEQUENCE; Schema: public; Owner: websentinel_user
--

CREATE SEQUENCE public.api_key_id_seq1
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.api_key_id_seq1 OWNER TO websentinel_user;

--
-- Name: api_key_id_seq1; Type: SEQUENCE OWNED BY; Schema: public; Owner: websentinel_user
--

ALTER SEQUENCE public.api_key_id_seq1 OWNED BY public.api_key.id;


--
-- Name: password_reset_codes; Type: TABLE; Schema: public; Owner: websentinel_user
--

CREATE TABLE public.password_reset_codes (
    id integer NOT NULL,
    user_id integer NOT NULL,
    code character varying(6) NOT NULL,
    expires_at timestamp without time zone NOT NULL,
    used boolean DEFAULT false,
    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);


ALTER TABLE public.password_reset_codes OWNER TO websentinel_user;

--
-- Name: password_reset_codes_id_seq; Type: SEQUENCE; Schema: public; Owner: websentinel_user
--

CREATE SEQUENCE public.password_reset_codes_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.password_reset_codes_id_seq OWNER TO websentinel_user;

--
-- Name: password_reset_codes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: websentinel_user
--

ALTER SEQUENCE public.password_reset_codes_id_seq OWNED BY public.password_reset_codes.id;


--
-- Name: scans; Type: TABLE; Schema: public; Owner: websentinel_user
--

CREATE TABLE public.scans (
    id integer NOT NULL,
    api_key_id integer NOT NULL,
    scan_type character varying(20) NOT NULL,
    target character varying(500) NOT NULL,
    findings_count integer,
    "timestamp" timestamp without time zone,
    processing_time double precision,
    severity_critical integer DEFAULT 0,
    severity_high integer DEFAULT 0,
    severity_medium integer DEFAULT 0,
    severity_low integer DEFAULT 0,
    severity_info integer DEFAULT 0,
    duration double precision
);


ALTER TABLE public.scans OWNER TO websentinel_user;

--
-- Name: scan_history_id_seq; Type: SEQUENCE; Schema: public; Owner: websentinel_user
--

CREATE SEQUENCE public.scan_history_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.scan_history_id_seq OWNER TO websentinel_user;

--
-- Name: scan_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: websentinel_user
--

ALTER SEQUENCE public.scan_history_id_seq OWNED BY public.scans.id;


--
-- Name: api_key id; Type: DEFAULT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.api_key ALTER COLUMN id SET DEFAULT nextval('public.api_key_id_seq1'::regclass);


--
-- Name: password_reset_codes id; Type: DEFAULT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.password_reset_codes ALTER COLUMN id SET DEFAULT nextval('public.password_reset_codes_id_seq'::regclass);


--
-- Name: scans id; Type: DEFAULT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.scans ALTER COLUMN id SET DEFAULT nextval('public.scan_history_id_seq'::regclass);


--
-- Name: users id; Type: DEFAULT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.api_key_id_seq'::regclass);


--
-- Data for Name: api_key; Type: TABLE DATA; Schema: public; Owner: websentinel_user
--

COPY public.api_key (id, email, api_key, tier, status, max_domains, max_users, stripe_customer_id, stripe_subscription_id, created_at, updated_at, expires_at, usage_count, last_used_at, events) FROM stdin;
\.


--
-- Data for Name: password_reset_codes; Type: TABLE DATA; Schema: public; Owner: websentinel_user
--

COPY public.password_reset_codes (id, user_id, code, expires_at, used, created_at) FROM stdin;
1	4	086780	2025-11-06 13:58:34.638966	f	2025-11-06 12:50:47.891881
16	21	979744	2025-11-06 14:10:05.664853	f	2025-11-06 13:35:22.590359
17	22	858431	2025-11-06 14:10:29.318347	f	2025-11-06 13:35:37.503563
\.


--
-- Data for Name: scans; Type: TABLE DATA; Schema: public; Owner: websentinel_user
--

COPY public.scans (id, api_key_id, scan_type, target, findings_count, "timestamp", processing_time, severity_critical, severity_high, severity_medium, severity_low, severity_info, duration) FROM stdin;
1	3	source_scan	test.php	0	2025-10-24 08:19:43	\N	0	0	0	0	0	0.053972
2	3	source_scan	xss.php	2	2025-10-24 09:10:07	\N	0	2	0	0	0	0.042311
3	10	telemetry	v1.1.0	10	2025-10-31 13:14:56	\N	0	0	0	0	0	3.5
4	11	telemetry	v1.1.0	5	2025-10-31 13:16:35	\N	0	0	0	0	0	2.5
5	12	telemetry	v1.1.0	30	2025-10-31 13:37:02	\N	0	0	0	0	0	7.5
6	11	telemetry	v1.1.0	5	2025-10-31 14:41:38	\N	0	0	0	0	0	2.5
7	10	telemetry	v1.0.0	11	2025-10-31 15:08:56	\N	0	0	0	0	0	21.6
8	11	telemetry	v1.1.0	5	2025-10-31 15:09:13	\N	0	0	0	0	0	2.5
9	10	telemetry	v1.0.0	3	2025-10-31 15:10:05	\N	0	0	0	0	0	0.29
10	11	telemetry	v1.1.0	5	2025-10-31 15:10:28	\N	0	0	0	0	0	2.5
11	13	telemetry	v1.0.0	12	2025-10-31 15:11:53	\N	0	0	0	0	0	0.24
12	10	telemetry	v1.0.0	12	2025-10-31 15:12:00	\N	0	0	0	0	0	0.23
13	10	telemetry	v1.0.0	12	2025-10-31 15:18:30	\N	0	0	0	0	0	0.2
14	14	telemetry	v1.1.0	3	2025-10-31 15:18:34	\N	0	0	0	0	0	1.5
15	4	sast	web-sentinel	58	2025-11-06 08:28:32.568822	\N	8	43	1	6	0	2.6097464561462402
16	4	sast	web-sentinel	58	2025-11-06 08:33:27.380322	\N	8	43	1	6	0	2.3260765075683594
17	4	sast	web-sentinel	58	2025-11-06 08:59:20.979824	\N	8	43	1	6	0	2.1537485122680664
18	4	sast	web-sentinel	58	2025-11-06 09:29:55.442863	\N	8	43	1	6	0	2.6883914470672607
19	4	sast	web-sentinel	58	2025-11-06 10:18:30.529348	\N	8	43	1	6	0	2.3013575077056885
20	4	sast	web-sentinel	58	2025-11-06 10:24:29.136955	\N	8	43	1	6	0	2.5923538208007812
21	4	sast	FailDaily	16	2025-11-06 10:31:59.520059	\N	0	5	2	8	1	32.70695114135742
22	4	sast	WEB API	298	2025-11-06 10:41:13.566979	\N	36	205	20	36	1	49.77846074104309
23	4	sast	Taaazzz-prog	7	2025-11-06 11:00:18.31357	\N	2	5	0	0	0	0.10944509506225586
24	4	sast	Taaazzz-prog	7	2025-11-06 11:31:52.377237	\N	2	5	0	0	0	0.1918487548828125
25	4	sast	harrypotter	0	2025-11-06 12:30:59.160799	\N	0	0	0	0	0	0.20413637161254883
26	4	sast	Pokemon	7	2025-11-06 12:31:52.365302	\N	0	7	0	0	0	1.8695976734161377
27	4	sast	coolcare-app	199	2025-11-06 13:04:44.849864	\N	28	138	11	22	0	8.215680837631226
\.


--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: websentinel_user
--

COPY public.users (id, key_hash, name, email, tier, created_at, last_used, is_active, daily_limit, monthly_limit, password_hash, api_key, license_key, license_purchased_at, license_expires_at, last_login, name_full) FROM stdin;
5	\N	test.586567062	test.586567062@example.com	free	2025-11-05 10:04:32	\N	t	\N	\N	ae98e50bfbf12b226fbc1fa9f7542919$6e098a97784752ca6b3d411f676108fab1c4b72f5b325b964d4f3f6ef72a7afb	\N	\N	\N	\N	\N	test.586567062
10	\N	Telemetry GUI	telemetry-windows-gui	free	2025-11-05 12:04:46.932862	\N	t	\N	\N	\N	\N	\N	\N	\N	\N	Telemetry GUI
11	\N	Telemetry Script	telemetry-test-script	free	2025-11-05 12:04:46.932862	\N	t	\N	\N	\N	\N	\N	\N	\N	\N	Telemetry Script
12	\N	Telemetry Final	telemetry-final-test	free	2025-11-05 12:04:46.932862	\N	t	\N	\N	\N	\N	\N	\N	\N	\N	Telemetry Final
13	\N	Telemetry CLI	telemetry-windows-cli	free	2025-11-05 12:04:46.932862	\N	t	\N	\N	\N	\N	\N	\N	\N	\N	Telemetry CLI
14	\N	Telemetry Verif	telemetry-verification-finale	free	2025-11-05 12:04:46.932862	\N	t	\N	\N	\N	\N	\N	\N	\N	\N	Telemetry Verif
3	\N	Aurelien Mossini	aurelien.mossini@example.com	sysop	2025-11-05 12:03:55.23804	\N	t	\N	\N	916f7ec0b9ac7018e36058a20441121a$5001ab114283fdaffdda2f61c639893e412ad493a9a77bca3c2dee46b326f9cb	ws_sysop_CUsMkeL6jdDHXrA14rot9Vj0Yegg4KiPuYqiHMKhRC0	\N	\N	\N	\N	Aurelien Mossini
1	ws_sysop_aurelien_2025_hash	Aurelien Mossini	aurelien.mossini@taaazzz-prog.fr	sysop	2025-10-23 18:54:34.244403	\N	t	10000	100000	916f7ec0b9ac7018e36058a20441121a$5001ab114283fdaffdda2f61c639893e412ad493a9a77bca3c2dee46b326f9cb	ws_sysop_aurelien_2025_hash	\N	\N	\N	\N	Aurelien Mossini
4	\N	Bruno Taaazzz	bruno@taaazzz-prog.fr	sysop	2025-11-05 12:03:55.259053	\N	t	\N	\N	faad59a3c654c0b9622b0b376490eb4d$359ac35b1846d20b120629621eba89745da178b25d73522c524c58572ef05159	ws_sysop_bruno_taaazzz_2024	\N	\N	\N	\N	Bruno Taaazzz
21	\N	Bruno	bruno@taaazzz.be	pro	2025-11-06 13:35:14.029885	\N	t	\N	\N	ddc485e87b3268d9dd7cfe91961469e90ad999b6266158ae84ffb6926a2c994b:154035ec86dc5814024e660017244be2	\N	\N	\N	\N	\N	\N
22	\N	Contact Taaazzz	contact@taaazzz-prog.fr	entreprise	2025-11-06 13:35:14.029885	\N	t	\N	\N	e627b4c7c87b40d3881328f89e022166ed7b7fe7506e658b64d5cd608bf3fc0d:ffa0ec8cf6cd596827f76c6764035e6b	\N	\N	\N	\N	\N	\N
\.


--
-- Name: api_key_id_seq; Type: SEQUENCE SET; Schema: public; Owner: websentinel_user
--

SELECT pg_catalog.setval('public.api_key_id_seq', 22, true);


--
-- Name: api_key_id_seq1; Type: SEQUENCE SET; Schema: public; Owner: websentinel_user
--

SELECT pg_catalog.setval('public.api_key_id_seq1', 1, false);


--
-- Name: password_reset_codes_id_seq; Type: SEQUENCE SET; Schema: public; Owner: websentinel_user
--

SELECT pg_catalog.setval('public.password_reset_codes_id_seq', 19, true);


--
-- Name: scan_history_id_seq; Type: SEQUENCE SET; Schema: public; Owner: websentinel_user
--

SELECT pg_catalog.setval('public.scan_history_id_seq', 27, true);


--
-- Name: api_key api_key_api_key_key; Type: CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.api_key
    ADD CONSTRAINT api_key_api_key_key UNIQUE (api_key);


--
-- Name: users api_key_key_hash_key; Type: CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT api_key_key_hash_key UNIQUE (key_hash);


--
-- Name: users api_key_pkey; Type: CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT api_key_pkey PRIMARY KEY (id);


--
-- Name: api_key api_key_pkey1; Type: CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.api_key
    ADD CONSTRAINT api_key_pkey1 PRIMARY KEY (id);


--
-- Name: password_reset_codes password_reset_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.password_reset_codes
    ADD CONSTRAINT password_reset_codes_pkey PRIMARY KEY (id);


--
-- Name: password_reset_codes password_reset_codes_user_id_key; Type: CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.password_reset_codes
    ADD CONSTRAINT password_reset_codes_user_id_key UNIQUE (user_id);


--
-- Name: scans scan_history_pkey; Type: CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.scans
    ADD CONSTRAINT scan_history_pkey PRIMARY KEY (id);


--
-- Name: users users_api_key_key; Type: CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_api_key_key UNIQUE (api_key);


--
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_email_key UNIQUE (email);


--
-- Name: idx_api_key_lookup; Type: INDEX; Schema: public; Owner: websentinel_user
--

CREATE INDEX idx_api_key_lookup ON public.api_key USING btree (api_key);


--
-- Name: idx_password_reset_codes_expires_at; Type: INDEX; Schema: public; Owner: websentinel_user
--

CREATE INDEX idx_password_reset_codes_expires_at ON public.password_reset_codes USING btree (expires_at);


--
-- Name: idx_password_reset_codes_user_id; Type: INDEX; Schema: public; Owner: websentinel_user
--

CREATE INDEX idx_password_reset_codes_user_id ON public.password_reset_codes USING btree (user_id);


--
-- Name: idx_subscription_lookup; Type: INDEX; Schema: public; Owner: websentinel_user
--

CREATE INDEX idx_subscription_lookup ON public.api_key USING btree (stripe_subscription_id);


--
-- Name: password_reset_codes password_reset_codes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.password_reset_codes
    ADD CONSTRAINT password_reset_codes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: scans scan_history_api_key_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: websentinel_user
--

ALTER TABLE ONLY public.scans
    ADD CONSTRAINT scan_history_api_key_id_fkey FOREIGN KEY (api_key_id) REFERENCES public.users(id);


--
--

\unrestrict qy66XnLkTKWk7lyOecwWH8nZd79pD84h7gvN2fyyRUc9MaL68wUP0wAzsF0Wyqq

