8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/slonik_migration/extension.rb', line 8
def overwrite
ActiveRecord::Migrator.class_eval do
private
alias_method :orig_use_transaction?, :use_transaction?
def use_transaction?(migration)
false
end
end
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
alias_method :orig_execute, :execute
def execute(sql, name = nil)
if sql =~ /^create (table|sequence|view) "([^"]+)"/i
ret = SlonikMigration::Command.new.execute(sql, target: $1, name: $2)
raise "failed to execute slonik command." unless ret
elsif sql =~ /^(create|alter|drop)/i
ret = SlonikMigration::Command.new.execute(sql)
raise "failed to execute slonik command." unless ret
else
orig_execute sql, name
end
end
end
end
|