Commit de724a7a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve db schema for merge request diffs

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent c983e8eb
class CreateMergeRequestDiffs < ActiveRecord::Migration class CreateMergeRequestDiffs < ActiveRecord::Migration
def change def change
create_table :merge_request_diffs do |t| create_table :merge_request_diffs do |t|
t.string :state, null: false, default: 'valid' t.string :state, null: false, default: 'collected'
t.text :st_commits, null: true, limit: 2147483647 t.text :st_commits, null: true, limit: 2147483647
t.text :st_diffs, null: true, limit: 2147483647 t.text :st_diffs, null: true, limit: 2147483647
t.integer :merge_request_id, null: false t.integer :merge_request_id, null: false
......
class RemoveMRdiffFields < ActiveRecord::Migration
def up
remove_column :merge_requests, :st_commits
remove_column :merge_requests, :st_diffs
end
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"
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140122114406) do ActiveRecord::Schema.define(version: 20140122122549) do
create_table "broadcast_messages", force: true do |t| create_table "broadcast_messages", force: true do |t|
t.text "message", null: false t.text "message", null: false
...@@ -96,7 +96,7 @@ ActiveRecord::Schema.define(version: 20140122114406) do ...@@ -96,7 +96,7 @@ ActiveRecord::Schema.define(version: 20140122114406) do
add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree
create_table "merge_request_diffs", force: true do |t| create_table "merge_request_diffs", force: true do |t|
t.string "state", default: "valid", null: false t.string "state", default: "collected", null: false
t.text "st_commits", limit: 2147483647 t.text "st_commits", limit: 2147483647
t.text "st_diffs", limit: 2147483647 t.text "st_diffs", limit: 2147483647
t.integer "merge_request_id", null: false t.integer "merge_request_id", null: false
...@@ -113,8 +113,6 @@ ActiveRecord::Schema.define(version: 20140122114406) do ...@@ -113,8 +113,6 @@ ActiveRecord::Schema.define(version: 20140122114406) do
t.string "title" t.string "title"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.text "st_commits", limit: 2147483647
t.text "st_diffs", limit: 2147483647
t.integer "milestone_id" t.integer "milestone_id"
t.string "state" t.string "state"
t.string "merge_status" t.string "merge_status"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment