summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-05-23 14:45:53 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-05-23 14:45:53 +0100
commit2fdf15dd9784dd9cef76ab62ea36a3d165fa9bec (patch)
tree442cfa0a2e939cefc35e85e2f17047e5c72a44fc
parentacdb7435dadc0b4efbe8da96873383cac4221a97 (diff)
downloadgitlab-ce-2fdf15dd9784dd9cef76ab62ea36a3d165fa9bec.tar.gz
Edits create_project_mirror_data to add the new columns when table already exists
-rw-r--r--db/migrate/20180502122856_create_project_mirror_data.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/db/migrate/20180502122856_create_project_mirror_data.rb b/db/migrate/20180502122856_create_project_mirror_data.rb
index d449f944844..d050ff1ca61 100644
--- a/db/migrate/20180502122856_create_project_mirror_data.rb
+++ b/db/migrate/20180502122856_create_project_mirror_data.rb
@@ -4,13 +4,17 @@ class CreateProjectMirrorData < ActiveRecord::Migration
DOWNTIME = false
def up
- return if table_exists?(:project_mirror_data)
-
- create_table :project_mirror_data do |t|
- t.references :project, index: true, foreign_key: { on_delete: :cascade }
- t.string :status
- t.string :jid
- t.text :last_error
+ if table_exists?(:project_mirror_data)
+ add_column :project_mirror_data, :status, :string unless column_exists?(:project_mirror_data, :status)
+ add_column :project_mirror_data, :jid, :string unless column_exists?(:project_mirror_data, :jid)
+ add_column :project_mirror_data, :last_error, :text unless column_exists?(:project_mirror_data, :last_error)
+ else
+ create_table :project_mirror_data do |t|
+ t.references :project, index: true, foreign_key: { on_delete: :cascade }
+ t.string :status
+ t.string :jid
+ t.text :last_error
+ end
end
end