Yes, didn't think about this issue when exporting foreign key
constraints to schema.rb (which is new feature in 1.2.2 version of
adapter).
I created a fix (which moves all foreign key definitions after
creation of all tables) that will be included in next version of
oracle_enhanced adapter.
One option is that you can git clone repository from
github.com/rsim/
oracle-enhanced and then run "rake install_gem".
Other option is to include the following monkey patch in your Rails
application which will fix this issue:
module ActiveRecord
module ConnectionAdapters
module OracleEnhancedSchemaDumper
private
def tables_with_oracle_enhanced(stream)
sorted_tables = @connection.tables.sort
sorted_tables.each do |tbl|
# add table prefix or suffix for schema_migrations
next if [ActiveRecord::Migrator.proper_table_name
('schema_migrations'), ignore_tables].flatten.any? do |ignored|
case ignored
when String; tbl == ignored
when Regexp; tbl =~ ignored
else
raise StandardError,
'ActiveRecord::SchemaDumper.ignore_tables accepts an array of String
and / or Regexp values.'
end
end
# change table name inspect method
tbl.extend TableInspect
table(tbl, stream)
# add primary key trigger if table has it
primary_key_trigger(tbl, stream)
end
sorted_tables.each do |tbl|
# add foreign keys if table has them
foreign_keys(tbl, stream)
end
# add synonyms in local schema
synonyms(stream)
end
end
end
end