Untitled

mail@pastecode.io avatar
unknown
pgsql
24 days ago
1.3 kB
1
Indexable
Never
CREATE TABLE user (
    id BIGINT NOT NULL PRIMARY KEY,
    fio TEXT NOT NULL,
    type TEXT NOT NULL,
    login TEXT NOT NULL,
    password TEXT NOT NULL
);

CREATE TABLE project (
    id BIGINT NOT NULL PRIMARY KEY,
    owner_id BIGINT NOT NULL REFERENCES user (id),
    name TEXT NOT NULL
);

CREATE TABLE status (
    id BIGINT NOT NULL PRIMARY KEY,
    name TEXT NOT NULL,
    description TEXT NOT NULL
);

CREATE TABLE document (
    id BIGINT NOT NULL PRIMARY KEY,
    status_id BIGINT NOT NULL REFERENCES status (id),
    project_id BIGINT NOT NULL REFERENCES project (id),
    name TEXT NOT NULL,
    standart TEXT NOT NULL,
    created_at TIMESTAMPTZ NOT NULL,
    updated_at TIMESTAMPTZ NOT NULL,
    stored_at TIMESTAMPTZ NOT NULL
);

CREATE TABLE access_right (
    id BIGINT NOT NULL PRIMARY KEY,
    user_id BIGINT NOT NULL REFERENCES user (id),
    doc_id BIGINT NOT NULL REFERENCES document (id),
    description TEXT NOT NULL,
    role TEXT NOT NULL
);

CREATE TABLE message (
    id BIGINT NOT NULL PRIMARY KEY,
    receiver_id BIGINT NOT NULL REFERENCES user (id),
    sender_id BIGINT NOT NULL REFERENCES user (id),
    doc_id BIGINT NOT NULL REFERENCES document (id),
    sending_date TIMESTAMPTZ NOT NULL,
    theme TEXT NOT NULL,
    message_text TEXT NOT NULL
);

Leave a Comment