lib/torque/postgresql/adapter/schema_statements.rb in torque-postgresql-2.4.1 vs lib/torque/postgresql/adapter/schema_statements.rb in torque-postgresql-2.4.2
- old
+ new
@@ -31,13 +31,13 @@
#{quote_type_name(name, options[:schema])} #{force}
SQL
end
# Renames a type.
- def rename_type(type_name, new_name)
+ def rename_type(type_name, new_name, options = {})
execute <<-SQL.squish
- ALTER TYPE #{quote_type_name(type_name)}
+ ALTER TYPE #{quote_type_name(type_name, options[:schema])}
RENAME TO #{Quoting::Name.new(nil, new_name.to_s).quoted}
SQL
end
# Creates a new PostgreSQL enumerator type
@@ -98,9 +98,21 @@
options[:id] = false if options[:inherits].present? &&
options[:primary_key].blank? && options[:id].blank?
super table_name, **options, &block
+ end
+
+ # Simply add the schema to the table name when changing a table
+ def change_table(table_name, **options)
+ table_name = "#{options[:schema]}.#{table_name}" if options[:schema].present?
+ super table_name, **options
+ end
+
+ # Simply add the schema to the table name when dropping a table
+ def drop_table(table_name, **options)
+ table_name = "#{options[:schema]}.#{table_name}" if options[:schema].present?
+ super table_name, **options
end
# Add the schema option when extracting table options
def table_options(table_name)
parts = table_name.split('.').reverse