Commit c3a8d277 authored by Douwe Maan's avatar Douwe Maan

Ensure we use the same migration versions in CE and EE, and that CE can be upgraded to EE

parent 108e83ce
class CreateProjectMirrorDataCe < ActiveRecord::Migration
class CreateProjectMirrorData < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
......
class AddIndexesToProjectMirrorDataCe < ActiveRecord::Migration
class AddIndexesToProjectMirrorData < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
......
class CreateProjectMirrorData < ActiveRecord::Migration
class CreateProjectMirrorDataEE < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
......@@ -6,6 +6,10 @@ class CreateProjectMirrorData < ActiveRecord::Migration
disable_ddl_transaction!
def up
# When moving from CE to EE, project_mirror_data may already exist, but will
# not have all the required columns. These are added in AddMissingColumnsToProjectMirrorData.
return if table_exists?(:project_mirror_data)
execute <<-SQL
CREATE TABLE project_mirror_data
AS (
......
class MigrateImportAttributesFromProjectToProjectMirrorData < ActiveRecord::Migration
DOWNTIME = false
def up
add_column :project_mirror_data, :status, :string
add_column :project_mirror_data, :jid, :string
add_column :project_mirror_data, :last_update_at, :datetime_with_timezone
add_column :project_mirror_data, :last_successful_update_at, :datetime_with_timezone
add_column :project_mirror_data, :last_error, :text
end
def down
remove_column :project_mirror_data, :status
remove_column :project_mirror_data, :jid
remove_column :project_mirror_data, :last_update_at
remove_column :project_mirror_data, :last_successful_update_at
remove_column :project_mirror_data, :last_error
end
end
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class AddMissingColumnsToProjectMirrorData < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
# Columns missing when a CE instance is upgraded to EE
unless column_exists? :project_mirror_data, :retry_count
add_column_with_default :project_mirror_data, :retry_count, :integer, default: 0, allow_null: false
add_column :project_mirror_data, :last_update_started_at, :datetime
add_column :project_mirror_data, :last_update_scheduled_at, :datetime
add_column :project_mirror_data, :next_execution_timestamp, :datetime
end
# Columns missing on an EE instance
unless column_exists? :project_mirror_data, :status
add_column :project_mirror_data, :status, :string
add_column :project_mirror_data, :jid, :string
add_column :project_mirror_data, :last_update_at, :datetime_with_timezone
add_column :project_mirror_data, :last_successful_update_at, :datetime_with_timezone
add_column :project_mirror_data, :last_error, :text
end
end
def down
if column_exists? :project_mirror_data, :retry_count
remove_column :project_mirror_data, :retry_count
remove_column :project_mirror_data, :last_update_started_at
remove_column :project_mirror_data, :last_update_scheduled_at
remove_column :project_mirror_data, :next_execution_timestamp
end
if column_exists? :project_mirror_data, :status
remove_column :project_mirror_data, :status
remove_column :project_mirror_data, :jid
remove_column :project_mirror_data, :last_update_at
remove_column :project_mirror_data, :last_successful_update_at
remove_column :project_mirror_data, :last_error
end
end
end
class AddIndexesToProjectMirrorData < ActiveRecord::Migration
class AddIndexesToProjectMirrorDataEE < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
......@@ -7,13 +7,9 @@ class AddIndexesToProjectMirrorData < ActiveRecord::Migration
def up
add_concurrent_index :project_mirror_data, :last_successful_update_at
add_concurrent_index :project_mirror_data, :jid
add_concurrent_index :project_mirror_data, :status
end
def down
remove_index :project_mirror_data, :last_successful_update_at if index_exists? :project_mirror_data, :last_successful_update_at
remove_index :project_mirror_data, :jid if index_exists? :project_mirror_data, :jid
remove_index :project_mirror_data, :status if index_exists? :project_mirror_data, :status
end
end
require 'spec_helper'
describe Gitlab::BackgroundMigration::PopulateImportState, :migration, schema: 20180430144643 do
describe Gitlab::BackgroundMigration::PopulateImportState, :migration, schema: 20180502134117 do
let(:migration) { described_class.new }
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
......
require 'spec_helper'
describe Gitlab::BackgroundMigration::RollbackImportStateData, :migration, schema: 20180430144643 do
describe Gitlab::BackgroundMigration::RollbackImportStateData, :migration, schema: 20180502134117 do
let(:migration) { described_class.new }
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
......
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180430144643_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb')
require Rails.root.join('db', 'post_migrate', '20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb')
describe MigrateImportAttributesDataFromProjectsToProjectMirrorData, :sidekiq, :migration do
let(:namespaces) { table(:namespaces) }
......
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