Chandan Jhunjhunwal
24-06-2017
https://github.com/indyarocks/
@ChandanJ
PostgreSQL & MySQL: Use big integer as
Add :default option to belongs_to
Use it to specify that an association should be initialized with a particular record before validation. For example:
# Before
belongs_to :account
before_validation -> { self.account ||= Current.account }
# After
belongs_to :account, default: -> { Current.account }
create_table :generated_columns do |t|
t.string :name
t.virtual :upper_name, type: :string, as: "UPPER(name)"
t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true
t.index :name_length # May be indexed, too!
end
#uniq, #uniq!, #unique_value, #insert_sql, #update_sql, and #delete_sql
create_table :generated_columns do |t|
t.string :name
t.virtual :upper_name, type: :string, as: "UPPER(name)"
t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true
t.index :name_length # May be indexed, too!
end
#uniq, #uniq!, #unique_value, #insert_sql, #update_sql, and #delete_sql