diff --git a/db/migrate/20170817123339_add_verification_status_to_gpg_signatures.rb b/db/migrate/20170817123339_add_verification_status_to_gpg_signatures.rb index d50277aa066edf5cf502379b2ec73a621050a3bb..126036a95d8fcb578efef705ab134a7a25c7e544 100644 --- a/db/migrate/20170817123339_add_verification_status_to_gpg_signatures.rb +++ b/db/migrate/20170817123339_add_verification_status_to_gpg_signatures.rb @@ -1,7 +1,28 @@ class AddVerificationStatusToGpgSignatures < ActiveRecord::Migration DOWNTIME = false - def change - add_column :gpg_signatures, :verification_status, :smallint + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + class GpgSignature < ActiveRecord::Base + self.table_name = 'gpg_signatures' + + include EachBatch + end + + def up + # First we remove all signatures because we need to re-verify them all + # again anyway (because of the updated verification logic). + # + # This makes adding the column with default values faster + GpgSignature.each_batch do |relation| + relation.delete_all + end + + add_column_with_default(:gpg_signatures, :verification_status, :smallint, default: 0) + end + + def down + remove_column(:gpg_signatures, :verification_status) end end diff --git a/db/schema.rb b/db/schema.rb index e2c602b000f249ce8a1fb8e5abeb9cb34e5e1e75..8db0d08016697d8894d343052963806b725323cd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -614,7 +614,7 @@ ActiveRecord::Schema.define(version: 20170830125940) do t.binary "gpg_key_primary_keyid" t.text "gpg_key_user_name" t.text "gpg_key_user_email" - t.integer "verification_status", limit: 2 + t.integer "verification_status", limit: 2, default: 0, null: false end add_index "gpg_signatures", ["commit_sha"], name: "index_gpg_signatures_on_commit_sha", unique: true, using: :btree