From 2178cd44c59effb67cef0743064a75f5073c9f45 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Thu, 5 Oct 2017 17:09:00 +0200 Subject: [PATCH] Optimise gcp_clusters table schema --- db/migrate/20170924094327_create_gcp_clusters.rb | 16 ++++++++++------ db/schema.rb | 8 ++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/db/migrate/20170924094327_create_gcp_clusters.rb b/db/migrate/20170924094327_create_gcp_clusters.rb index 42171be7fc4..657dddcbbc4 100644 --- a/db/migrate/20170924094327_create_gcp_clusters.rb +++ b/db/migrate/20170924094327_create_gcp_clusters.rb @@ -3,13 +3,21 @@ class CreateGcpClusters < ActiveRecord::Migration def change create_table :gcp_clusters do |t| + # Order columns by best align scheme t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } t.references :user, foreign_key: { on_delete: :nullify } t.references :service, foreign_key: { on_delete: :nullify } + t.integer :status + t.integer :gcp_cluster_size, null: false - # General + # Timestamps + t.datetime_with_timezone :created_at, null: false + t.datetime_with_timezone :updated_at, null: false + + # Enable/disable t.boolean :enabled, default: true - t.integer :status + + # General t.text :status_reason # k8s integration specific @@ -28,14 +36,10 @@ class CreateGcpClusters < ActiveRecord::Migration t.string :gcp_project_id, null: false t.string :gcp_cluster_zone, null: false t.string :gcp_cluster_name, null: false - t.integer :gcp_cluster_size, null: false t.string :gcp_machine_type t.string :gcp_operation_id t.text :encrypted_gcp_token t.string :encrypted_gcp_token_iv - - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false end end end diff --git a/db/schema.rb b/db/schema.rb index 00a52c1dffe..5f8f4bb7d5e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -583,8 +583,11 @@ ActiveRecord::Schema.define(version: 20171004121444) do t.integer "project_id", null: false t.integer "user_id" t.integer "service_id" - t.boolean "enabled", default: true t.integer "status" + t.integer "gcp_cluster_size", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.boolean "enabled", default: true t.text "status_reason" t.string "project_namespace" t.string "endpoint" @@ -597,13 +600,10 @@ ActiveRecord::Schema.define(version: 20171004121444) do t.string "gcp_project_id", null: false t.string "gcp_cluster_zone", null: false t.string "gcp_cluster_name", null: false - t.integer "gcp_cluster_size", null: false t.string "gcp_machine_type" t.string "gcp_operation_id" t.text "encrypted_gcp_token" t.string "encrypted_gcp_token_iv" - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false end add_index "gcp_clusters", ["project_id"], name: "index_gcp_clusters_on_project_id", unique: true, using: :btree -- GitLab