-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
64 lines (57 loc) · 2.02 KB
/
init.sql
File metadata and controls
64 lines (57 loc) · 2.02 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
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE IF NOT EXISTS rooms (
id BIGSERIAL PRIMARY KEY,
bedrooms INT,
bathrooms INT,
parking_spots INT,
CONSTRAINT rooms_unique UNIQUE (bedrooms, bathrooms, parking_spots)
);
CREATE TABLE IF NOT EXISTS rooms_extras (
id BIGSERIAL PRIMARY KEY,
living_room BOOLEAN DEFAULT TRUE,
garden BOOLEAN DEFAULT FALSE,
kitchen BOOLEAN DEFAULT TRUE,
laundry_room BOOLEAN DEFAULT FALSE,
pool BOOLEAN DEFAULT FALSE,
office BOOLEAN DEFAULT FALSE
);
CREATE TABLE IF NOT EXISTS condo (
id BIGSERIAL PRIMARY KEY,
name TEXT,
address TEXT,
gym BOOLEAN DEFAULT FALSE,
pool BOOLEAN DEFAULT FALSE,
court BOOLEAN DEFAULT FALSE,
parks BOOLEAN DEFAULT FALSE,
party_spaces BOOLEAN DEFAULT FALSE,
concierge BOOLEAN DEFAULT FALSE,
laundry_room BOOLEAN DEFAULT FALSE
);
CREATE TABLE IF NOT EXISTS users (
id BIGSERIAL PRIMARY KEY,
name TEXT NOT NULL,
age INT,
gender CHAR(1),
email TEXT UNIQUE NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS properties (
id BIGSERIAL PRIMARY KEY,
owner_id BIGINT REFERENCES users(id),
rooms_id BIGINT REFERENCES rooms(id),
rooms_extras_id BIGINT REFERENCES rooms_extras(id),
condo_id BIGINT REFERENCES condo(id),
property_purpose CHAR(1),
type CHAR(1),
area FLOAT,
floors INT,
floor_number INT,
preco NUMERIC(15, 2),
address TEXT,
neighborhood TEXT,
city TEXT,
fotos_url TEXT,
descricao TEXT,
embedding vector(1536),
created_at TIMESTAMP DEFAULT NOW()
);