20171125024930_create_invites.rb 444 B

123456789101112131415
  1. class CreateInvites < ActiveRecord::Migration[5.1]
  2. def change
  3. create_table :invites do |t|
  4. t.belongs_to :user, foreign_key: { on_delete: :cascade }
  5. t.string :code, null: false, default: ''
  6. t.datetime :expires_at, null: true, default: nil
  7. t.integer :max_uses, null: true, default: nil
  8. t.integer :uses, null: false, default: 0
  9. t.timestamps
  10. end
  11. add_index :invites, :code, unique: true
  12. end
  13. end