Files
member-console/internal/billing/migrations/00009_subscription_changes.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

28 lines
927 B
SQL

-- +goose Up
-- +goose StatementBegin
CREATE TABLE billing.subscription_changes (
change_id UUID PRIMARY KEY DEFAULT uuidv7(),
subscription_id UUID NOT NULL REFERENCES billing.subscriptions(subscription_id),
previous_status TEXT,
new_status TEXT NOT NULL,
stripe_event_id TEXT NOT NULL,
changed_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_subscription_changes_subscription_id ON billing.subscription_changes(subscription_id);
-- 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 INDEX IF EXISTS billing.idx_subscription_changes_subscription_id;
DROP TABLE IF EXISTS billing.subscription_changes;
-- +goose StatementEnd