Files
telecom-platform/migrations/00017_init_transactions.sql
nutcas3 e6450f15ad feat: Add comprehensive database schema migrations for all platform tables
- Add subscribers table with IMSI, MSISDN, authentication keys, and eSIM profile fields
- Add service_plans table for data/voice/SMS limits and QoS parameters (ARPA, AMBR)
- Add sessions table for tracking PDU sessions with QoS and usage metrics
- Add usage_records table for billing and charging data
- Add users table with role-based access control fields
- Add roles, permissions, and role_permissions junction table for RBAC
- Add auth
2026-04-29 03:25:28 +03:00

26 lines
945 B
SQL

-- +goose Up
-- Create transactions table
CREATE TABLE IF NOT EXISTS transactions (
id SERIAL PRIMARY KEY,
subscriber_id INTEGER NOT NULL,
transaction_id TEXT NOT NULL,
type TEXT NOT NULL,
amount DOUBLE PRECISION NOT NULL,
currency TEXT NOT NULL,
status TEXT NOT NULL,
description TEXT,
parent_id INTEGER,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Create indexes
CREATE INDEX IF NOT EXISTS idx_transactions_subscriber_id ON transactions(subscriber_id);
CREATE INDEX IF NOT EXISTS idx_transactions_transaction_id ON transactions(transaction_id);
CREATE INDEX IF NOT EXISTS idx_transactions_status ON transactions(status);
CREATE INDEX IF NOT EXISTS idx_transactions_created_at ON transactions(created_at);
-- +goose Down
-- Drop transactions table
DROP TABLE IF EXISTS transactions CASCADE;