Sha256: 2b0fedceb4a68f2f101da6a3ac08f23bdae2a3fcd4a7d5eca895d541ac3420dc
Contents?: true
Size: 677 Bytes
Versions: 8
Compression:
Stored size: 677 Bytes
Contents
class AddNotNullConstraintsForTimestampColumns < ActiveRecord::Migration[4.2] 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 %i[created_at updated_at].all? { |column| column_exists?(table, column) } %i[created_at updated_at].each do |column| change_column table, column, :datetime, constraints end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems