Files
telegram-bot-for-manipulate…/init_schemes.sql
ronis_0505 20aefeb110
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
add 'job_title' column to workers table
2025-08-26 22:04:13 +03:00

48 lines
1.3 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

CREATE TYPE job_title AS ENUM ('Начальник цеха','Мастер','Сборщик');
CREATE TYPE status AS ENUM ('Выполнено','В процессе','Создано','Ожидание комплектующих');
CREATE TABLE workers
(
id SERIAL PRIMARY KEY,
telegram_id BIGINT UNIQUE NOT NULL,
name VARCHAR NOT NULL,
email VARCHAR(50),
phone_number VARCHAR(20),
job_title job_title default 'Сборщик',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP
);
CREATE TABLE orders
(
id SERIAL PRIMARY KEY,
name VARCHAR,
worker_id BIGINT REFERENCES workers (telegram_id),
status_id status DEFAULT 'Создано',
counterparty VARCHAR(50),
customer VARCHAR NOT NULL,
commencement_work DATE,
end_work DATE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
description VARCHAR DEFAULT NULL
);
CREATE TABLE components
(
id SERIAL PRIMARY KEY,
name VARCHAR NOT NULL,
description VARCHAR NULL
);
CREATE TABLE order_components
(
id SERIAL PRIMARY KEY,
order_id INTEGER REFERENCES orders (id),
component_id INTEGER REFERENCES components (id),
quantity INTEGER DEFAULT 1
);