Files
member-console/internal/billing/migrations/00001_init.sql
Christian Galo 1f1540d7e0 Use plain DB connection for migrations
Add ConnectPlain to open the DB without the custom search_path and
switch migration and CLI flows to run on that plain connection.
Wrap multi-statement goose migrations with StatementBegin/End to
ensure statements are executed atomically. Move Stripe price outbox
seeding into a dedicated stripe migration.
2026-04-05 18:25:05 -05:00

39 lines
1.2 KiB
SQL

-- +goose Up
-- +goose StatementBegin
CREATE TABLE billing.products (
product_id UUID PRIMARY KEY DEFAULT uuidv7(),
name VARCHAR(255) NOT NULL,
description TEXT,
product_type VARCHAR(50) NOT NULL,
metadata JSONB,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
is_public BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_products_is_active ON billing.products(is_active);
CREATE INDEX idx_products_is_public ON billing.products(is_public);
CREATE TRIGGER trigger_products_updated_at
BEFORE UPDATE ON billing.products
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();
-- Per-schema role grants (Decision 115).
GRANT ALL ON ALL TABLES IN SCHEMA billing TO billing_owner;
GRANT ALL ON ALL TABLES IN SCHEMA billing TO billing_writer;
GRANT SELECT ON ALL TABLES IN SCHEMA billing TO billing_reader;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TRIGGER IF EXISTS trigger_products_updated_at ON billing.products;
DROP INDEX IF EXISTS billing.idx_products_is_public;
DROP INDEX IF EXISTS billing.idx_products_is_active;
DROP TABLE IF EXISTS billing.products;
-- +goose StatementEnd