Subscription Database Migration Plan

Tablo Birleştirme - Eksik/Fazla Field Analizi & Migration Planı

📅 2025-12-05 🎯 3 Tenant DB Analizi 🔧 Migration Hazır

⚠️ ÖNEMLİ: Deneme Aşamasındayız

Şu anda plan tablolarında veri olmasına gerek yok, denemeler yapıyoruz.

Hedef: Tüm tabloları aynı tarza/yapıya getirmek

Strateji: Manage sayfasında kullanılan field'leri baz alarak tüm DB'leri birleştirmek

✅ Manage Sayfası Analizi (Baz Yapı)

SubscriptionPlanManageComponent.php

Çoklu Dil Alanları (JSON):

  • title → JSON → {tr: "...", en: "..."}
  • description → JSON → {tr: "...", en: "..."}

Dil-Neutral Alanlar:

  • slug → string → unique
  • currency → string → TRY/USD/EUR
  • tax_rate → decimal(5,2) → %20.00
  • price_display_mode → enum → show/hide/request
  • device_limit → integer → 1,2,3...
  • is_featured → boolean
  • is_active → boolean

JSON Alanlar:

  • features → JSON array → ["fas fa-music|Özellik 1", ...]
  • billing_cycles → JSON → {1-aylik: {...}, 12-aylik: {...}}

Billing Cycles Yapısı:

  • label → {tr, en}
  • price → decimal
  • compare_price → decimal (nullable)
  • duration_days → integer
  • trial_days → integer (nullable)
  • badge → {text, color}
  • promo_text → {tr, en}
  • sort_order → integer

📊 3 Tenant Mevcut Durum

Central (tuufi_4ekim)

✅ VAR:

  • title, slug, description (JSON)
  • features (JSON)
  • currency, trial_days
  • device_limit
  • billing_cycles (JSON)
  • is_featured, is_active, is_public
  • sort_order

❌ EKSİK:

  • tax_rate
  • price_display_mode
  • is_trial (boolean)

⚠️ FAZLA (Kullanılmayan):

  • max_products, max_orders
  • max_storage_mb
  • custom_limits (JSON)
  • has_analytics
  • has_priority_support
  • has_api_access
  • enabled_features (JSON)
  • badge_text, highlight_color
  • terms, notes

Tenant 2 (ixtif.com)

✅ VAR:

  • title, slug, description (JSON)
  • features (JSON)
  • currency, currency_id
  • tax_rate ✅
  • price_display_mode ✅
  • trial_days, device_limit
  • billing_cycles (JSON)
  • is_featured, is_active

❌ EKSİK:

  • is_trial (boolean)
  • sort_order (sıralama için)

⚠️ FAZLA:

  • custom_limits, enabled_features
  • is_public, subscribers_count
  • metadata

Tenant 1001 (muzibu)

✅ VAR:

  • title, slug, description (JSON)
  • features (JSON)
  • currency
  • trial_days, device_limit
  • billing_cycles (JSON)
  • is_featured, is_active

❌ EKSİK:

  • tax_rate
  • price_display_mode
  • is_trial (boolean)
  • sort_order

⚠️ FAZLA (Legacy):

  • price_daily, price_weekly
  • price_monthly, price_quarterly
  • price_yearly
  • compare_price_monthly/yearly
  • has_trial (cycle bazlı - artık gereksiz)
  • requires_payment_method
  • default_billing_cycle

🎯 Hedef: Unified Tablo Yapısı

subscription_plans Standardı

✅ Tutulacak Field'ler (Manage Sayfası Kullanıyor):

Temel:

  • subscription_plan_id (PK)
  • title (JSON)
  • slug (unique)
  • description (JSON)

Pricing & Tax:

  • currency (TRY/USD/EUR)
  • tax_rate (decimal 5,2)
  • price_display_mode (enum)
  • billing_cycles (JSON)

Features:

  • features (JSON array)
  • device_limit (integer)
  • trial_days (integer) - global

Status & Display:

  • is_trial (boolean) ⭐ YENİ!
  • is_featured (boolean)
  • is_active (boolean)
  • sort_order (integer)

❌ Kaldırılacak Field'ler:

Legacy Pricing (Muzibu):

  • price_daily, price_weekly
  • price_monthly, price_quarterly, price_yearly
  • compare_price_monthly, compare_price_yearly
  • default_billing_cycle

Kullanılmayan (Central):

  • max_products, max_orders
  • max_storage_mb
  • custom_limits, enabled_features
  • has_analytics, has_priority_support
  • has_api_access
  • badge_text, highlight_color, terms, notes

➕ Eklenecek Field'ler:

  • 1. is_trial → boolean → default: false (Hangi plan trial planı?)
  • 2. tax_rate → decimal(5,2) → default: 20.00 (Central'da yok)
  • 3. price_display_mode → enum(show,hide,request) → default: show (Central'da yok)
  • 4. sort_order → integer → default: 0 (Muzibu'da yok)

👤 Users Tablosu (Central DB)

❌ Mevcut Durum

has_used_trial field'i YOK!

Kullanıcı trial kullandı mı kontrol edilemiyor.

✅ Hedef Yapı

has_used_trial eklenecek:

  • Type: boolean
  • Default: false
  • Nullable: false
  • Kullanıcı trial başlatınca → true
  • Ömür boyu değişmez

🔧 Migration Planı - Adım Adım

1

Central DB (tuufi_4ekim) - subscription_plans

➕ EKLE:

  • tax_rate → decimal(5,2) → default: 20.00
  • price_display_mode → enum(show,hide,request) → default: show
  • is_trial → boolean → default: false

❌ SİL:

  • max_products, max_orders, max_storage_mb
  • custom_limits, enabled_features
  • has_analytics, has_priority_support, has_api_access
  • badge_text, highlight_color, terms, notes
2

Tenant 2 (tenant_ixtif) - subscription_plans

➕ EKLE:

  • is_trial → boolean → default: false
  • sort_order → integer → default: 0

❌ SİL:

  • custom_limits, enabled_features
  • is_public, subscribers_count
  • metadata
3

Tenant 1001 (tenant_muzibu_1528d0) - subscription_plans

➕ EKLE:

  • tax_rate → decimal(5,2) → default: 20.00
  • price_display_mode → enum(show,hide,request) → default: show
  • is_trial → boolean → default: false
  • sort_order → integer → default: 0

❌ SİL (LEGACY):

  • price_daily, price_weekly, price_monthly
  • price_quarterly, price_yearly
  • compare_price_monthly, compare_price_yearly
  • has_trial (artık is_trial kullanılacak)
  • requires_payment_method
  • default_billing_cycle
  • max_products, max_orders, max_storage_mb
  • custom_limits, enabled_features
  • has_analytics, has_priority_support, has_api_access
4

Central DB (tuufi_4ekim) - users

➕ EKLE:

  • has_used_trial → boolean → default: false → nullable: false
  • Mevcut 8 kullanıcı için → default false set edilecek

🎉 Son Tablo Yapısı (3 DB Unified)

subscription_plans (Final Schema)

Temel Fields:

  • subscription_plan_id (PK, auto_increment)
  • title (JSON)
  • slug (unique)
  • description (JSON, nullable)
  • features (JSON, nullable)

Pricing & Currency:

  • currency (string, default: TRY)
  • tax_rate (decimal 5,2, default: 20.00)
  • price_display_mode (enum, default: show)
  • billing_cycles (JSON, nullable)

Limits & Features:

  • trial_days (integer, default: 0)
  • device_limit (integer, default: 1)

Status & Display:

  • is_trial (boolean, default: false) ⭐
  • is_featured (boolean, default: false)
  • is_active (boolean, default: true)
  • sort_order (integer, default: 0)

Timestamps:

  • created_at
  • updated_at
  • deleted_at (soft delete)

✅ Sonuç:

Central, İxtif, Muzibu - tüm DB'ler aynı yapıda! Manage sayfası sorunsuz çalışacak.