main
rb 24 lines 988 Bytes
Raw
1 # frozen_string_literal: true
2
3 # A siGit user's subscription. siGit Code is local-first and free; a paid plan
4 # unlocks siGit Code Cloud (the Fast/Balanced/Large tiers). Stripe is siGit's own
5 # — separate from Onde Inference's billing — and is the source of truth; this row
6 # caches plan + status so the cloud gate can decide without a Stripe round-trip.
7 class CreateSubscriptions < ActiveRecord::Migration[8.1]
8 def change
9 create_table :subscriptions do |t|
10 t.references :user, null: false, foreign_key: true, index: { unique: true }
11 t.integer :plan, null: false, default: 0 # free=0, pro=1, team=2
12 t.integer :status, null: false, default: 0 # active=0, past_due=1, canceled=2, trialing=3, incomplete=4
13
14 t.string :stripe_customer_id
15 t.string :stripe_subscription_id
16 t.datetime :current_period_end
17
18 t.timestamps
19 end
20
21 add_index :subscriptions, :stripe_customer_id
22 add_index :subscriptions, :stripe_subscription_id
23 end
24 end