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;