-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.sql
More file actions
36 lines (32 loc) · 777 Bytes
/
create.sql
File metadata and controls
36 lines (32 loc) · 777 Bytes
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
DROP SCHEMA IF EXISTS ccca CASCADE;
CREATE SCHEMA ccca;
CREATE TABLE ccca.accounts (
account_id UUID PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL,
cpf TEXT NOT NULL,
car_plate TEXT NULL,
is_passenger BOOLEAN NOT NULL DEFAULT false,
is_driver BOOLEAN NOT NULL DEFAULT false,
password TEXT NOT NULL
);
CREATE TABLE ccca.rides (
ride_id UUID PRIMARY KEY NOT NULL,
passenger_id UUID NOT NULL,
driver_id UUID,
status TEXT NOT NULL,
fare NUMERIC,
distance NUMERIC,
from_lat NUMERIC,
from_long NUMERIC,
to_lat NUMERIC,
to_long NUMERIC,
date TIMESTAMP WITH TIME ZONE NOT NULL
);
CREATE TABLE ccca.positions (
position_id UUID PRIMARY KEY NOT NULL,
ride_id UUID NOT NULL,
lat NUMERIC NOT NULL,
long NUMERIC NOT NULL,
date timestamp WITH TIME ZONE
);