Files
telegram-bot-for-manipulate…/init_schemes.sql
ronis_0505 c0f4be1179
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone Build is failing
change worker.telegram_id type (INTEGER>>BIGINT)
2025-07-28 23:48:33 +03:00

42 lines
1.2 KiB
SQL
Raw Permalink 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 TABLE workers
(
id SERIAL PRIMARY KEY,
telegram_id BIGINT UNIQUE NOT NULL,
name VARCHAR NOT NULL,
email VARCHAR(50),
phone_number VARCHAR(20) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP
);
CREATE TYPE status AS ENUM ('Выполнено','В процессе','Создано','Ожидание комплектующих');
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
);