diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-09-29 00:08:11 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-09-29 00:08:11 +0900 |
commit | bda1b0a878205ac99bf10c0b4f0e63f2d4e3a25f (patch) | |
tree | 09d5318034ed17966be0fa74a7a4e07fde0b2c05 /db | |
parent | fabc359e77c39aea86f0eaa9f19b17b2a609dd99 (diff) | |
download | gitlab-ce-bda1b0a878205ac99bf10c0b4f0e63f2d4e3a25f.tar.gz |
Databse foreing key, index, encrypt password. Use short path. Improve error handling. Polish.
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20170924094327_create_ci_clusters.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 15 |
2 files changed, 17 insertions, 15 deletions
diff --git a/db/migrate/20170924094327_create_ci_clusters.rb b/db/migrate/20170924094327_create_ci_clusters.rb index 33a67be46dc..2663130c7e6 100644 --- a/db/migrate/20170924094327_create_ci_clusters.rb +++ b/db/migrate/20170924094327_create_ci_clusters.rb @@ -3,9 +3,9 @@ class CreateCiClusters < ActiveRecord::Migration def up create_table :ci_clusters do |t| - t.integer :project_id - t.integer :owner_id - t.integer :service_id + t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } + t.references :user, null: false, foreign_key: true + t.references :service, foreign_key: true # General t.boolean :enabled, default: true @@ -14,11 +14,14 @@ class CreateCiClusters < ActiveRecord::Migration t.string :project_namespace # Cluster details - t.string :end_point + t.string :endpoint t.text :ca_cert t.string :token t.string :username t.string :password + t.string :encrypted_password + t.string :encrypted_password_salt + t.string :encrypted_password_iv # GKE t.string :gcp_project_id @@ -29,12 +32,6 @@ class CreateCiClusters < ActiveRecord::Migration t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :updated_at, null: false end - - # TODO: fk, index, attr_encrypted - - add_foreign_key :ci_clusters, :projects - add_foreign_key :ci_clusters, :users, column: :owner_id - add_foreign_key :ci_clusters, :services end def down diff --git a/db/schema.rb b/db/schema.rb index 0ebce995cfd..af5367113a2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -268,16 +268,19 @@ ActiveRecord::Schema.define(version: 20170924094327) do add_index "ci_builds", ["user_id"], name: "index_ci_builds_on_user_id", using: :btree create_table "ci_clusters", force: :cascade do |t| - t.integer "project_id" - t.integer "owner_id" + t.integer "project_id", null: false + t.integer "user_id", null: false t.integer "service_id" t.boolean "enabled", default: true t.string "project_namespace" - t.string "end_point" + t.string "endpoint" t.text "ca_cert" t.string "token" t.string "username" t.string "password" + t.string "encrypted_password" + t.string "encrypted_password_salt" + t.string "encrypted_password_iv" t.string "gcp_project_id" t.string "cluster_zone" t.string "cluster_name" @@ -286,6 +289,8 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.datetime "updated_at", null: false end + add_index "ci_clusters", ["project_id"], name: "index_ci_clusters_on_project_id", unique: true, using: :btree + create_table "ci_group_variables", force: :cascade do |t| t.string "key", null: false t.text "value" @@ -1704,9 +1709,9 @@ ActiveRecord::Schema.define(version: 20170924094327) do add_foreign_key "ci_builds", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_a2141b1522", on_delete: :nullify add_foreign_key "ci_builds", "ci_stages", column: "stage_id", name: "fk_3a9eaa254d", on_delete: :cascade add_foreign_key "ci_builds", "projects", name: "fk_befce0568a", on_delete: :cascade - add_foreign_key "ci_clusters", "projects" + add_foreign_key "ci_clusters", "projects", on_delete: :cascade add_foreign_key "ci_clusters", "services" - add_foreign_key "ci_clusters", "users", column: "owner_id" + add_foreign_key "ci_clusters", "users" add_foreign_key "ci_group_variables", "namespaces", column: "group_id", name: "fk_33ae4d58d8", on_delete: :cascade add_foreign_key "ci_pipeline_schedule_variables", "ci_pipeline_schedules", column: "pipeline_schedule_id", name: "fk_41c35fda51", on_delete: :cascade add_foreign_key "ci_pipeline_schedules", "projects", name: "fk_8ead60fcc4", on_delete: :cascade |