Commit e9eba6b1 authored by Douwe Maan's avatar Douwe Maan Committed by Douwe Maan

Don't add project_mirror_data columns that have already been added

In !5586, some `add_column` statements were moved between migrations.
If the original migrations were already run on a user's instance,
the new migrations would try to add the columns again.
parent df349b66
......@@ -5,9 +5,9 @@ class CreateProjectMirrorData < ActiveRecord::Migration
def up
if table_exists?(:project_mirror_data)
add_column :project_mirror_data, :status, :string
add_column :project_mirror_data, :jid, :string
add_column :project_mirror_data, :last_error, :text
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 }
......
......@@ -9,10 +9,10 @@ class CreateProjectMirrorDataEE < ActiveRecord::Migration
# When moving from CE to EE, project_mirror_data may already exist, but will
# not have all the required columns.
if table_exists?(:project_mirror_data)
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_with_timezone
add_column :project_mirror_data, :last_update_scheduled_at, :datetime_with_timezone
add_column :project_mirror_data, :next_execution_timestamp, :datetime_with_timezone
add_column_with_default :project_mirror_data, :retry_count, :integer, default: 0, allow_null: false unless column_exists?(:project_mirror_data, :retry_count)
add_column :project_mirror_data, :last_update_started_at, :datetime_with_timezone unless column_exists?(:project_mirror_data, :last_update_started_at)
add_column :project_mirror_data, :last_update_scheduled_at, :datetime_with_timezone unless column_exists?(:project_mirror_data, :last_update_scheduled_at)
add_column :project_mirror_data, :next_execution_timestamp, :datetime_with_timezone unless column_exists?(:project_mirror_data, :next_execution_timestamp)
else
execute <<-SQL
CREATE TABLE project_mirror_data
......
......@@ -10,8 +10,8 @@ class AddMissingColumnsToProjectMirrorData < ActiveRecord::Migration
disable_ddl_transaction!
def up
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_update_at, :datetime_with_timezone unless column_exists?(:project_mirror_data, :last_update_at)
add_column :project_mirror_data, :last_successful_update_at, :datetime_with_timezone unless column_exists?(:project_mirror_data, :last_successful_update_at)
end
def down
......
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