-
Notifications
You must be signed in to change notification settings - Fork 25
/
test_db.sql
46 lines (36 loc) · 1.02 KB
/
test_db.sql
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
drop schema if exists "public" cascade;
drop schema if exists "geo" cascade;
create schema "public";
create extension if not exists "uuid-ossp";
create table "projects"
(
"projectId" uuid not null default uuid_generate_v4(),
"code" uuid,
"name" text not null,
primary key ("projectId")
);
create table "users"
(
"userId" serial not null,
"email" varchar(64) not null,
"activated" bool not null default false,
"name" varchar(128),
"countryId" integer,
"avatar" bytea not null,
"avatarAlt" bytea,
"apiKeys" bytea[],
"loggedAt" timestamp,
primary key ("userId")
);
create schema "geo";
create table geo."countries"
(
"countryId" serial not null,
"code" varchar(3) not null,
"coords" integer[],
primary key ("countryId")
);
alter table "users"
add constraint "fk_user_country"
foreign key ("countryId")
references geo."countries" ("countryId") on update restrict on delete restrict;