forked from jakeonrails/fix-db-schema-conflicts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema_dumper.rb
44 lines (36 loc) · 882 Bytes
/
schema_dumper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'delegate'
module FixDBSchemaConflicts
module SchemaDumper
class ConnectionWithSorting < SimpleDelegator
def extensions
__getobj__.extensions.sort
end
def columns(table)
__getobj__.columns(table).sort_by(&:name)
end
def indexes(table)
__getobj__.indexes(table).sort_by(&:name)
end
def foreign_keys(table)
__getobj__.indexes(table).sort_by(&:name)
end
end
def extensions(*args)
with_sorting do
super(*args)
end
end
def table(*args)
with_sorting do
super(*args)
end
end
def with_sorting
old, @connection = @connection, ConnectionWithSorting.new(@connection)
result = yield
@connection = old
result
end
end
end
ActiveRecord::SchemaDumper.send(:prepend, FixDBSchemaConflicts::SchemaDumper)