Sha256: a7d7af865ea8cb232569059d1e5f91d6d6e3a6c3ed0ce9d4bf642f363856b5ac
Contents?: true
Size: 676 Bytes
Versions: 12
Compression:
Stored size: 676 Bytes
Contents
class AddNotNullConstraintsForTimestampColumns < ActiveRecord::Migration def up set_timestamp_constraints :null => false unless $FFCRM_NEW_DATABASE end def down set_timestamp_constraints {} unless $FFCRM_NEW_DATABASE end private def set_timestamp_constraints(constraints) ActiveRecord::Base.connection.tables.each do |table| # If table has both timestamp columns, set not null constraints on both columns. if [:created_at, :updated_at].all? { |column| column_exists?(table, column) } [:created_at, :updated_at].each do |column| change_column table, column, :datetime, constraints end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems