CREATE TABLE IF NOT EXISTS produto_estoques (
    id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    produto_id BIGINT NOT NULL REFERENCES produtos(id),
    estoque_id BIGINT NOT NULL REFERENCES estoques(id),
    quantidade NUMERIC(18,6) NOT NULL DEFAULT 0,
    criado_em TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    atualizado_em TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (produto_id, estoque_id)
);
CREATE INDEX IF NOT EXISTS idx_produto_estoques_estoque ON produto_estoques (estoque_id);
