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