main
rb 19 lines 723 Bytes
Raw
1 # frozen_string_literal: true
2
3 # Per-user, per-billing-period count of siGit Code Cloud requests, used to enforce
4 # the plan's monthly allowance. `period_key` is the subscription's current-period
5 # marker, so the count resets automatically each billing cycle (a new period →
6 # a new row). On-device usage is never recorded here — it's free and unmetered.
7 class CreateCloudUsages < ActiveRecord::Migration[8.1]
8 def change
9 create_table :cloud_usages do |t|
10 t.references :user, null: false, foreign_key: true
11 t.string :period_key, null: false
12 t.integer :request_count, null: false, default: 0
13
14 t.timestamps
15 end
16
17 add_index :cloud_usages, %i[user_id period_key], unique: true
18 end
19 end