lib/ridgepole/ext/schema_dumper.rb in ridgepole-0.7.0.beta18 vs lib/ridgepole/ext/schema_dumper.rb in ridgepole-0.7.0.beta19
- old
+ new
@@ -1,10 +1,27 @@
require 'active_record/schema_dumper'
module Ridgepole
module Ext
module SchemaDumper
+ def self.prepended(klass)
+ klass.extend ClassMethods
+ end
+
+ module ClassMethods
+ attr_reader :__with_default_fk_name
+
+ def with_default_fk_name(value)
+ @__with_default_fk_name = value
+ yield
+ ensure
+ remove_instance_variable(:@__with_default_fk_name)
+ end
+ end
+
def foreign_keys(table, stream)
+ return super unless self.class.__with_default_fk_name
+
if (foreign_keys = @connection.foreign_keys(table)).any?
add_foreign_key_statements = foreign_keys.map do |foreign_key|
parts = [
"add_foreign_key #{remove_prefix_and_suffix(foreign_key.from_table).inspect}",
remove_prefix_and_suffix(foreign_key.to_table).inspect,