From 601c34654ef8b57fad2eedf7500525b1c2097590 Mon Sep 17 00:00:00 2001 From: nutcas3 Date: Wed, 29 Apr 2026 02:54:52 +0300 Subject: [PATCH] feat: Add goose database migrations for rating_plans and esim_profiles tables - Create 00001_init_rating_plans.sql migration with rating_plans table schema - Add plan_id, name, rate fields (data/voice/sms), monthly_fee, and limit fields (data/voice/sms) - Include is_active flag and timestamp fields (created_at, updated_at) - Add indexes on is_active and created_at columns - Create 00002_init_esim_profiles.sql migration with esim_profiles table schema - Add iccid (primary key), eid, imsi, mcc, mnc, profile_ --- migrations/00001_init_rating_plans.sql | 24 +++++++++++++++++++++++ migrations/00002_init_esim_profiles.sql | 26 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 migrations/00001_init_rating_plans.sql create mode 100644 migrations/00002_init_esim_profiles.sql diff --git a/migrations/00001_init_rating_plans.sql b/migrations/00001_init_rating_plans.sql new file mode 100644 index 0000000..b9032d3 --- /dev/null +++ b/migrations/00001_init_rating_plans.sql @@ -0,0 +1,24 @@ +-- +goose Up +-- Create rating_plans table +CREATE TABLE IF NOT EXISTS rating_plans ( + plan_id TEXT PRIMARY KEY, + name TEXT NOT NULL, + data_rate DOUBLE PRECISION NOT NULL, + voice_rate DOUBLE PRECISION NOT NULL, + sms_rate DOUBLE PRECISION NOT NULL, + monthly_fee DOUBLE PRECISION NOT NULL, + data_limit BIGINT NOT NULL, + voice_limit BIGINT NOT NULL, + sms_limit BIGINT NOT NULL, + is_active BOOLEAN NOT NULL DEFAULT TRUE, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +-- Create indexes +CREATE INDEX IF NOT EXISTS idx_rating_plans_is_active ON rating_plans(is_active); +CREATE INDEX IF NOT EXISTS idx_rating_plans_created_at ON rating_plans(created_at); + +-- +goose Down +-- Drop rating_plans table +DROP TABLE IF EXISTS rating_plans CASCADE; diff --git a/migrations/00002_init_esim_profiles.sql b/migrations/00002_init_esim_profiles.sql new file mode 100644 index 0000000..22f576f --- /dev/null +++ b/migrations/00002_init_esim_profiles.sql @@ -0,0 +1,26 @@ +-- +goose Up +-- Create esim_profiles table +CREATE TABLE IF NOT EXISTS esim_profiles ( + iccid TEXT PRIMARY KEY, + eid TEXT, + imsi TEXT, + mcc TEXT, + mnc TEXT, + profile_type TEXT, + state TEXT, + tenant_id TEXT, + activation_code TEXT, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +-- Create indexes +CREATE INDEX IF NOT EXISTS idx_esim_profiles_eid ON esim_profiles(eid); +CREATE INDEX IF NOT EXISTS idx_esim_profiles_imsi ON esim_profiles(imsi); +CREATE INDEX IF NOT EXISTS idx_esim_profiles_state ON esim_profiles(state); +CREATE INDEX IF NOT EXISTS idx_esim_profiles_tenant_id ON esim_profiles(tenant_id); +CREATE INDEX IF NOT EXISTS idx_esim_profiles_created_at ON esim_profiles(created_at); + +-- +goose Down +-- Drop esim_profiles table +DROP TABLE IF EXISTS esim_profiles CASCADE;