20171125024930_create_invites.rb 475 B

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