db-e.sql 978 Bytes
Newer Older
Vladislav Rykov's avatar
Vladislav Rykov committed
1
CREATE TABLE public.notifications (
2
3
	id VARCHAR(10) NOT NULL,
	app_key VARCHAR(30) NOT NULL,
Vladislav Rykov's avatar
Vladislav Rykov committed
4
5
6
7
8
9
10
11
12
13
	dev_id NUMERIC(3) NOT NULL,
	name VARCHAR(50) NOT NULL,
	description VARCHAR(300),
	action_type VARCHAR(20) NOT NULL,
	action VARCHAR (200) NOT NULL
);

CREATE TABLE public.notifications_queue (
	nf_id VARCHAR(10) NOT NULL,
	app_key VARCHAR(30) NOT NULL,
14
15
	dev_id NUMERIC(3) NOT NULL,
	fired_on TIMESTAMP(6) NOT NULL
Vladislav Rykov's avatar
Vladislav Rykov committed
16
17
);

18

Vladislav Rykov's avatar
Vladislav Rykov committed
19
20
21
22
23
24
25
ALTER TABLE ONLY public.notifications
	ADD CONSTRAINT notifications_pkey PRIMARY KEY (id, app_key, dev_id);

ALTER TABLE ONLY public.notifications
	ADD CONSTRAINT notifications_app_key_fkey FOREIGN KEY (app_key) REFERENCES public.applications(app_key);

ALTER TABLE ONLY public.notifications_queue
26
	ADD CONSTRAINT notifications_queue_pkey PRIMARY KEY (nf_id, app_key, dev_id);
Vladislav Rykov's avatar
Vladislav Rykov committed
27
28

ALTER TABLE ONLY public.notifications_queue
29
	ADD CONSTRAINT notifications_queue_app_key_fkey FOREIGN KEY (app_key, nf_id, dev_id) REFERENCES public.notifications(app_key, id, dev_id);
Vladislav Rykov's avatar
Vladislav Rykov committed
30