feat: add initial database schema and postgres profile
This commit is contained in:
1 parent
3bf5fc8940
commit
4535e0127f
3 files changed
+78
No files matched your search
@@ -0,0 +1,32 @@
|
||||
CREATE TABLE app_user (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
username VARCHAR(64) NOT NULL,
|
||||
password_hash VARCHAR(100) NOT NULL,
|
||||
role VARCHAR(16) NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
CONSTRAINT uq_app_user_username UNIQUE (username)
|
||||
);
|
||||
|
||||
CREATE TABLE resource (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
name VARCHAR(128) NOT NULL,
|
||||
description VARCHAR(512),
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
version BIGINT NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE reservation (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
resource_id BIGINT NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
start_time TIMESTAMP NOT NULL,
|
||||
end_time TIMESTAMP NOT NULL,
|
||||
status VARCHAR(16) NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
version BIGINT NOT NULL DEFAULT 0,
|
||||
CONSTRAINT fk_reservation_resource FOREIGN KEY (resource_id) REFERENCES resource (id),
|
||||
CONSTRAINT fk_reservation_user FOREIGN KEY (user_id) REFERENCES app_user (id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_reservation_resource_status ON reservation (resource_id, status);
|
||||
CREATE INDEX idx_reservation_user ON reservation (user_id);
|
||||
Reference in new issue
Block a user