lib/strong_migrations/checks.rb in strong_migrations-1.3.2 vs lib/strong_migrations/checks.rb in strong_migrations-1.4.0
- old
+ new
@@ -71,10 +71,18 @@
raise_error :add_column_json,
command: command_str("add_column", [table, column, :jsonb, options])
end
end
+ def check_add_exclusion_constraint(*args)
+ table = args[0]
+
+ unless new_table?(table)
+ raise_error :add_exclusion_constraint
+ end
+ end
+
# unlike add_index, we don't make an exception here for new tables
#
# with add_index, it's fine to lock a new table even after inserting data
# since the table won't be in use by the application
#
@@ -168,10 +176,11 @@
def check_change_column(*args)
options = args.extract_options!
table, column, type = args
safe = false
- existing_column = connection.columns(table).find { |c| c.name.to_s == column.to_s }
+ table_columns = connection.columns(table) rescue []
+ existing_column = table_columns.find { |c| c.name.to_s == column.to_s }
if existing_column
existing_type = existing_column.sql_type.sub(/\(\d+(,\d+)?\)/, "")
safe = adapter.change_type_safe?(table, column, type, options, existing_column, existing_type)
end