Commit a68b0014 authored by Micaël Bergeron's avatar Micaël Bergeron

make the db migration idempotent

parent 272af7a2
...@@ -26,10 +26,14 @@ class AddFileStoreToLfsObjects < ActiveRecord::Migration ...@@ -26,10 +26,14 @@ class AddFileStoreToLfsObjects < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column(:lfs_objects, :file_store, :integer) unless column_exists?(:lfs_objects, :file_store)
add_column(:lfs_objects, :file_store, :integer)
end
end end
def down def down
remove_column(:lfs_objects, :file_store) if column_exists?(:lfs_objects, :file_store)
remove_column(:lfs_objects, :file_store)
end
end end
end end
...@@ -5,10 +5,14 @@ class AddFileStoreJobArtifacts < ActiveRecord::Migration ...@@ -5,10 +5,14 @@ class AddFileStoreJobArtifacts < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
def up def up
add_column(:ci_job_artifacts, :file_store, :integer) unless column_exists?(:ci_job_artifacts, :file_store)
add_column(:ci_job_artifacts, :file_store, :integer)
end
end end
def down def down
remove_column(:ci_job_artifacts, :file_store) if column_exists?(:ci_job_artifacts, :file_store)
remove_column(:ci_job_artifacts, :file_store)
end
end end
end end
...@@ -6,7 +6,15 @@ class AddStoreColumnToUploads < ActiveRecord::Migration ...@@ -6,7 +6,15 @@ class AddStoreColumnToUploads < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
def change def up
add_column :uploads, :store, :integer unless column.exists?(:uploads, :store)
add_column(:uploads, :store, :integer)
end
end
def down
if column.exists?(:uploads, :store)
remove_column(:uploads, :store)
end
end end
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