diff options
author | Micaël Bergeron <mbergeron@gitlab.com> | 2018-02-26 22:14:00 +0300 |
---|---|---|
committer | Micaël Bergeron <mbergeron@gitlab.com> | 2018-03-01 18:38:37 +0300 |
commit | 40a3b467f25df62fab4b92a3700846f06ef7534c (patch) | |
tree | 36a810dda2811035af976a89eb4756ff12245f48 /db | |
parent | e43d7d2b4d4ccae4e7c7c89b68b6dc3ae8f34bb7 (diff) |
add the Ci::Build `*_store` column
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20180222152310_port_object_storage_to_ce.rb | 42 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 23 insertions, 21 deletions
diff --git a/db/migrate/20180222152310_port_object_storage_to_ce.rb b/db/migrate/20180222152310_port_object_storage_to_ce.rb index aa1e15072b8..f2e2e53ed8c 100644 --- a/db/migrate/20180222152310_port_object_storage_to_ce.rb +++ b/db/migrate/20180222152310_port_object_storage_to_ce.rb @@ -7,31 +7,31 @@ class PortObjectStorageToCe < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false - def up - unless column_exists?(:ci_job_artifacts, :file_store) - add_column(:ci_job_artifacts, :file_store, :integer) - end - - unless column_exists?(:lfs_objects, :file_store) - add_column(:lfs_objects, :file_store, :integer) - end + def add_column_idempotent(table, column, *defs) + return if column_exists?(table, column) - unless column_exists?(:uploads, :store) - add_column(:uploads, :store, :integer) - end + add_column(table, column, *defs) end - def down - if column_exists?(:ci_job_artifacts, :file_store) - remove_column(:ci_job_artifacts, :file_store) - end + def remove_column_idempotent(table, column) + return unless column_exists?(table, column) + + remove_column(table, column) + end - if column_exists?(:lfs_objects, :file_store) - remove_column(:lfs_objects, :file_store) - end + def up + add_column_idempotent(:ci_job_artifacts, :file_store, :integer) + add_column_idempotent(:ci_builds, :artifacts_file_store, :integer) + add_column_idempotent(:ci_builds, :artifacts_metadata_store, :integer) + add_column_idempotent(:lfs_objects, :file_store, :integer) + add_column_idempotent(:uploads, :store, :integer) + end - if column_exists?(:uploads, :store) - remove_column(:uploads, :store) - end + def down + remove_column_idempotent(:ci_job_artifacts, :file_store) + remove_column_idempotent(:ci_builds, :artifacts_file_store) + remove_column_idempotent(:ci_builds, :artifacts_metadata_store) + remove_column_idempotent(:lfs_objects, :file_store) + remove_column_idempotent(:uploads, :store) end end diff --git a/db/schema.rb b/db/schema.rb index 74dbb11c89b..3af701d0ed9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -294,6 +294,8 @@ ActiveRecord::Schema.define(version: 20180222152310) do t.integer "artifacts_metadata_store", default: 1, null: false t.boolean "protected" t.integer "failure_reason" + t.integer "artifacts_file_store" + t.integer "artifacts_metadata_store" end add_index "ci_builds", ["artifacts_expire_at"], name: "index_ci_builds_on_artifacts_expire_at", where: "(artifacts_file <> ''::text)", using: :btree |