summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-07-03 15:30:22 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-07-13 12:10:26 +0200
commit1c57a4b92b66b91f4defd569666bed6f2d7a4428 (patch)
tree627a6e4f85ce39d1e0043888fd27b64ef6662529 /db
parent73e3a6ad5944a1b4ead4a6d6a5c3cee45a5449e1 (diff)
downloadgitlab-ci-1c57a4b92b66b91f4defd569666bed6f2d7a4428.tar.gz
Encrypt variables with attr_encrypted
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20150703125244_add_encrypted_value_to_variables.rb7
-rw-r--r--db/migrate/20150703125325_encrypt_variables.rb10
-rw-r--r--db/schema.rb5
3 files changed, 21 insertions, 1 deletions
diff --git a/db/migrate/20150703125244_add_encrypted_value_to_variables.rb b/db/migrate/20150703125244_add_encrypted_value_to_variables.rb
new file mode 100644
index 0000000..0adf31a
--- /dev/null
+++ b/db/migrate/20150703125244_add_encrypted_value_to_variables.rb
@@ -0,0 +1,7 @@
+class AddEncryptedValueToVariables < ActiveRecord::Migration
+ def change
+ add_column :variables, :encrypted_value, :text
+ add_column :variables, :encrypted_value_salt, :string
+ add_column :variables, :encrypted_value_iv, :string
+ end
+end
diff --git a/db/migrate/20150703125325_encrypt_variables.rb b/db/migrate/20150703125325_encrypt_variables.rb
new file mode 100644
index 0000000..c5f9d04
--- /dev/null
+++ b/db/migrate/20150703125325_encrypt_variables.rb
@@ -0,0 +1,10 @@
+class EncryptVariables < ActiveRecord::Migration
+ def up
+ Variable.find_each do |variable|
+ variable.update(value: variable.read_attribute(:value)) unless variable.encrypted_value
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6b88c7f..6686465 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -177,9 +177,12 @@ ActiveRecord::Schema.define(version: 20150707134456) do
add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
create_table "variables", force: true do |t|
- t.integer "project_id", null: false
+ t.integer "project_id", null: false
t.string "key"
t.text "value"
+ t.text "encrypted_value"
+ t.string "encrypted_value_salt"
+ t.string "encrypted_value_iv"
end
add_index "variables", ["project_id"], name: "index_variables_on_project_id", using: :btree