Sha256: d6c68e60333c8f0021d80d3fe94d98eae78a5ed4d6133b6cb46b593cce7f4cef
Contents?: true
Size: 674 Bytes
Versions: 7
Compression:
Stored size: 674 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
7 entries across 7 versions & 2 rubygems