new-site/api/migrations/033_amb_and_client_selection.sql
justin f8cd37ac8c Initial commit — Performance West telecom compliance platform
Includes: API (Express/TypeScript), Astro site, Python workers,
document generators, FCC compliance tools, Canada CRTC formation,
Ansible infrastructure, and deployment scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 06:54:22 -05:00

34 lines
2.4 KiB
SQL

-- ═══════════════════════════════════════════════════════════════════════════════
-- 033: Anytime Mailbox locations + client selection columns
-- ═══════════════════════════════════════════════════════════════════════════════
-- Anytime Mailbox BC locations with live pricing (updated daily by scraper)
CREATE TABLE IF NOT EXISTS amb_locations (
id SERIAL PRIMARY KEY,
slug TEXT UNIQUE NOT NULL, -- e.g. "howe-st-vancouver"
name TEXT NOT NULL, -- e.g. "329 Howe St"
full_address TEXT NOT NULL, -- full street address line
city TEXT NOT NULL DEFAULT 'Vancouver',
province TEXT NOT NULL DEFAULT 'BC',
postal_code TEXT NOT NULL,
provider_url TEXT NOT NULL, -- AMB listing URL for scraping
plan_name TEXT DEFAULT 'Basic',
monthly_price_usd INTEGER NOT NULL DEFAULT 0, -- cents
yearly_price_usd INTEGER NOT NULL DEFAULT 0, -- cents (annual rate, used in orders)
is_active BOOLEAN DEFAULT TRUE,
available_units INTEGER DEFAULT -1, -- -1 = unknown, 0 = sold out, >0 = count
last_scraped_at TIMESTAMPTZ,
price_changed_at TIMESTAMPTZ,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Client-selected AMB location + unit + DID on CRTC orders
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS amb_location_slug TEXT;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS amb_annual_price_cents INTEGER DEFAULT 0;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS client_selected_unit TEXT;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS client_selected_did TEXT;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS funds_available BOOLEAN DEFAULT FALSE;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS funds_available_at TIMESTAMPTZ;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS stripe_topup_id TEXT;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS client_selection_email_sent_at TIMESTAMPTZ;