-- Postgres schema for MyMafi dispatch data

CREATE TABLE IF NOT EXISTS orders (
    id SERIAL PRIMARY KEY,
    status VARCHAR(10) NOT NULL DEFAULT 'OPEN', -- OPEN, PLANNED, DONE
    art VARCHAR(50) NOT NULL,
    quelle VARCHAR(100),
    container VARCHAR(50),
    bemerkung VARCHAR(255),
    ziel VARCHAR(100),
    prio BOOLEAN DEFAULT FALSE,
    planned_at TIMESTAMP WITH TIME ZONE,
    erledigt_am TIMESTAMP WITH TIME ZONE,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_orders_status ON orders(status);
CREATE INDEX IF NOT EXISTS idx_orders_prio ON orders(prio);
