-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit-schema.docker.sql
More file actions
67 lines (57 loc) · 1.92 KB
/
Copy pathinit-schema.docker.sql
File metadata and controls
67 lines (57 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
-- This file is almost the same as `scrapy.sql` but contains only the necessary to initialize the database once.
-- also, it doesn't hardcode the database name or user so the values are free to be defined in `docker-compose.yml`
CREATE EXTENSION unaccent;
CREATE TABLE "seller" (
"seller_id" integer PRIMARY KEY,
"seller_name" text,
"seller_url" text,
"seller_nb_announces" integer,
"seller_is_pro" boolean
);
CREATE TABLE "okkazeo_announce" (
"oa_id" integer UNIQUE NOT NULL,
"oa_last_modification_date" timestamptz NOT NULL,
"oa_name" text NOT NULL,
"oa_image" text NOT NULL,
"oa_price" real NOT NULL,
"oa_url" text NOT NULL,
"oa_extension" text,
"oa_seller" integer REFERENCES seller("seller_id"),
"oa_barcode" bigint,
"oa_city" text,
"oa_nbr_player" integer
);
CREATE TABLE "deal" (
"deal_id" SERIAL PRIMARY KEY,
"deal_oa_id" integer REFERENCES okkazeo_announce("oa_id") ON DELETE CASCADE,
"deal_price" integer,
"deal_percentage" integer
);
CREATE TABLE "reference" (
"ref_id" SERIAL PRIMARY KEY,
"ref_oa_id" integer REFERENCES okkazeo_announce("oa_id") ON DELETE CASCADE,
"ref_name" text,
"ref_price" real,
"ref_url" text,
"ref_available" boolean
);
CREATE TABLE "reviewer" (
"reviewer_id" SERIAL PRIMARY KEY,
"reviewer_oa_id" integer REFERENCES okkazeo_announce("oa_id") ON DELETE CASCADE,
"reviewer_name" text,
"reviewer_url" text,
"reviewer_note" real,
"reviewer_number" integer
);
CREATE TABLE "shipping" (
"ship_id" SERIAL PRIMARY KEY,
"ship_oa_id" integer REFERENCES okkazeo_announce("oa_id") ON DELETE CASCADE,
"ship_shipper" text,
"ship_price" real
);
CREATE INDEX idx_deal_oa_id ON deal (deal_oa_id);
CREATE INDEX idx_oa_id ON okkazeo_announce (oa_id);
CREATE INDEX idx_reference_oa_id ON reference (ref_oa_id);
CREATE INDEX idx_reviewer_oa_id ON reviewer (reviewer_oa_id);
CREATE INDEX idx_ship_oa_id ON shipping (ship_oa_id);
CREATE INDEX idx_seller ON seller (seller_id);