Add production defect and workstation foundation
This commit is contained in:
@@ -236,6 +236,43 @@ const initDB = async () => {
|
||||
);
|
||||
`);
|
||||
|
||||
await pool.query(`
|
||||
CREATE TABLE IF NOT EXISTS production_workstations (
|
||||
id SERIAL PRIMARY KEY,
|
||||
code VARCHAR(60) NOT NULL UNIQUE,
|
||||
name VARCHAR(160) NOT NULL,
|
||||
color VARCHAR(40) NOT NULL DEFAULT '#38bdf8',
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
`);
|
||||
await pool.query(`
|
||||
INSERT INTO production_workstations (code, name, color, sort_order)
|
||||
VALUES
|
||||
('cutting', 'Corte', '#fbbf24', 10),
|
||||
('sewing', 'Costura', '#38bdf8', 20),
|
||||
('review', 'Revisão', '#a78bfa', 30),
|
||||
('sac', 'SAC', '#fb7185', 40)
|
||||
ON CONFLICT (code) DO NOTHING;
|
||||
`);
|
||||
|
||||
await pool.query(`
|
||||
CREATE TABLE IF NOT EXISTS production_order_defects (
|
||||
id SERIAL PRIMARY KEY,
|
||||
production_order_id INTEGER NOT NULL REFERENCES production_orders(id) ON DELETE CASCADE,
|
||||
workstation_id INTEGER REFERENCES production_workstations(id) ON DELETE SET NULL,
|
||||
defect_type VARCHAR(160) NOT NULL,
|
||||
origin VARCHAR(160),
|
||||
quantity NUMERIC(14, 4) NOT NULL CHECK (quantity > 0),
|
||||
lot_code VARCHAR(120),
|
||||
notes TEXT,
|
||||
occurred_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
`);
|
||||
|
||||
await pool.query(`
|
||||
CREATE TABLE IF NOT EXISTS product_compositions (
|
||||
id SERIAL PRIMARY KEY,
|
||||
|
||||
Reference in New Issue
Block a user