bmc_hub/migrations/235_delefiber_product_prices.sql

17 lines
797 B
MySQL
Raw Permalink Normal View History

-- Local standard selling prices for products offered from a shared/delefiber.
CREATE TABLE IF NOT EXISTS internet_connections_delefiber_product_prices (
id SERIAL PRIMARY KEY,
connection_id INTEGER NOT NULL REFERENCES internet_connections_connections(id) ON DELETE CASCADE,
product_id INTEGER NOT NULL REFERENCES products(id) ON DELETE RESTRICT,
monthly_price NUMERIC(12,2) NOT NULL CHECK (monthly_price >= 0),
notes TEXT,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE (connection_id, product_id)
);
CREATE INDEX IF NOT EXISTS idx_delefiber_product_prices_connection
ON internet_connections_delefiber_product_prices(connection_id)
WHERE is_active = TRUE;