djezzzl/database_consistency

View on GitHub
rails6-example/db/migrate/20191012163954_create_users.rb

Summary

Maintainability
A
2 hrs
Test Coverage
class CreateUsers < ActiveRecord::Migration[6.0]
  def change
    create_table :users do |t|
      t.string :email, null: false
      t.string :name, null: false
      t.string :phone
      t.string :address
      t.string :code, null: false
      t.string :slug, null: false
      t.integer :company_id, null: false, limit: 8
      t.integer :country_id
      t.integer :organization_id, null: false
      t.integer :invitable_id, null: false
      t.string :invitable_type, null: false
      t.integer :subject_id, null: false
      t.string :subject_type

      t.timestamps

      t.foreign_key :countries
      t.index :slug, unique: true
      t.index :phone
      t.index %i[phone slug]
      t.index %i[name slug], unique: true
    end
  end
end