chore: upload parte 2 - assets
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
-- Packing lists for shipping finished products
|
||||
CREATE TABLE IF NOT EXISTS packing_lists (
|
||||
id SERIAL PRIMARY KEY,
|
||||
packing_list_number VARCHAR(100) UNIQUE NOT NULL,
|
||||
purchase_order_id INTEGER NOT NULL REFERENCES purchase_orders(id),
|
||||
customer_id INTEGER NOT NULL REFERENCES customers(id),
|
||||
product_id INTEGER NOT NULL,
|
||||
quantity_shipped INTEGER NOT NULL DEFAULT 0,
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'finalized')),
|
||||
shipped_date DATE,
|
||||
notes TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Serial numbers for each packing list
|
||||
CREATE TABLE IF NOT EXISTS packing_list_serials (
|
||||
id SERIAL PRIMARY KEY,
|
||||
packing_list_id INTEGER NOT NULL REFERENCES packing_lists(id) ON DELETE CASCADE,
|
||||
serial_number VARCHAR(200) NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_packing_lists_po ON packing_lists(purchase_order_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_packing_lists_customer ON packing_lists(customer_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_packing_list_serials_pl ON packing_list_serials(packing_list_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_packing_list_serials_sn ON packing_list_serials(serial_number);
|
||||
|
||||
-- Add shipped_quantity column to purchase_order_items to track how many units have been shipped
|
||||
ALTER TABLE purchase_order_items ADD COLUMN IF NOT EXISTS shipped_quantity INTEGER NOT NULL DEFAULT 0;
|
||||
Reference in New Issue
Block a user