summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorKrasimir Angelov <kangelov@gitlab.com>2019-06-06 21:37:49 +1200
committerKrasimir Angelov <kangelov@gitlab.com>2019-06-18 11:09:15 +1200
commit03000c8f26e85f5bc8bbfe292af7ffd1bcc38d29 (patch)
tree066683f2351ad7bc56fe02fbdd2765f4be252326 /db/migrate
parent30bddd546f117043f2b7389ad06ba5257184c148 (diff)
downloadgitlab-ce-03000c8f26e85f5bc8bbfe292af7ffd1bcc38d29.tar.gz
Add migrations needed to encrypt feature flags client tokens57918-encrypt-feature-flags-tokens
Make plaintext token column not null, add new token_encrypted column and index on project_id & token_encrypted. Post deployment migration to encrypt existing tokens.
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20190606054649_change_operations_feature_flags_clients_token_not_null.rb11
-rw-r--r--db/migrate/20190606054742_add_token_encrypted_to_operations_feature_flags_clients.rb11
-rw-r--r--db/migrate/20190606054832_add_index_to_operations_feature_flags_clients_token_encrypted.rb18
3 files changed, 40 insertions, 0 deletions
diff --git a/db/migrate/20190606054649_change_operations_feature_flags_clients_token_not_null.rb b/db/migrate/20190606054649_change_operations_feature_flags_clients_token_not_null.rb
new file mode 100644
index 00000000000..c9dbb48f5bd
--- /dev/null
+++ b/db/migrate/20190606054649_change_operations_feature_flags_clients_token_not_null.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class ChangeOperationsFeatureFlagsClientsTokenNotNull < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ change_column_null :operations_feature_flags_clients, :token, true
+ end
+end
diff --git a/db/migrate/20190606054742_add_token_encrypted_to_operations_feature_flags_clients.rb b/db/migrate/20190606054742_add_token_encrypted_to_operations_feature_flags_clients.rb
new file mode 100644
index 00000000000..024b5bd2ba5
--- /dev/null
+++ b/db/migrate/20190606054742_add_token_encrypted_to_operations_feature_flags_clients.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddTokenEncryptedToOperationsFeatureFlagsClients < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :operations_feature_flags_clients, :token_encrypted, :string
+ end
+end
diff --git a/db/migrate/20190606054832_add_index_to_operations_feature_flags_clients_token_encrypted.rb b/db/migrate/20190606054832_add_index_to_operations_feature_flags_clients_token_encrypted.rb
new file mode 100644
index 00000000000..5627457af5c
--- /dev/null
+++ b/db/migrate/20190606054832_add_index_to_operations_feature_flags_clients_token_encrypted.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexToOperationsFeatureFlagsClientsTokenEncrypted < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :operations_feature_flags_clients, [:project_id, :token_encrypted],
+ unique: true, name: "index_feature_flags_clients_on_project_id_and_token_encrypted"
+ end
+
+ def down
+ remove_concurrent_index_by_name :operations_feature_flags_clients, "index_feature_flags_clients_on_project_id_and_token_encrypted"
+ end
+end