forked from JavaOPs/masterjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabaseChangeLog.sql
More file actions
34 lines (27 loc) · 913 Bytes
/
databaseChangeLog.sql
File metadata and controls
34 lines (27 loc) · 913 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
--liquibase formatted sql
--changeset gkislin:1
CREATE SEQUENCE common_seq START 100000;
CREATE TABLE city (
ref TEXT PRIMARY KEY,
name TEXT NOT NULL
);
ALTER TABLE users
ADD COLUMN city_ref TEXT REFERENCES city (ref) ON UPDATE CASCADE;
--changeset gkislin:2
CREATE TABLE project (
id INTEGER PRIMARY KEY DEFAULT nextval('common_seq'),
name TEXT UNIQUE NOT NULL,
description TEXT
);
CREATE TYPE GROUP_TYPE AS ENUM ('REGISTERING', 'CURRENT', 'FINISHED');
CREATE TABLE groups (
id INTEGER PRIMARY KEY DEFAULT nextval('common_seq'),
name TEXT UNIQUE NOT NULL,
type GROUP_TYPE NOT NULL,
project_id INTEGER NOT NULL REFERENCES project (id)
);
CREATE TABLE user_group (
user_id INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
group_id INTEGER NOT NULL REFERENCES groups (id),
CONSTRAINT users_group_idx UNIQUE (user_id, group_id)
);