lib/strong_migrations/checks.rb in strong_migrations-1.7.0 vs lib/strong_migrations/checks.rb in strong_migrations-1.8.0
- old
+ new
@@ -40,13 +40,11 @@
# Also, Active Record has special case for uuid columns that allows function default values
# https://github.com/rails/rails/blob/v7.0.3.1/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb#L92-L93
if options.key?(:default) && (!adapter.add_column_default_safe? || (volatile = (postgresql? && type.to_s == "uuid" && default.to_s.include?("()") && adapter.default_volatile?(default))))
if options[:null] == false
options = options.except(:null)
- append = "
-
-Then add the NOT NULL constraint in separate migrations."
+ append = "\n\nThen add the NOT NULL constraint in separate migrations."
end
if default.nil?
raise_error :add_column_default_null,
command: command_str("add_column", [table, column, type, options.except(:default)]),
@@ -76,10 +74,17 @@
end
if type.to_s == "virtual" && options[:stored]
raise_error :add_column_generated_stored, rewrite_blocks: adapter.rewrite_blocks
end
+
+ if adapter.auto_incrementing_types.include?(type.to_s)
+ append = (mysql? || mariadb?) ? "\n\nIf using statement-based replication, this can also generate different values on replicas." : ""
+ raise_error :add_column_auto_incrementing,
+ rewrite_blocks: adapter.rewrite_blocks,
+ append: append
+ end
end
def check_add_exclusion_constraint(*args)
table = args[0]
@@ -163,13 +168,11 @@
throw :safe
end
if options.delete(:foreign_key)
headline = "Adding a foreign key blocks writes on both tables."
- append = "
-
-Then add the foreign key in separate migrations."
+ append = "\n\nThen add the foreign key in separate migrations."
else
headline = "Adding an index non-concurrently locks the table."
end
raise_error :add_reference,
@@ -351,10 +354,10 @@
cols << "#{reference}_type" if options[:polymorphic]
cols << "#{reference}_id"
cols
end
- code = "self.ignored_columns = #{columns.inspect}"
+ code = "self.ignored_columns += #{columns.inspect}"
raise_error :remove_column,
model: args[0].to_s.classify,
code: code,
command: command_str(method, args),