diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-01-22 16:22:47 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-01-22 16:22:47 +0400 |
commit | c983e8eb3d9cac01090b8657735544f71f891576 (patch) | |
tree | 632bedb0febc29d09e6885d0a788974eb4911b13 /db/migrate | |
parent | 1018cbdc803d56e6cae385aee97aa04752d3e3fb (diff) |
Create separate table to store Merge request commits/diffs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20140122112253_create_merge_request_diffs.rb | 12 | ||||
-rw-r--r-- | db/migrate/20140122114406_migrate_mr_diffs.rb | 11 |
2 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20140122112253_create_merge_request_diffs.rb b/db/migrate/20140122112253_create_merge_request_diffs.rb new file mode 100644 index 00000000000..f016ef0f061 --- /dev/null +++ b/db/migrate/20140122112253_create_merge_request_diffs.rb @@ -0,0 +1,12 @@ +class CreateMergeRequestDiffs < ActiveRecord::Migration + def change + create_table :merge_request_diffs do |t| + t.string :state, null: false, default: 'valid' + t.text :st_commits, null: true, limit: 2147483647 + t.text :st_diffs, null: true, limit: 2147483647 + t.integer :merge_request_id, null: false + + t.timestamps + end + end +end diff --git a/db/migrate/20140122114406_migrate_mr_diffs.rb b/db/migrate/20140122114406_migrate_mr_diffs.rb new file mode 100644 index 00000000000..2cc5faaa851 --- /dev/null +++ b/db/migrate/20140122114406_migrate_mr_diffs.rb @@ -0,0 +1,11 @@ +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" + end + + def self.down + MergeRequestDiff.delete_all + end +end |