diff options
author | skv-headless <skv-headless@yandex.ru> | 2014-01-27 16:37:00 +0400 |
---|---|---|
committer | skv-headless <skv-headless@yandex.ru> | 2014-01-27 18:50:53 +0400 |
commit | 4125de5ef1c694f65b038b4a4b17de7adcdeef78 (patch) | |
tree | 7513e083b8e377470ef41c7edd8fdd3bf797abda /db/migrate | |
parent | 5221dbfee74e48f379bc06b2848a64243a76270c (diff) |
Fix merge_request_diffs migrations for postgresql
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20140122114406_migrate_mr_diffs.rb | 4 | ||||
-rw-r--r-- | db/migrate/20140122122549_remove_m_rdiff_fields.rb | 12 |
2 files changed, 11 insertions, 5 deletions
diff --git a/db/migrate/20140122114406_migrate_mr_diffs.rb b/db/migrate/20140122114406_migrate_mr_diffs.rb index 2cc5faaa851..1595e2b6472 100644 --- a/db/migrate/20140122114406_migrate_mr_diffs.rb +++ b/db/migrate/20140122114406_migrate_mr_diffs.rb @@ -1,8 +1,6 @@ class MigrateMrDiffs < ActiveRecord::Migration def self.up - execute "INSERT INTO merge_request_diffs ( merge_request_id ) SELECT id FROM merge_requests" - execute "UPDATE merge_requests mr, merge_request_diffs md SET md.st_commits = mr.st_commits WHERE md.merge_request_id = mr.id" - execute "UPDATE merge_requests mr, merge_request_diffs md SET md.st_diffs = mr.st_diffs WHERE md.merge_request_id = mr.id" + execute "INSERT INTO merge_request_diffs ( merge_request_id, st_commits, st_diffs ) SELECT id, st_commits, st_diffs FROM merge_requests" end def self.down diff --git a/db/migrate/20140122122549_remove_m_rdiff_fields.rb b/db/migrate/20140122122549_remove_m_rdiff_fields.rb index c27e649e9a3..8f863d85a68 100644 --- a/db/migrate/20140122122549_remove_m_rdiff_fields.rb +++ b/db/migrate/20140122122549_remove_m_rdiff_fields.rb @@ -7,7 +7,15 @@ class RemoveMRdiffFields < ActiveRecord::Migration def down add_column :merge_requests, :st_commits, :text, null: true, limit: 2147483647 add_column :merge_requests, :st_diffs, :text, null: true, limit: 2147483647 - execute "UPDATE merge_requests mr, merge_request_diffs md SET mr.st_commits = md.st_commits WHERE md.merge_request_id = mr.id" - execute "UPDATE merge_requests mr, merge_request_diffs md SET mr.st_diffs = md.st_diffs WHERE md.merge_request_id = mr.id" + + if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' + execute "UPDATE merge_requests mr + SET (st_commits, st_diffs) = (md.st_commits, md.st_diffs) + FROM merge_request_diffs md + WHERE md.merge_request_id = mr.id" + else + execute "UPDATE merge_requests mr, merge_request_diffs md SET mr.st_commits = md.st_commits WHERE md.merge_request_id = mr.id" + execute "UPDATE merge_requests mr, merge_request_diffs md SET mr.st_diffs = md.st_diffs WHERE md.merge_request_id = mr.id" + end end end |