31 lines
1 KiB
Elixir
31 lines
1 KiB
Elixir
defmodule Towerops.Repo.Migrations.AddBillingToOrganizations do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
alter table(:organizations) do
|
|
# Stripe customer and subscription IDs
|
|
add :stripe_customer_id, :string
|
|
add :stripe_subscription_id, :string
|
|
|
|
# Subscription status: "active", "past_due", "canceled", "incomplete"
|
|
add :subscription_status, :string
|
|
|
|
# Billing period tracking
|
|
add :subscription_current_period_start, :utc_datetime
|
|
add :subscription_current_period_end, :utc_datetime
|
|
|
|
# Payment method status: "valid", "missing", "requires_action"
|
|
add :payment_method_status, :string
|
|
|
|
# Last successful billing sync timestamp
|
|
add :last_billing_sync_at, :utc_datetime
|
|
|
|
# Device count at last sync (for debugging/reconciliation)
|
|
add :last_synced_device_count, :integer
|
|
end
|
|
|
|
create index(:organizations, [:stripe_customer_id])
|
|
create index(:organizations, [:stripe_subscription_id])
|
|
create index(:organizations, [:subscription_status])
|
|
end
|
|
end
|