Commit 1848f2c1 authored by Stan Hu's avatar Stan Hu

Merge branch 'dm-remote-mirrors-migrations-ce-to-ee' into 'master'

Merge new CE remote_mirror migrations into EE, and disable ones that are already in EE

See merge request gitlab-org/gitlab-ee!5606
parents 1d07c6c0 2a0d0309
class CreateRemoteMirrors < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
return if table_exists?(:remote_mirrors)
create_table :remote_mirrors do |t|
t.references :project, index: true, foreign_key: { on_delete: :cascade }
t.string :url
t.boolean :enabled, default: true
t.string :update_status
t.datetime :last_update_at
t.datetime :last_successful_update_at
t.datetime :last_update_started_at
t.string :last_error
t.boolean :only_protected_branches, default: false, null: false
t.string :remote_name
t.text :encrypted_credentials
t.string :encrypted_credentials_iv
t.string :encrypted_credentials_salt
t.timestamps null: false
end
end
def down
# ee/db/migrate/20160321161032_create_remote_mirrors_ee.rb will remove the table
end
end
......@@ -6,10 +6,10 @@ class AddRemoteMirrorAvailableOverriddenToProjects < ActiveRecord::Migration
disable_ddl_transaction!
def up
add_column(:projects, :remote_mirror_available_overridden, :boolean)
add_column(:projects, :remote_mirror_available_overridden, :boolean) unless column_exists?(:projects, :remote_mirror_available_overridden)
end
def down
remove_column(:projects, :remote_mirror_available_overridden)
# ee/db/migrate/20171017130239_add_remote_mirror_available_overridden_to_projects_ee.rb will remove the column.
end
end
class AddIndexesToRemoteMirror < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :remote_mirrors, :last_successful_update_at unless index_exists?(:remote_mirrors, :last_successful_update_at)
end
def down
# ee/db/migrate/20170208144550_add_index_to_mirrors_last_update_at_fields.rb will remove the index.
end
end
class AddMirrorAvailableToApplicationSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:application_settings, :mirror_available, :boolean, default: true, allow_null: false) unless column_exists?(:application_settings, :mirror_available)
end
def down
# ee/db/migrate/20171017125928_add_remote_mirror_available_to_application_settings.rb will remove the column.
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180503175054) do
ActiveRecord::Schema.define(version: 20180503193953) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......
# rubocop:disable Migration/Datetime
# rubocop:disable Migration/Timestamps
class CreateRemoteMirrors < ActiveRecord::Migration
def change
class CreateRemoteMirrorsEE < ActiveRecord::Migration
def up
# When moving from CE to EE, remote_mirrors may already exist
return if table_exists?(:remote_mirrors)
create_table :remote_mirrors do |t|
t.references :project, index: true, foreign_key: true
t.string :url
......@@ -17,4 +20,8 @@ class CreateRemoteMirrors < ActiveRecord::Migration
t.timestamps null: false
end
end
def down
drop_table :remote_mirrors if table_exists?(:remote_mirrors)
end
end
......@@ -7,8 +7,8 @@ class AddIndexToMirrorsLastUpdateAtFields < ActiveRecord::Migration
disable_ddl_transaction!
def up
add_concurrent_index :projects, :mirror_last_successful_update_at
add_concurrent_index :remote_mirrors, :last_successful_update_at
add_concurrent_index :projects, :mirror_last_successful_update_at unless index_exists? :projects, :mirror_last_successful_update_at
add_concurrent_index :remote_mirrors, :last_successful_update_at unless index_exists? :remote_mirrors, :last_successful_update_at
end
def down
......
......@@ -4,7 +4,14 @@ class AddLastUpdateStartedAtColumnToRemoteMirrors < ActiveRecord::Migration
DOWNTIME = false
def change
def up
# When moving from CE to EE, this column may already exist
return if column_exists?(:remote_mirrors, :last_update_started_at)
add_column :remote_mirrors, :last_update_started_at, :datetime
end
def down
remove_column :remote_mirrors, :last_update_started_at
end
end
......@@ -6,6 +6,9 @@ class AddRemoteMirrorAvailableToApplicationSettings < ActiveRecord::Migration
disable_ddl_transaction!
def up
# When moving from CE to EE, this column may already exist
return if column_exists?(:application_settings, :remote_mirror_available)
add_column_with_default(:application_settings, :remote_mirror_available, :boolean, default: true, allow_null: false)
end
......
class AddRemoteMirrorAvailableOverriddenToProjectsEE < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
# When moving from CE to EE, this column may already exist
return if column_exists?(:projects, :remote_mirror_available_overridden)
add_column(:projects, :remote_mirror_available_overridden, :boolean)
end
def down
remove_column(:projects, :remote_mirror_available_overridden)
end
end
......@@ -3,7 +3,14 @@ class AddRemoteNameToRemoteMirrors < ActiveRecord::Migration
DOWNTIME = false
def change
def up
# When moving from CE to EE, this column may already exist
return if column_exists?(:remote_mirrors, :remote_name)
add_column :remote_mirrors, :remote_name, :string
end
def down
remove_column :remote_mirrors, :remote_name
end
end
......@@ -7,11 +7,11 @@ class RemoveSyncTimeColumnFromRemoteMirrors < ActiveRecord::Migration
def up
remove_concurrent_index :remote_mirrors, [:sync_time] if index_exists? :remote_mirrors, [:sync_time]
remove_column :remote_mirrors, :sync_time, :integer
remove_column :remote_mirrors, :sync_time, :integer if column_exists? :remote_mirrors, :sync_time
end
def down
add_column :remote_mirrors, :sync_time, :integer
add_concurrent_index :remote_mirrors, [:sync_time]
add_column :remote_mirrors, :sync_time, :integer unless column_exists? :remote_mirrors, :sync_time
add_concurrent_index :remote_mirrors, [:sync_time] unless index_exists? :remote_mirrors, [:sync_time]
end
end
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