Files
erp_naurua/db/migrations/0021_stock_lot_documents.sql
T

19 lines
548 B
PL/PgSQL

BEGIN;
CREATE TABLE stock_lot_document (
id BIGSERIAL PRIMARY KEY,
stock_lot_id BIGINT NOT NULL REFERENCES stock_lot(id) ON DELETE CASCADE,
original_filename TEXT NOT NULL,
stored_filename TEXT NOT NULL,
mime_type TEXT NOT NULL,
size_bytes BIGINT NOT NULL,
comment TEXT,
uploaded_by TEXT NOT NULL,
uploaded_at TIMESTAMP NOT NULL DEFAULT NOW(),
CONSTRAINT chk_stock_lot_document_size CHECK (size_bytes > 0 AND size_bytes <= 52428800)
);
CREATE INDEX idx_stock_lot_document_lot ON stock_lot_document(stock_lot_id, id);
COMMIT;