summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-05-29 10:43:06 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-05-29 11:29:29 +0100
commit4a344a154949fc9ba72cd6e122fe4e24d952ff3f (patch)
treea93e02e87e51f9b35a5af0894ad8e7c1fb1c4c23
parentc5adf04cd69035a7a1737df8c2303bc228ea4089 (diff)
downloadgitlab-ce-4a344a154949fc9ba72cd6e122fe4e24d952ff3f.tar.gz
Adds migration to ensure all remote mirror columns get created
-rw-r--r--changelogs/unreleased/ensure-remote-mirror-columns-in-ce.yml5
-rw-r--r--db/migrate/20180529093006_ensure_remote_mirror_columns.rb24
-rw-r--r--db/schema.rb2
3 files changed, 30 insertions, 1 deletions
diff --git a/changelogs/unreleased/ensure-remote-mirror-columns-in-ce.yml b/changelogs/unreleased/ensure-remote-mirror-columns-in-ce.yml
new file mode 100644
index 00000000000..7617412431f
--- /dev/null
+++ b/changelogs/unreleased/ensure-remote-mirror-columns-in-ce.yml
@@ -0,0 +1,5 @@
+---
+title: Fix remote mirror database inconsistencies when upgrading from EE to CE
+merge_request: 19196
+author:
+type: fixed
diff --git a/db/migrate/20180529093006_ensure_remote_mirror_columns.rb b/db/migrate/20180529093006_ensure_remote_mirror_columns.rb
new file mode 100644
index 00000000000..290416cb61c
--- /dev/null
+++ b/db/migrate/20180529093006_ensure_remote_mirror_columns.rb
@@ -0,0 +1,24 @@
+class EnsureRemoteMirrorColumns < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column :remote_mirrors, :last_update_started_at, :datetime unless column_exists?(:remote_mirrors, :last_update_started_at)
+ add_column :remote_mirrors, :remote_name, :string unless column_exists?(:remote_mirrors, :remote_name)
+
+ unless column_exists?(:remote_mirrors, :only_protected_branches)
+ add_column_with_default(:remote_mirrors,
+ :only_protected_branches,
+ :boolean,
+ default: false,
+ allow_null: false)
+ end
+ end
+
+ def down
+ # db/migrate/20180503131624_create_remote_mirrors.rb will remove the table
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index a3e33c1d9aa..932b7f8da02 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180524132016) do
+ActiveRecord::Schema.define(version: 20180529093006) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"