From b9287208523e1a5c05939fe0db038df51a9082fc Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Wed, 30 Aug 2017 16:57:50 +0200 Subject: Support discussion locking in the backend --- .../20161207221154_add_dicussion_locked_to_issuable.rb | 16 ++++++++++++++++ db/schema.rb | 2 ++ 2 files changed, 18 insertions(+) create mode 100644 db/migrate/20161207221154_add_dicussion_locked_to_issuable.rb (limited to 'db') diff --git a/db/migrate/20161207221154_add_dicussion_locked_to_issuable.rb b/db/migrate/20161207221154_add_dicussion_locked_to_issuable.rb new file mode 100644 index 00000000000..bb60ac2a410 --- /dev/null +++ b/db/migrate/20161207221154_add_dicussion_locked_to_issuable.rb @@ -0,0 +1,16 @@ +class AddDicussionLockedToIssuable < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + disable_ddl_transaction! + + def up + add_column(:merge_requests, :discussion_locked, :boolean) + add_column(:issues, :discussion_locked, :boolean) + end + + def down + remove_column(:merge_requests, :discussion_locked) + remove_column(:issues, :discussion_locked) + end +end diff --git a/db/schema.rb b/db/schema.rb index 2149f5ad23d..16f38f7b60b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -660,6 +660,7 @@ ActiveRecord::Schema.define(version: 20170905112933) do t.integer "cached_markdown_version" t.datetime "last_edited_at" t.integer "last_edited_by_id" + t.boolean "discussion_locked", default: false, null: false end add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree @@ -882,6 +883,7 @@ ActiveRecord::Schema.define(version: 20170905112933) do t.integer "head_pipeline_id" t.boolean "ref_fetched" t.string "merge_jid" + t.boolean "discussion_locked", default: false, null: false end add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree -- cgit v1.2.1 From 994e7d135947ca162c147c5e0992a0190de22808 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Fri, 1 Sep 2017 14:03:57 +0200 Subject: Create system notes for MR too, improve doc + clean up code --- .../20161207221154_add_dicussion_locked_to_issuable.rb | 16 ---------------- .../20170815221154_add_discussion_locked_to_issuable.rb | 13 +++++++++++++ db/schema.rb | 4 ++-- 3 files changed, 15 insertions(+), 18 deletions(-) delete mode 100644 db/migrate/20161207221154_add_dicussion_locked_to_issuable.rb create mode 100644 db/migrate/20170815221154_add_discussion_locked_to_issuable.rb (limited to 'db') diff --git a/db/migrate/20161207221154_add_dicussion_locked_to_issuable.rb b/db/migrate/20161207221154_add_dicussion_locked_to_issuable.rb deleted file mode 100644 index bb60ac2a410..00000000000 --- a/db/migrate/20161207221154_add_dicussion_locked_to_issuable.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddDicussionLockedToIssuable < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - disable_ddl_transaction! - - def up - add_column(:merge_requests, :discussion_locked, :boolean) - add_column(:issues, :discussion_locked, :boolean) - end - - def down - remove_column(:merge_requests, :discussion_locked) - remove_column(:issues, :discussion_locked) - end -end diff --git a/db/migrate/20170815221154_add_discussion_locked_to_issuable.rb b/db/migrate/20170815221154_add_discussion_locked_to_issuable.rb new file mode 100644 index 00000000000..5bd777c53a0 --- /dev/null +++ b/db/migrate/20170815221154_add_discussion_locked_to_issuable.rb @@ -0,0 +1,13 @@ +class AddDiscussionLockedToIssuable < ActiveRecord::Migration + DOWNTIME = false + + def up + add_column(:merge_requests, :discussion_locked, :boolean) + add_column(:issues, :discussion_locked, :boolean) + end + + def down + remove_column(:merge_requests, :discussion_locked) + remove_column(:issues, :discussion_locked) + end +end diff --git a/db/schema.rb b/db/schema.rb index 16f38f7b60b..6cdf929b1b6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -660,7 +660,7 @@ ActiveRecord::Schema.define(version: 20170905112933) do t.integer "cached_markdown_version" t.datetime "last_edited_at" t.integer "last_edited_by_id" - t.boolean "discussion_locked", default: false, null: false + t.boolean "discussion_locked" end add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree @@ -883,7 +883,7 @@ ActiveRecord::Schema.define(version: 20170905112933) do t.integer "head_pipeline_id" t.boolean "ref_fetched" t.string "merge_jid" - t.boolean "discussion_locked", default: false, null: false + t.boolean "discussion_locked" end add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree -- cgit v1.2.1 From 579092f53aa1a27e8d60bd70e12bed19123e24e7 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Thu, 14 Sep 2017 12:06:11 +0100 Subject: Remove discussion_lock --- db/schema.rb | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 6cdf929b1b6..ceaa7a7deea 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -32,8 +32,8 @@ ActiveRecord::Schema.define(version: 20170905112933) do t.text "description", null: false t.string "header_logo" t.string "logo" - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.text "description_html" t.integer "cached_markdown_version" end @@ -275,8 +275,8 @@ ActiveRecord::Schema.define(version: 20170905112933) do t.string "encrypted_value_iv" t.integer "group_id", null: false t.boolean "protected", default: false, null: false - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "ci_group_variables", ["group_id", "key"], name: "index_ci_group_variables_on_group_id_and_key", unique: true, using: :btree @@ -288,8 +288,8 @@ ActiveRecord::Schema.define(version: 20170905112933) do t.string "encrypted_value_salt" t.string "encrypted_value_iv" t.integer "pipeline_schedule_id", null: false - t.datetime_with_timezone "created_at" - t.datetime_with_timezone "updated_at" + t.datetime "created_at" + t.datetime "updated_at" end add_index "ci_pipeline_schedule_variables", ["pipeline_schedule_id", "key"], name: "index_ci_pipeline_schedule_variables_on_schedule_id_and_key", unique: true, using: :btree @@ -537,8 +537,8 @@ ActiveRecord::Schema.define(version: 20170905112933) do t.integer "project_id" t.integer "author_id", null: false t.integer "target_id" - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "action", limit: 2, null: false t.string "target_type" end @@ -576,8 +576,8 @@ ActiveRecord::Schema.define(version: 20170905112933) do add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree create_table "gpg_keys", force: :cascade do |t| - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "user_id" t.binary "primary_keyid" t.binary "fingerprint" @@ -589,8 +589,8 @@ ActiveRecord::Schema.define(version: 20170905112933) do add_index "gpg_keys", ["user_id"], name: "index_gpg_keys_on_user_id", using: :btree create_table "gpg_signatures", force: :cascade do |t| - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "project_id" t.integer "gpg_key_id" t.binary "commit_sha" @@ -789,8 +789,8 @@ ActiveRecord::Schema.define(version: 20170905112933) do add_index "members", ["user_id"], name: "index_members_on_user_id", using: :btree create_table "merge_request_diff_commits", id: false, force: :cascade do |t| - t.datetime_with_timezone "authored_date" - t.datetime_with_timezone "committed_date" + t.datetime "authored_date" + t.datetime "committed_date" t.integer "merge_request_diff_id", null: false t.integer "relative_order", null: false t.binary "sha", null: false @@ -1114,8 +1114,8 @@ ActiveRecord::Schema.define(version: 20170905112933) do create_table "project_auto_devops", force: :cascade do |t| t.integer "project_id", null: false - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "enabled" t.string "domain" end -- cgit v1.2.1 From f9f467227538df0ce2012df39dfdcf55fb260f94 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Mon, 4 Sep 2017 19:23:33 +0200 Subject: Send a confirmation email when the user adds a secondary email address. Utilizes the Devise `confirmable` capabilities. Issue #37385 --- .../20170904092148_add_email_confirmation.rb | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 db/migrate/20170904092148_add_email_confirmation.rb (limited to 'db') diff --git a/db/migrate/20170904092148_add_email_confirmation.rb b/db/migrate/20170904092148_add_email_confirmation.rb new file mode 100644 index 00000000000..b4c574b6a99 --- /dev/null +++ b/db/migrate/20170904092148_add_email_confirmation.rb @@ -0,0 +1,34 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddEmailConfirmation < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index", "remove_concurrent_index" or + # "add_column_with_default" you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + + def change + add_column :emails, :confirmation_token, :string + add_column :emails, :confirmed_at, :datetime + add_column :emails, :confirmation_sent_at, :datetime + add_index :emails, :confirmation_token, unique: true + end +end -- cgit v1.2.1 From 86698c960bb95e51bc6141b361ba3f1ee79abcdf Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Sat, 9 Sep 2017 11:05:59 +0200 Subject: use `add_concurrent_index` to add the :confirmation_token index --- .../20170904092148_add_email_confirmation.rb | 1 - .../20170909090114_add_email_confirmation_index.rb | 36 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170909090114_add_email_confirmation_index.rb (limited to 'db') diff --git a/db/migrate/20170904092148_add_email_confirmation.rb b/db/migrate/20170904092148_add_email_confirmation.rb index b4c574b6a99..b6ecf1dd9da 100644 --- a/db/migrate/20170904092148_add_email_confirmation.rb +++ b/db/migrate/20170904092148_add_email_confirmation.rb @@ -29,6 +29,5 @@ class AddEmailConfirmation < ActiveRecord::Migration add_column :emails, :confirmation_token, :string add_column :emails, :confirmed_at, :datetime add_column :emails, :confirmation_sent_at, :datetime - add_index :emails, :confirmation_token, unique: true end end diff --git a/db/migrate/20170909090114_add_email_confirmation_index.rb b/db/migrate/20170909090114_add_email_confirmation_index.rb new file mode 100644 index 00000000000..e488f339247 --- /dev/null +++ b/db/migrate/20170909090114_add_email_confirmation_index.rb @@ -0,0 +1,36 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddEmailConfirmationIndex < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index", "remove_concurrent_index" or + # "add_column_with_default" you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + disable_ddl_transaction! + + # Not necessary to remove duplicates, as :confirmation_token is a new column + def up + add_concurrent_index :emails, :confirmation_token, unique: true + end + + def down + remove_index :emails, :confirmation_token if index_exists?(:emails, :confirmation_token) + end +end -- cgit v1.2.1 From d2267beb8916de5003e06b8764f209508fca989f Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Sat, 9 Sep 2017 18:32:27 +0200 Subject: tweaks for rubocop --- db/migrate/20170904092148_add_email_confirmation.rb | 4 ++-- db/migrate/20170909090114_add_email_confirmation_index.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/migrate/20170904092148_add_email_confirmation.rb b/db/migrate/20170904092148_add_email_confirmation.rb index b6ecf1dd9da..17ff424b319 100644 --- a/db/migrate/20170904092148_add_email_confirmation.rb +++ b/db/migrate/20170904092148_add_email_confirmation.rb @@ -27,7 +27,7 @@ class AddEmailConfirmation < ActiveRecord::Migration def change add_column :emails, :confirmation_token, :string - add_column :emails, :confirmed_at, :datetime - add_column :emails, :confirmation_sent_at, :datetime + add_column :emails, :confirmed_at, :datetime_with_timezone + add_column :emails, :confirmation_sent_at, :datetime_with_timezone end end diff --git a/db/migrate/20170909090114_add_email_confirmation_index.rb b/db/migrate/20170909090114_add_email_confirmation_index.rb index e488f339247..a8c1023c482 100644 --- a/db/migrate/20170909090114_add_email_confirmation_index.rb +++ b/db/migrate/20170909090114_add_email_confirmation_index.rb @@ -31,6 +31,6 @@ class AddEmailConfirmationIndex < ActiveRecord::Migration end def down - remove_index :emails, :confirmation_token if index_exists?(:emails, :confirmation_token) + remove_concurrent_index :emails, :confirmation_token if index_exists?(:emails, :confirmation_token) end end -- cgit v1.2.1 From 4457ae827251904c28a30c3db06e05495a42b484 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Mon, 11 Sep 2017 18:31:49 +0200 Subject: updated schema.rb --- db/schema.rb | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 80ef91ec95d..861e369a695 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -32,8 +32,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.text "description", null: false t.string "header_logo" t.string "logo" - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.text "description_html" t.integer "cached_markdown_version" end @@ -101,10 +101,6 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.text "help_page_text_html" t.text "shared_runners_text_html" t.text "after_sign_up_text_html" - t.integer "rsa_key_restriction", default: 0, null: false - t.integer "dsa_key_restriction", default: 0, null: false - t.integer "ecdsa_key_restriction", default: 0, null: false - t.integer "ed25519_key_restriction", default: 0, null: false t.boolean "housekeeping_enabled", default: true, null: false t.boolean "housekeeping_bitmaps_enabled", default: true, null: false t.integer "housekeeping_incremental_repack_period", default: 10, null: false @@ -129,10 +125,14 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.boolean "prometheus_metrics_enabled", default: false, null: false t.boolean "help_page_hide_commercial_content", default: false t.string "help_page_support_url" - t.boolean "password_authentication_enabled" t.integer "performance_bar_allowed_group_id" - t.boolean "hashed_storage_enabled", default: false, null: false + t.boolean "password_authentication_enabled" t.boolean "project_export_enabled", default: true, null: false + t.boolean "hashed_storage_enabled", default: false, null: false + t.integer "rsa_key_restriction", default: 0, null: false + t.integer "dsa_key_restriction", default: 0, null: false + t.integer "ecdsa_key_restriction", default: 0, null: false + t.integer "ed25519_key_restriction", default: 0, null: false t.boolean "auto_devops_enabled", default: false, null: false end @@ -275,8 +275,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "encrypted_value_iv" t.integer "group_id", null: false t.boolean "protected", default: false, null: false - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "ci_group_variables", ["group_id", "key"], name: "index_ci_group_variables_on_group_id_and_key", unique: true, using: :btree @@ -288,8 +288,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "encrypted_value_salt" t.string "encrypted_value_iv" t.integer "pipeline_schedule_id", null: false - t.datetime_with_timezone "created_at" - t.datetime_with_timezone "updated_at" + t.datetime "created_at" + t.datetime "updated_at" end add_index "ci_pipeline_schedule_variables", ["pipeline_schedule_id", "key"], name: "index_ci_pipeline_schedule_variables_on_schedule_id_and_key", unique: true, using: :btree @@ -341,8 +341,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.integer "auto_canceled_by_id" t.integer "pipeline_schedule_id" t.integer "source" - t.integer "config_source" t.boolean "protected" + t.integer "config_source" end add_index "ci_pipelines", ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree @@ -515,8 +515,12 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "email", null: false t.datetime "created_at" t.datetime "updated_at" + t.string "confirmation_token" + t.datetime "confirmed_at" + t.datetime "confirmation_sent_at" end + add_index "emails", ["confirmation_token"], name: "index_emails_on_confirmation_token", unique: true, using: :btree add_index "emails", ["email"], name: "index_emails_on_email", unique: true, using: :btree add_index "emails", ["user_id"], name: "index_emails_on_user_id", using: :btree @@ -538,8 +542,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.integer "project_id" t.integer "author_id", null: false t.integer "target_id" - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "action", limit: 2, null: false t.string "target_type" end @@ -577,8 +581,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree create_table "gpg_keys", force: :cascade do |t| - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "user_id" t.binary "primary_keyid" t.binary "fingerprint" @@ -590,8 +594,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "gpg_keys", ["user_id"], name: "index_gpg_keys_on_user_id", using: :btree create_table "gpg_signatures", force: :cascade do |t| - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "project_id" t.integer "gpg_key_id" t.binary "commit_sha" @@ -789,8 +793,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "members", ["user_id"], name: "index_members_on_user_id", using: :btree create_table "merge_request_diff_commits", id: false, force: :cascade do |t| - t.datetime_with_timezone "authored_date" - t.datetime_with_timezone "committed_date" + t.datetime "authored_date" + t.datetime "committed_date" t.integer "merge_request_diff_id", null: false t.integer "relative_order", null: false t.binary "sha", null: false @@ -1113,8 +1117,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do create_table "project_auto_devops", force: :cascade do |t| t.integer "project_id", null: false - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "enabled" t.string "domain" end @@ -1204,7 +1208,6 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "repository_storage", default: "default", null: false t.boolean "request_access_enabled", default: false, null: false t.boolean "has_external_wiki" - t.string "ci_config_path" t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" @@ -1212,8 +1215,9 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.integer "auto_cancel_pending_pipelines", default: 1, null: false t.string "import_jid" t.integer "cached_markdown_version" - t.text "delete_error" t.datetime "last_repository_updated_at" + t.string "ci_config_path" + t.text "delete_error" t.integer "storage_version", limit: 2 t.boolean "resolve_outdated_diff_discussions" end -- cgit v1.2.1 From a2715aaa121dbef8d209ddc87993495280a7fc2f Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Wed, 13 Sep 2017 16:13:33 +0200 Subject: Return schema.rb to pre-rebase state This reverts commit 9f186db09d7f380cfbde4c0061be77c272518547. --- db/schema.rb | 54 +++++++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 861e369a695..80ef91ec95d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -32,8 +32,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.text "description", null: false t.string "header_logo" t.string "logo" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.text "description_html" t.integer "cached_markdown_version" end @@ -101,6 +101,10 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.text "help_page_text_html" t.text "shared_runners_text_html" t.text "after_sign_up_text_html" + t.integer "rsa_key_restriction", default: 0, null: false + t.integer "dsa_key_restriction", default: 0, null: false + t.integer "ecdsa_key_restriction", default: 0, null: false + t.integer "ed25519_key_restriction", default: 0, null: false t.boolean "housekeeping_enabled", default: true, null: false t.boolean "housekeeping_bitmaps_enabled", default: true, null: false t.integer "housekeeping_incremental_repack_period", default: 10, null: false @@ -125,14 +129,10 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.boolean "prometheus_metrics_enabled", default: false, null: false t.boolean "help_page_hide_commercial_content", default: false t.string "help_page_support_url" - t.integer "performance_bar_allowed_group_id" t.boolean "password_authentication_enabled" - t.boolean "project_export_enabled", default: true, null: false + t.integer "performance_bar_allowed_group_id" t.boolean "hashed_storage_enabled", default: false, null: false - t.integer "rsa_key_restriction", default: 0, null: false - t.integer "dsa_key_restriction", default: 0, null: false - t.integer "ecdsa_key_restriction", default: 0, null: false - t.integer "ed25519_key_restriction", default: 0, null: false + t.boolean "project_export_enabled", default: true, null: false t.boolean "auto_devops_enabled", default: false, null: false end @@ -275,8 +275,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "encrypted_value_iv" t.integer "group_id", null: false t.boolean "protected", default: false, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false end add_index "ci_group_variables", ["group_id", "key"], name: "index_ci_group_variables_on_group_id_and_key", unique: true, using: :btree @@ -288,8 +288,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "encrypted_value_salt" t.string "encrypted_value_iv" t.integer "pipeline_schedule_id", null: false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime_with_timezone "created_at" + t.datetime_with_timezone "updated_at" end add_index "ci_pipeline_schedule_variables", ["pipeline_schedule_id", "key"], name: "index_ci_pipeline_schedule_variables_on_schedule_id_and_key", unique: true, using: :btree @@ -341,8 +341,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.integer "auto_canceled_by_id" t.integer "pipeline_schedule_id" t.integer "source" - t.boolean "protected" t.integer "config_source" + t.boolean "protected" end add_index "ci_pipelines", ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree @@ -515,12 +515,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "email", null: false t.datetime "created_at" t.datetime "updated_at" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" end - add_index "emails", ["confirmation_token"], name: "index_emails_on_confirmation_token", unique: true, using: :btree add_index "emails", ["email"], name: "index_emails_on_email", unique: true, using: :btree add_index "emails", ["user_id"], name: "index_emails_on_user_id", using: :btree @@ -542,8 +538,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.integer "project_id" t.integer "author_id", null: false t.integer "target_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.integer "action", limit: 2, null: false t.string "target_type" end @@ -581,8 +577,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree create_table "gpg_keys", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.integer "user_id" t.binary "primary_keyid" t.binary "fingerprint" @@ -594,8 +590,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "gpg_keys", ["user_id"], name: "index_gpg_keys_on_user_id", using: :btree create_table "gpg_signatures", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.integer "project_id" t.integer "gpg_key_id" t.binary "commit_sha" @@ -793,8 +789,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "members", ["user_id"], name: "index_members_on_user_id", using: :btree create_table "merge_request_diff_commits", id: false, force: :cascade do |t| - t.datetime "authored_date" - t.datetime "committed_date" + t.datetime_with_timezone "authored_date" + t.datetime_with_timezone "committed_date" t.integer "merge_request_diff_id", null: false t.integer "relative_order", null: false t.binary "sha", null: false @@ -1117,8 +1113,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do create_table "project_auto_devops", force: :cascade do |t| t.integer "project_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.boolean "enabled" t.string "domain" end @@ -1208,6 +1204,7 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "repository_storage", default: "default", null: false t.boolean "request_access_enabled", default: false, null: false t.boolean "has_external_wiki" + t.string "ci_config_path" t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" @@ -1215,9 +1212,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.integer "auto_cancel_pending_pipelines", default: 1, null: false t.string "import_jid" t.integer "cached_markdown_version" - t.datetime "last_repository_updated_at" - t.string "ci_config_path" t.text "delete_error" + t.datetime "last_repository_updated_at" t.integer "storage_version", limit: 2 t.boolean "resolve_outdated_diff_discussions" end -- cgit v1.2.1 From 867d59c57f9b2501690b52671c9ca1ed54fb92d4 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Wed, 13 Sep 2017 16:18:48 +0200 Subject: updated schema.rb with correct changes --- db/schema.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 80ef91ec95d..17f59145472 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -515,8 +515,12 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "email", null: false t.datetime "created_at" t.datetime "updated_at" + t.string "confirmation_token" + t.datetime "confirmed_at" + t.datetime "confirmation_sent_at" end + add_index "emails", ["confirmation_token"], name: "index_emails_on_confirmation_token", unique: true, using: :btree add_index "emails", ["email"], name: "index_emails_on_email", unique: true, using: :btree add_index "emails", ["user_id"], name: "index_emails_on_user_id", using: :btree -- cgit v1.2.1 From d4fa672c20657a1c7d2fcfa25e9798e7ccdbf39d Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 25 Sep 2017 16:10:25 +0900 Subject: Create Kubernetes cluster on GKE from k8s service --- db/migrate/20170924094327_create_ci_clusters.rb | 29 +++++++++++ db/schema.rb | 68 ++++++++++++++++--------- 2 files changed, 72 insertions(+), 25 deletions(-) create mode 100644 db/migrate/20170924094327_create_ci_clusters.rb (limited to 'db') diff --git a/db/migrate/20170924094327_create_ci_clusters.rb b/db/migrate/20170924094327_create_ci_clusters.rb new file mode 100644 index 00000000000..86e75edf203 --- /dev/null +++ b/db/migrate/20170924094327_create_ci_clusters.rb @@ -0,0 +1,29 @@ +class CreateCiClusters < ActiveRecord::Migration + DOWNTIME = false + + def change + create_table :ci_clusters do |t| + t.integer :project_id + t.integer :owner_id + t.datetime_with_timezone :created_at, null: false + t.datetime_with_timezone :updated_at, null: false + t.boolean :enabled, default: true + t.string :end_point + t.text :ca_cert # Base64? + t.string :token + t.string :username + t.string :password + t.string :project_namespace + t.integer :creation_type # manual or on_gke + end + + # TODO: fk, index, encypt + + add_foreign_key :ci_clusters, :projects + add_foreign_key :ci_clusters, :users, column: :owner_id + end + + def down + drop_table :ci_clusters + end +end diff --git a/db/schema.rb b/db/schema.rb index 80ef91ec95d..5258adcbcb7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170921115009) do +ActiveRecord::Schema.define(version: 20170924094327) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -32,8 +32,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.text "description", null: false t.string "header_logo" t.string "logo" - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.text "description_html" t.integer "cached_markdown_version" end @@ -101,10 +101,6 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.text "help_page_text_html" t.text "shared_runners_text_html" t.text "after_sign_up_text_html" - t.integer "rsa_key_restriction", default: 0, null: false - t.integer "dsa_key_restriction", default: 0, null: false - t.integer "ecdsa_key_restriction", default: 0, null: false - t.integer "ed25519_key_restriction", default: 0, null: false t.boolean "housekeeping_enabled", default: true, null: false t.boolean "housekeeping_bitmaps_enabled", default: true, null: false t.integer "housekeeping_incremental_repack_period", default: 10, null: false @@ -132,6 +128,10 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.boolean "password_authentication_enabled" t.integer "performance_bar_allowed_group_id" t.boolean "hashed_storage_enabled", default: false, null: false + t.integer "rsa_key_restriction", default: 0, null: false + t.integer "dsa_key_restriction", default: 0, null: false + t.integer "ecdsa_key_restriction", default: 0, null: false + t.integer "ed25519_key_restriction", default: 0, null: false t.boolean "project_export_enabled", default: true, null: false t.boolean "auto_devops_enabled", default: false, null: false end @@ -256,7 +256,6 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "ci_builds", ["commit_id", "status", "type"], name: "index_ci_builds_on_commit_id_and_status_and_type", using: :btree add_index "ci_builds", ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref", using: :btree add_index "ci_builds", ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref", using: :btree - add_index "ci_builds", ["id"], name: "index_for_ci_builds_retried_migration", where: "(retried IS NULL)", using: :btree add_index "ci_builds", ["project_id"], name: "index_ci_builds_on_project_id", using: :btree add_index "ci_builds", ["protected"], name: "index_ci_builds_on_protected", using: :btree add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree @@ -267,6 +266,21 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "ci_builds", ["updated_at"], name: "index_ci_builds_on_updated_at", using: :btree 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.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "enabled", default: true + t.string "end_point" + t.text "ca_cert" + t.string "token" + t.string "username" + t.string "password" + t.string "project_namespace" + t.integer "creation_type" + end + create_table "ci_group_variables", force: :cascade do |t| t.string "key", null: false t.text "value" @@ -275,8 +289,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "encrypted_value_iv" t.integer "group_id", null: false t.boolean "protected", default: false, null: false - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "ci_group_variables", ["group_id", "key"], name: "index_ci_group_variables_on_group_id_and_key", unique: true, using: :btree @@ -288,8 +302,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "encrypted_value_salt" t.string "encrypted_value_iv" t.integer "pipeline_schedule_id", null: false - t.datetime_with_timezone "created_at" - t.datetime_with_timezone "updated_at" + t.datetime "created_at" + t.datetime "updated_at" end add_index "ci_pipeline_schedule_variables", ["pipeline_schedule_id", "key"], name: "index_ci_pipeline_schedule_variables_on_schedule_id_and_key", unique: true, using: :btree @@ -341,12 +355,14 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.integer "auto_canceled_by_id" t.integer "pipeline_schedule_id" t.integer "source" - t.integer "config_source" t.boolean "protected" + t.integer "iid" + t.integer "config_source" end add_index "ci_pipelines", ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree add_index "ci_pipelines", ["pipeline_schedule_id"], name: "index_ci_pipelines_on_pipeline_schedule_id", using: :btree + add_index "ci_pipelines", ["project_id", "iid"], name: "index_ci_pipelines_on_project_id_and_iid", unique: true, using: :btree add_index "ci_pipelines", ["project_id", "ref", "status"], name: "index_ci_pipelines_on_project_id_and_ref_and_status", using: :btree add_index "ci_pipelines", ["project_id", "sha"], name: "index_ci_pipelines_on_project_id_and_sha", using: :btree add_index "ci_pipelines", ["project_id"], name: "index_ci_pipelines_on_project_id", using: :btree @@ -538,8 +554,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.integer "project_id" t.integer "author_id", null: false t.integer "target_id" - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "action", limit: 2, null: false t.string "target_type" end @@ -577,8 +593,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree create_table "gpg_keys", force: :cascade do |t| - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "user_id" t.binary "primary_keyid" t.binary "fingerprint" @@ -590,8 +606,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "gpg_keys", ["user_id"], name: "index_gpg_keys_on_user_id", using: :btree create_table "gpg_signatures", force: :cascade do |t| - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "project_id" t.integer "gpg_key_id" t.binary "commit_sha" @@ -789,8 +805,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do add_index "members", ["user_id"], name: "index_members_on_user_id", using: :btree create_table "merge_request_diff_commits", id: false, force: :cascade do |t| - t.datetime_with_timezone "authored_date" - t.datetime_with_timezone "committed_date" + t.datetime "authored_date" + t.datetime "committed_date" t.integer "merge_request_diff_id", null: false t.integer "relative_order", null: false t.binary "sha", null: false @@ -1113,8 +1129,8 @@ ActiveRecord::Schema.define(version: 20170921115009) do create_table "project_auto_devops", force: :cascade do |t| t.integer "project_id", null: false - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "enabled" t.string "domain" end @@ -1204,7 +1220,6 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.string "repository_storage", default: "default", null: false t.boolean "request_access_enabled", default: false, null: false t.boolean "has_external_wiki" - t.string "ci_config_path" t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" @@ -1212,8 +1227,9 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.integer "auto_cancel_pending_pipelines", default: 1, null: false t.string "import_jid" t.integer "cached_markdown_version" - t.text "delete_error" t.datetime "last_repository_updated_at" + t.string "ci_config_path" + t.text "delete_error" t.integer "storage_version", limit: 2 t.boolean "resolve_outdated_diff_discussions" end @@ -1685,6 +1701,8 @@ ActiveRecord::Schema.define(version: 20170921115009) 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", "users", column: "owner_id" 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 -- cgit v1.2.1 From cf8140a752afe9a00197b11c9f9d38098717e6df Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 25 Sep 2017 16:38:21 +0900 Subject: Discard unnessecary changed in schema --- db/schema.rb | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 5258adcbcb7..f3e174c847f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -32,8 +32,8 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.text "description", null: false t.string "header_logo" t.string "logo" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.text "description_html" t.integer "cached_markdown_version" end @@ -101,6 +101,10 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.text "help_page_text_html" t.text "shared_runners_text_html" t.text "after_sign_up_text_html" + t.integer "rsa_key_restriction", default: 0, null: false + t.integer "dsa_key_restriction", default: 0, null: false + t.integer "ecdsa_key_restriction", default: 0, null: false + t.integer "ed25519_key_restriction", default: 0, null: false t.boolean "housekeeping_enabled", default: true, null: false t.boolean "housekeeping_bitmaps_enabled", default: true, null: false t.integer "housekeeping_incremental_repack_period", default: 10, null: false @@ -128,10 +132,6 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.boolean "password_authentication_enabled" t.integer "performance_bar_allowed_group_id" t.boolean "hashed_storage_enabled", default: false, null: false - t.integer "rsa_key_restriction", default: 0, null: false - t.integer "dsa_key_restriction", default: 0, null: false - t.integer "ecdsa_key_restriction", default: 0, null: false - t.integer "ed25519_key_restriction", default: 0, null: false t.boolean "project_export_enabled", default: true, null: false t.boolean "auto_devops_enabled", default: false, null: false end @@ -256,6 +256,7 @@ ActiveRecord::Schema.define(version: 20170924094327) do add_index "ci_builds", ["commit_id", "status", "type"], name: "index_ci_builds_on_commit_id_and_status_and_type", using: :btree add_index "ci_builds", ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref", using: :btree add_index "ci_builds", ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref", using: :btree + add_index "ci_builds", ["id"], name: "index_for_ci_builds_retried_migration", where: "(retried IS NULL)", using: :btree add_index "ci_builds", ["project_id"], name: "index_ci_builds_on_project_id", using: :btree add_index "ci_builds", ["protected"], name: "index_ci_builds_on_protected", using: :btree add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree @@ -289,8 +290,8 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.string "encrypted_value_iv" t.integer "group_id", null: false t.boolean "protected", default: false, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false end add_index "ci_group_variables", ["group_id", "key"], name: "index_ci_group_variables_on_group_id_and_key", unique: true, using: :btree @@ -302,8 +303,8 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.string "encrypted_value_salt" t.string "encrypted_value_iv" t.integer "pipeline_schedule_id", null: false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime_with_timezone "created_at" + t.datetime_with_timezone "updated_at" end add_index "ci_pipeline_schedule_variables", ["pipeline_schedule_id", "key"], name: "index_ci_pipeline_schedule_variables_on_schedule_id_and_key", unique: true, using: :btree @@ -355,14 +356,12 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.integer "auto_canceled_by_id" t.integer "pipeline_schedule_id" t.integer "source" - t.boolean "protected" - t.integer "iid" t.integer "config_source" + t.boolean "protected" end add_index "ci_pipelines", ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree add_index "ci_pipelines", ["pipeline_schedule_id"], name: "index_ci_pipelines_on_pipeline_schedule_id", using: :btree - add_index "ci_pipelines", ["project_id", "iid"], name: "index_ci_pipelines_on_project_id_and_iid", unique: true, using: :btree add_index "ci_pipelines", ["project_id", "ref", "status"], name: "index_ci_pipelines_on_project_id_and_ref_and_status", using: :btree add_index "ci_pipelines", ["project_id", "sha"], name: "index_ci_pipelines_on_project_id_and_sha", using: :btree add_index "ci_pipelines", ["project_id"], name: "index_ci_pipelines_on_project_id", using: :btree @@ -554,8 +553,8 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.integer "project_id" t.integer "author_id", null: false t.integer "target_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.integer "action", limit: 2, null: false t.string "target_type" end @@ -593,8 +592,8 @@ ActiveRecord::Schema.define(version: 20170924094327) do add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree create_table "gpg_keys", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.integer "user_id" t.binary "primary_keyid" t.binary "fingerprint" @@ -606,8 +605,8 @@ ActiveRecord::Schema.define(version: 20170924094327) do add_index "gpg_keys", ["user_id"], name: "index_gpg_keys_on_user_id", using: :btree create_table "gpg_signatures", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.integer "project_id" t.integer "gpg_key_id" t.binary "commit_sha" @@ -805,8 +804,8 @@ ActiveRecord::Schema.define(version: 20170924094327) do add_index "members", ["user_id"], name: "index_members_on_user_id", using: :btree create_table "merge_request_diff_commits", id: false, force: :cascade do |t| - t.datetime "authored_date" - t.datetime "committed_date" + t.datetime_with_timezone "authored_date" + t.datetime_with_timezone "committed_date" t.integer "merge_request_diff_id", null: false t.integer "relative_order", null: false t.binary "sha", null: false @@ -1129,8 +1128,8 @@ ActiveRecord::Schema.define(version: 20170924094327) do create_table "project_auto_devops", force: :cascade do |t| t.integer "project_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.boolean "enabled" t.string "domain" end @@ -1220,6 +1219,7 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.string "repository_storage", default: "default", null: false t.boolean "request_access_enabled", default: false, null: false t.boolean "has_external_wiki" + t.string "ci_config_path" t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" @@ -1227,9 +1227,8 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.integer "auto_cancel_pending_pipelines", default: 1, null: false t.string "import_jid" t.integer "cached_markdown_version" - t.datetime "last_repository_updated_at" - t.string "ci_config_path" t.text "delete_error" + t.datetime "last_repository_updated_at" t.integer "storage_version", limit: 2 t.boolean "resolve_outdated_diff_discussions" end -- cgit v1.2.1 From bdc618c289b8c2b996a3ef92b7748966c311d28a Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 26 Sep 2017 02:11:26 +0900 Subject: ok --- db/migrate/20170924094327_create_ci_clusters.rb | 34 ++++++++++++++++++++----- db/schema.rb | 13 +++++++--- 2 files changed, 37 insertions(+), 10 deletions(-) (limited to 'db') diff --git a/db/migrate/20170924094327_create_ci_clusters.rb b/db/migrate/20170924094327_create_ci_clusters.rb index 86e75edf203..7a35fe35605 100644 --- a/db/migrate/20170924094327_create_ci_clusters.rb +++ b/db/migrate/20170924094327_create_ci_clusters.rb @@ -1,26 +1,48 @@ class CreateCiClusters < ActiveRecord::Migration DOWNTIME = false - def change + def up create_table :ci_clusters do |t| t.integer :project_id t.integer :owner_id - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false + t.integer :service_id + + # General t.boolean :enabled, default: true + t.integer :creation_type # manual or on_gke + + # k8s integration specific + t.string :project_namespace + + # Cluster details t.string :end_point - t.text :ca_cert # Base64? + t.text :ca_cert t.string :token t.string :username t.string :password - t.string :project_namespace - t.integer :creation_type # manual or on_gke + + # GKE + t.string :gcp_project_id + t.string :cluster_zone + t.string :cluster_name + + t.datetime_with_timezone :created_at, null: false + t.datetime_with_timezone :updated_at, null: false end + # create_table :ci_gke_clusters do |t| + # t.integer :ci_cluster_id + # t.string :gcp_project_id + # t.string :cluster_zone + # t.string :cluster_name + # end + # add_foreign_key :ci_gke_clusters, :ci_clusters + # TODO: fk, index, encypt 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 f3e174c847f..8000229d5fa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -270,16 +270,20 @@ ActiveRecord::Schema.define(version: 20170924094327) do create_table "ci_clusters", force: :cascade do |t| t.integer "project_id" t.integer "owner_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "service_id" t.boolean "enabled", default: true + t.integer "creation_type" + t.string "project_namespace" t.string "end_point" t.text "ca_cert" t.string "token" t.string "username" t.string "password" - t.string "project_namespace" - t.integer "creation_type" + t.string "gcp_project_id" + t.string "cluster_zone" + t.string "cluster_name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "ci_group_variables", force: :cascade do |t| @@ -1701,6 +1705,7 @@ ActiveRecord::Schema.define(version: 20170924094327) do 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", "services" add_foreign_key "ci_clusters", "users", column: "owner_id" 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 -- cgit v1.2.1 From e9d05a2cdc24b4dc771344f26e6ffdcf0240e46c Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 27 Sep 2017 21:01:08 +0900 Subject: Add login root. Remove ceration type. --- db/migrate/20170924094327_create_ci_clusters.rb | 9 --------- db/schema.rb | 1 - 2 files changed, 10 deletions(-) (limited to 'db') diff --git a/db/migrate/20170924094327_create_ci_clusters.rb b/db/migrate/20170924094327_create_ci_clusters.rb index 7a35fe35605..dce3298cde2 100644 --- a/db/migrate/20170924094327_create_ci_clusters.rb +++ b/db/migrate/20170924094327_create_ci_clusters.rb @@ -9,7 +9,6 @@ class CreateCiClusters < ActiveRecord::Migration # General t.boolean :enabled, default: true - t.integer :creation_type # manual or on_gke # k8s integration specific t.string :project_namespace @@ -30,14 +29,6 @@ class CreateCiClusters < ActiveRecord::Migration t.datetime_with_timezone :updated_at, null: false end - # create_table :ci_gke_clusters do |t| - # t.integer :ci_cluster_id - # t.string :gcp_project_id - # t.string :cluster_zone - # t.string :cluster_name - # end - # add_foreign_key :ci_gke_clusters, :ci_clusters - # TODO: fk, index, encypt add_foreign_key :ci_clusters, :projects diff --git a/db/schema.rb b/db/schema.rb index 8000229d5fa..3908f06821e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -272,7 +272,6 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.integer "owner_id" t.integer "service_id" t.boolean "enabled", default: true - t.integer "creation_type" t.string "project_namespace" t.string "end_point" t.text "ca_cert" -- cgit v1.2.1 From 058e595788118fb129d3003989a3728de9ae7e39 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 27 Sep 2017 22:17:41 +0900 Subject: Delete/Update basic implementation --- db/migrate/20170924094327_create_ci_clusters.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170924094327_create_ci_clusters.rb b/db/migrate/20170924094327_create_ci_clusters.rb index dce3298cde2..c919c5da2c4 100644 --- a/db/migrate/20170924094327_create_ci_clusters.rb +++ b/db/migrate/20170924094327_create_ci_clusters.rb @@ -29,7 +29,7 @@ class CreateCiClusters < ActiveRecord::Migration t.datetime_with_timezone :updated_at, null: false end - # TODO: fk, index, encypt + # TODO: fk, index, attr_encrypted add_foreign_key :ci_clusters, :projects add_foreign_key :ci_clusters, :users, column: :owner_id -- cgit v1.2.1 From fabc359e77c39aea86f0eaa9f19b17b2a609dd99 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 28 Sep 2017 18:11:17 +0900 Subject: Multithreading cluster creation is done with `reactive_cache` --- db/migrate/20170924094327_create_ci_clusters.rb | 1 + db/schema.rb | 1 + 2 files changed, 2 insertions(+) (limited to 'db') diff --git a/db/migrate/20170924094327_create_ci_clusters.rb b/db/migrate/20170924094327_create_ci_clusters.rb index c919c5da2c4..33a67be46dc 100644 --- a/db/migrate/20170924094327_create_ci_clusters.rb +++ b/db/migrate/20170924094327_create_ci_clusters.rb @@ -24,6 +24,7 @@ class CreateCiClusters < ActiveRecord::Migration t.string :gcp_project_id t.string :cluster_zone t.string :cluster_name + t.string :gcp_operation_id t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :updated_at, null: false diff --git a/db/schema.rb b/db/schema.rb index 3908f06821e..0ebce995cfd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -281,6 +281,7 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.string "gcp_project_id" t.string "cluster_zone" t.string "cluster_name" + t.string "gcp_operation_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false end -- cgit v1.2.1 From bda1b0a878205ac99bf10c0b4f0e63f2d4e3a25f Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 29 Sep 2017 00:08:11 +0900 Subject: Databse foreing key, index, encrypt password. Use short path. Improve error handling. Polish. --- db/migrate/20170924094327_create_ci_clusters.rb | 17 +++++++---------- db/schema.rb | 15 ++++++++++----- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'db') 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 -- cgit v1.2.1 From e499c1c39dbea505858874ee47436641df3d93d4 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sun, 1 Oct 2017 00:54:22 +0900 Subject: Replace reactive_cache by multipel sidekiq workers --- db/migrate/20170924094327_create_ci_clusters.rb | 12 ++++++++++-- db/schema.rb | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/migrate/20170924094327_create_ci_clusters.rb b/db/migrate/20170924094327_create_ci_clusters.rb index 2663130c7e6..798c8e03b37 100644 --- a/db/migrate/20170924094327_create_ci_clusters.rb +++ b/db/migrate/20170924094327_create_ci_clusters.rb @@ -9,6 +9,8 @@ class CreateCiClusters < ActiveRecord::Migration # General t.boolean :enabled, default: true + t.integer :status + t.string :status_reason # k8s integration specific t.string :project_namespace @@ -16,9 +18,10 @@ class CreateCiClusters < ActiveRecord::Migration # Cluster details t.string :endpoint t.text :ca_cert - t.string :token + t.string :encrypted_kubernetes_token + t.string :encrypted_kubernetes_token_salt + t.string :encrypted_kubernetes_token_iv t.string :username - t.string :password t.string :encrypted_password t.string :encrypted_password_salt t.string :encrypted_password_iv @@ -27,7 +30,12 @@ class CreateCiClusters < ActiveRecord::Migration t.string :gcp_project_id t.string :cluster_zone t.string :cluster_name + t.string :cluster_size + t.string :machine_type t.string :gcp_operation_id + t.string :encrypted_gcp_token + t.string :encrypted_gcp_token_salt + t.string :encrypted_gcp_token_iv t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :updated_at, null: false diff --git a/db/schema.rb b/db/schema.rb index af5367113a2..de844583d56 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -272,19 +272,27 @@ ActiveRecord::Schema.define(version: 20170924094327) do t.integer "user_id", null: false t.integer "service_id" t.boolean "enabled", default: true + t.integer "status" + t.string "status_reason" t.string "project_namespace" t.string "endpoint" t.text "ca_cert" - t.string "token" + t.string "encrypted_kubernetes_token" + t.string "encrypted_kubernetes_token_salt" + t.string "encrypted_kubernetes_token_iv" 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" + t.string "cluster_size" + t.string "machine_type" t.string "gcp_operation_id" + t.string "encrypted_gcp_token" + t.string "encrypted_gcp_token_salt" + t.string "encrypted_gcp_token_iv" t.datetime "created_at", null: false t.datetime "updated_at", null: false end -- cgit v1.2.1 From 5663b4808df787b1bcbf32ba54eccbb4c7537e25 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sun, 1 Oct 2017 20:30:32 +0900 Subject: authorize in controller. validation in model. --- db/migrate/20170924094327_create_ci_clusters.rb | 8 ++++---- db/schema.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'db') diff --git a/db/migrate/20170924094327_create_ci_clusters.rb b/db/migrate/20170924094327_create_ci_clusters.rb index 798c8e03b37..bef39b9808d 100644 --- a/db/migrate/20170924094327_create_ci_clusters.rb +++ b/db/migrate/20170924094327_create_ci_clusters.rb @@ -27,10 +27,10 @@ class CreateCiClusters < ActiveRecord::Migration t.string :encrypted_password_iv # GKE - t.string :gcp_project_id - t.string :cluster_zone - t.string :cluster_name - t.string :cluster_size + t.string :gcp_project_id, null: false + t.string :cluster_zone, null: false + t.string :cluster_name, null: false + t.integer :cluster_size, null: false t.string :machine_type t.string :gcp_operation_id t.string :encrypted_gcp_token diff --git a/db/schema.rb b/db/schema.rb index de844583d56..61245f3f666 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -284,10 +284,10 @@ ActiveRecord::Schema.define(version: 20170924094327) do 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" - t.string "cluster_size" + t.string "gcp_project_id", null: false + t.string "cluster_zone", null: false + t.string "cluster_name", null: false + t.integer "cluster_size", null: false t.string "machine_type" t.string "gcp_operation_id" t.string "encrypted_gcp_token" -- cgit v1.2.1 From 00ee7a9f27d3d00936127957eb3c99f803d3e880 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Sun, 1 Oct 2017 16:45:48 +0100 Subject: FE review changes app code --- db/schema.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index c93fe7bea73..a706eb2a04e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1218,6 +1218,7 @@ ActiveRecord::Schema.define(version: 20170921115009) do t.datetime "last_repository_updated_at" t.integer "storage_version", limit: 2 t.boolean "resolve_outdated_diff_discussions" + t.boolean "merge_requests_ff_only_enabled", default: false, null: false end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree -- cgit v1.2.1 From 34e66c427dde2070c2c09a07ce08f991e46de92f Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 2 Oct 2017 21:58:50 +0900 Subject: PollingInterval, rename to gke_clusters, has_one :cluster --- db/migrate/20170924094327_create_ci_clusters.rb | 48 ------------------------ db/migrate/20170924094327_create_gcp_clusters.rb | 44 ++++++++++++++++++++++ db/schema.rb | 37 +++++++++++++++++- 3 files changed, 80 insertions(+), 49 deletions(-) delete mode 100644 db/migrate/20170924094327_create_ci_clusters.rb create mode 100644 db/migrate/20170924094327_create_gcp_clusters.rb (limited to 'db') diff --git a/db/migrate/20170924094327_create_ci_clusters.rb b/db/migrate/20170924094327_create_ci_clusters.rb deleted file mode 100644 index bef39b9808d..00000000000 --- a/db/migrate/20170924094327_create_ci_clusters.rb +++ /dev/null @@ -1,48 +0,0 @@ -class CreateCiClusters < ActiveRecord::Migration - DOWNTIME = false - - def up - create_table :ci_clusters do |t| - 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 - t.integer :status - t.string :status_reason - - # k8s integration specific - t.string :project_namespace - - # Cluster details - t.string :endpoint - t.text :ca_cert - t.string :encrypted_kubernetes_token - t.string :encrypted_kubernetes_token_salt - t.string :encrypted_kubernetes_token_iv - t.string :username - t.string :encrypted_password - t.string :encrypted_password_salt - t.string :encrypted_password_iv - - # GKE - t.string :gcp_project_id, null: false - t.string :cluster_zone, null: false - t.string :cluster_name, null: false - t.integer :cluster_size, null: false - t.string :machine_type - t.string :gcp_operation_id - t.string :encrypted_gcp_token - t.string :encrypted_gcp_token_salt - t.string :encrypted_gcp_token_iv - - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false - end - end - - def down - drop_table :ci_clusters - end -end diff --git a/db/migrate/20170924094327_create_gcp_clusters.rb b/db/migrate/20170924094327_create_gcp_clusters.rb new file mode 100644 index 00000000000..9aa8e537dbe --- /dev/null +++ b/db/migrate/20170924094327_create_gcp_clusters.rb @@ -0,0 +1,44 @@ +class CreateGcpClusters < ActiveRecord::Migration + DOWNTIME = false + + def change + create_table :gcp_clusters do |t| + 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 + t.integer :status + t.string :status_reason + + # k8s integration specific + t.string :project_namespace + + # Cluster details + t.string :endpoint + t.text :ca_cert + t.string :encrypted_kubernetes_token + t.string :encrypted_kubernetes_token_salt + t.string :encrypted_kubernetes_token_iv + t.string :username + t.string :encrypted_password + t.string :encrypted_password_salt + t.string :encrypted_password_iv + + # GKE + t.string :gcp_project_id, null: false + t.string :cluster_zone, null: false + t.string :cluster_name, null: false + t.integer :cluster_size, null: false + t.string :machine_type + t.string :gcp_operation_id + t.string :encrypted_gcp_token + t.string :encrypted_gcp_token_salt + 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 61245f3f666..62802cd20ee 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170924094327) do +ActiveRecord::Schema.define(version: 20170928100231) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -608,6 +608,38 @@ ActiveRecord::Schema.define(version: 20170924094327) do add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree + create_table "gcp_clusters", force: :cascade do |t| + t.integer "project_id", null: false + t.integer "user_id", null: false + t.integer "service_id" + t.boolean "enabled", default: true + t.integer "status" + t.string "status_reason" + t.string "project_namespace" + t.string "endpoint" + t.text "ca_cert" + t.string "encrypted_kubernetes_token" + t.string "encrypted_kubernetes_token_salt" + t.string "encrypted_kubernetes_token_iv" + t.string "username" + t.string "encrypted_password" + t.string "encrypted_password_salt" + t.string "encrypted_password_iv" + t.string "gcp_project_id", null: false + t.string "cluster_zone", null: false + t.string "cluster_name", null: false + t.integer "cluster_size", null: false + t.string "machine_type" + t.string "gcp_operation_id" + t.string "encrypted_gcp_token" + t.string "encrypted_gcp_token_salt" + t.string "encrypted_gcp_token_iv" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "gcp_clusters", ["project_id"], name: "index_gcp_clusters_on_project_id", unique: true, using: :btree + create_table "gpg_keys", force: :cascade do |t| t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "updated_at", null: false @@ -1742,6 +1774,9 @@ ActiveRecord::Schema.define(version: 20170924094327) do add_foreign_key "events", "projects", on_delete: :cascade add_foreign_key "events", "users", column: "author_id", name: "fk_edfd187b6f", on_delete: :cascade add_foreign_key "forked_project_links", "projects", column: "forked_to_project_id", name: "fk_434510edb0", on_delete: :cascade + add_foreign_key "gcp_clusters", "projects", on_delete: :cascade + add_foreign_key "gcp_clusters", "services" + add_foreign_key "gcp_clusters", "users" add_foreign_key "gpg_keys", "users", on_delete: :cascade add_foreign_key "gpg_signatures", "gpg_keys", on_delete: :nullify add_foreign_key "gpg_signatures", "projects", on_delete: :cascade -- cgit v1.2.1 From b0df3c747e38abe8ad1ae00ef57a9d767d16d2b7 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Tue, 3 Oct 2017 11:20:05 +0200 Subject: Remove redundant column from the schema --- db/schema.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 8443f86b21c..c5cac79dbfd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1218,7 +1218,6 @@ ActiveRecord::Schema.define(version: 20170928100231) do t.datetime "last_repository_updated_at" t.integer "storage_version", limit: 2 t.boolean "resolve_outdated_diff_discussions" - t.boolean "merge_requests_ff_only_enabled", default: false, null: false t.boolean "repository_read_only" end -- cgit v1.2.1 From fc95cd5bc6666076b5aceec20046e771f5c126bf Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Tue, 3 Oct 2017 15:03:59 +0200 Subject: fix db schema --- db/schema.rb | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index c5cac79dbfd..5ffcbd30c16 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -32,8 +32,8 @@ ActiveRecord::Schema.define(version: 20170928100231) do t.text "description", null: false t.string "header_logo" t.string "logo" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.text "description_html" t.integer "cached_markdown_version" end @@ -274,8 +274,8 @@ ActiveRecord::Schema.define(version: 20170928100231) do t.string "encrypted_value_iv" t.integer "group_id", null: false t.boolean "protected", default: false, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false end add_index "ci_group_variables", ["group_id", "key"], name: "index_ci_group_variables_on_group_id_and_key", unique: true, using: :btree @@ -287,8 +287,8 @@ ActiveRecord::Schema.define(version: 20170928100231) do t.string "encrypted_value_salt" t.string "encrypted_value_iv" t.integer "pipeline_schedule_id", null: false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime_with_timezone "created_at" + t.datetime_with_timezone "updated_at" end add_index "ci_pipeline_schedule_variables", ["pipeline_schedule_id", "key"], name: "index_ci_pipeline_schedule_variables_on_schedule_id_and_key", unique: true, using: :btree @@ -537,8 +537,8 @@ ActiveRecord::Schema.define(version: 20170928100231) do t.integer "project_id" t.integer "author_id", null: false t.integer "target_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.integer "action", limit: 2, null: false t.string "target_type" end @@ -576,8 +576,8 @@ ActiveRecord::Schema.define(version: 20170928100231) do add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree create_table "gpg_keys", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.integer "user_id" t.binary "primary_keyid" t.binary "fingerprint" @@ -589,8 +589,8 @@ ActiveRecord::Schema.define(version: 20170928100231) do add_index "gpg_keys", ["user_id"], name: "index_gpg_keys_on_user_id", using: :btree create_table "gpg_signatures", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.integer "project_id" t.integer "gpg_key_id" t.binary "commit_sha" @@ -789,8 +789,8 @@ ActiveRecord::Schema.define(version: 20170928100231) do add_index "members", ["user_id"], name: "index_members_on_user_id", using: :btree create_table "merge_request_diff_commits", id: false, force: :cascade do |t| - t.datetime "authored_date" - t.datetime "committed_date" + t.datetime_with_timezone "authored_date" + t.datetime_with_timezone "committed_date" t.integer "merge_request_diff_id", null: false t.integer "relative_order", null: false t.binary "sha", null: false @@ -1115,8 +1115,8 @@ ActiveRecord::Schema.define(version: 20170928100231) do create_table "project_auto_devops", force: :cascade do |t| t.integer "project_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false t.boolean "enabled" t.string "domain" end -- cgit v1.2.1 From 6b7889f750c56962c0674467c3fbfd7976b9b44f Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 3 Oct 2017 23:44:06 +0900 Subject: Implement Policy. Use show instead of edit. Chnage db column. fix comments. dry up workers --- db/migrate/20170924094327_create_gcp_clusters.rb | 11 +++--- db/schema.rb | 46 +++--------------------- 2 files changed, 8 insertions(+), 49 deletions(-) (limited to 'db') diff --git a/db/migrate/20170924094327_create_gcp_clusters.rb b/db/migrate/20170924094327_create_gcp_clusters.rb index 9aa8e537dbe..032db09e748 100644 --- a/db/migrate/20170924094327_create_gcp_clusters.rb +++ b/db/migrate/20170924094327_create_gcp_clusters.rb @@ -19,22 +19,19 @@ class CreateGcpClusters < ActiveRecord::Migration t.string :endpoint t.text :ca_cert t.string :encrypted_kubernetes_token - t.string :encrypted_kubernetes_token_salt t.string :encrypted_kubernetes_token_iv t.string :username t.string :encrypted_password - t.string :encrypted_password_salt t.string :encrypted_password_iv # GKE t.string :gcp_project_id, null: false - t.string :cluster_zone, null: false - t.string :cluster_name, null: false - t.integer :cluster_size, null: false - t.string :machine_type + 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.string :encrypted_gcp_token - t.string :encrypted_gcp_token_salt t.string :encrypted_gcp_token_iv t.datetime_with_timezone :created_at, null: false diff --git a/db/schema.rb b/db/schema.rb index 62802cd20ee..4d8dca384b4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -267,38 +267,6 @@ ActiveRecord::Schema.define(version: 20170928100231) do add_index "ci_builds", ["updated_at"], name: "index_ci_builds_on_updated_at", using: :btree 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", null: false - t.integer "user_id", null: false - t.integer "service_id" - t.boolean "enabled", default: true - t.integer "status" - t.string "status_reason" - t.string "project_namespace" - t.string "endpoint" - t.text "ca_cert" - t.string "encrypted_kubernetes_token" - t.string "encrypted_kubernetes_token_salt" - t.string "encrypted_kubernetes_token_iv" - t.string "username" - t.string "encrypted_password" - t.string "encrypted_password_salt" - t.string "encrypted_password_iv" - t.string "gcp_project_id", null: false - t.string "cluster_zone", null: false - t.string "cluster_name", null: false - t.integer "cluster_size", null: false - t.string "machine_type" - t.string "gcp_operation_id" - t.string "encrypted_gcp_token" - t.string "encrypted_gcp_token_salt" - t.string "encrypted_gcp_token_iv" - t.datetime "created_at", null: false - 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" @@ -619,20 +587,17 @@ ActiveRecord::Schema.define(version: 20170928100231) do t.string "endpoint" t.text "ca_cert" t.string "encrypted_kubernetes_token" - t.string "encrypted_kubernetes_token_salt" t.string "encrypted_kubernetes_token_iv" t.string "username" t.string "encrypted_password" - t.string "encrypted_password_salt" t.string "encrypted_password_iv" t.string "gcp_project_id", null: false - t.string "cluster_zone", null: false - t.string "cluster_name", null: false - t.integer "cluster_size", null: false - t.string "machine_type" + 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.string "encrypted_gcp_token" - t.string "encrypted_gcp_token_salt" t.string "encrypted_gcp_token_iv" t.datetime "created_at", null: false t.datetime "updated_at", null: false @@ -1749,9 +1714,6 @@ ActiveRecord::Schema.define(version: 20170928100231) 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", on_delete: :cascade - add_foreign_key "ci_clusters", "services" - 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 -- cgit v1.2.1 From c6d53250de7f439bc25740913d85ada6e3b2fed4 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 4 Oct 2017 00:20:47 +0200 Subject: Specify defaults, fix policies, fix db columns --- db/migrate/20170924094327_create_gcp_clusters.rb | 12 ++++++------ db/schema.rb | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'db') diff --git a/db/migrate/20170924094327_create_gcp_clusters.rb b/db/migrate/20170924094327_create_gcp_clusters.rb index 032db09e748..42171be7fc4 100644 --- a/db/migrate/20170924094327_create_gcp_clusters.rb +++ b/db/migrate/20170924094327_create_gcp_clusters.rb @@ -4,13 +4,13 @@ class CreateGcpClusters < ActiveRecord::Migration def change create_table :gcp_clusters do |t| 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 + t.references :user, foreign_key: { on_delete: :nullify } + t.references :service, foreign_key: { on_delete: :nullify } # General t.boolean :enabled, default: true t.integer :status - t.string :status_reason + t.text :status_reason # k8s integration specific t.string :project_namespace @@ -18,10 +18,10 @@ class CreateGcpClusters < ActiveRecord::Migration # Cluster details t.string :endpoint t.text :ca_cert - t.string :encrypted_kubernetes_token + t.text :encrypted_kubernetes_token t.string :encrypted_kubernetes_token_iv t.string :username - t.string :encrypted_password + t.text :encrypted_password t.string :encrypted_password_iv # GKE @@ -31,7 +31,7 @@ class CreateGcpClusters < ActiveRecord::Migration t.integer :gcp_cluster_size, null: false t.string :gcp_machine_type t.string :gcp_operation_id - t.string :encrypted_gcp_token + t.text :encrypted_gcp_token t.string :encrypted_gcp_token_iv t.datetime_with_timezone :created_at, null: false diff --git a/db/schema.rb b/db/schema.rb index 9fc8191751c..0056fe7a09f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -577,18 +577,18 @@ ActiveRecord::Schema.define(version: 20170928100231) do create_table "gcp_clusters", force: :cascade do |t| t.integer "project_id", null: false - t.integer "user_id", null: false + t.integer "user_id" t.integer "service_id" t.boolean "enabled", default: true t.integer "status" - t.string "status_reason" + t.text "status_reason" t.string "project_namespace" t.string "endpoint" t.text "ca_cert" - t.string "encrypted_kubernetes_token" + t.text "encrypted_kubernetes_token" t.string "encrypted_kubernetes_token_iv" t.string "username" - t.string "encrypted_password" + t.text "encrypted_password" t.string "encrypted_password_iv" t.string "gcp_project_id", null: false t.string "gcp_cluster_zone", null: false @@ -596,10 +596,10 @@ ActiveRecord::Schema.define(version: 20170928100231) do t.integer "gcp_cluster_size", null: false t.string "gcp_machine_type" t.string "gcp_operation_id" - t.string "encrypted_gcp_token" + t.text "encrypted_gcp_token" t.string "encrypted_gcp_token_iv" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + 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 @@ -1752,8 +1752,8 @@ ActiveRecord::Schema.define(version: 20170928100231) do add_foreign_key "events", "users", column: "author_id", name: "fk_edfd187b6f", on_delete: :cascade add_foreign_key "forked_project_links", "projects", column: "forked_to_project_id", name: "fk_434510edb0", on_delete: :cascade add_foreign_key "gcp_clusters", "projects", on_delete: :cascade - add_foreign_key "gcp_clusters", "services" - add_foreign_key "gcp_clusters", "users" + add_foreign_key "gcp_clusters", "services", on_delete: :nullify + add_foreign_key "gcp_clusters", "users", on_delete: :nullify add_foreign_key "gpg_keys", "users", on_delete: :cascade add_foreign_key "gpg_signatures", "gpg_keys", on_delete: :nullify add_foreign_key "gpg_signatures", "projects", on_delete: :cascade -- cgit v1.2.1 From 8912e99e5f65f148db97688b4d0c99126da222be Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 29 Sep 2017 10:05:11 +0200 Subject: Add failure_reason column to ci_pipelines Conflicts: db/schema.rb --- db/migrate/20170929080234_add_failure_reason_to_pipelines.rb | 9 +++++++++ db/schema.rb | 1 + 2 files changed, 10 insertions(+) create mode 100644 db/migrate/20170929080234_add_failure_reason_to_pipelines.rb (limited to 'db') diff --git a/db/migrate/20170929080234_add_failure_reason_to_pipelines.rb b/db/migrate/20170929080234_add_failure_reason_to_pipelines.rb new file mode 100644 index 00000000000..82adddbc1ec --- /dev/null +++ b/db/migrate/20170929080234_add_failure_reason_to_pipelines.rb @@ -0,0 +1,9 @@ +class AddFailureReasonToPipelines < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_pipelines, :failure_reason, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index fa1aad257db..5ebcf848709 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -342,6 +342,7 @@ ActiveRecord::Schema.define(version: 20171004121444) do t.integer "source" t.integer "config_source" t.boolean "protected" + t.integer "failure_reason" end add_index "ci_pipelines", ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree -- cgit v1.2.1 From 62d540340120baac7fa432108a7847cbc2a1cbe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Tue, 26 Sep 2017 19:42:23 -0500 Subject: Process and create subkeys when a new GPG key is created --- db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb | 10 ++++++++++ db/schema.rb | 1 + 2 files changed, 11 insertions(+) create mode 100644 db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb (limited to 'db') diff --git a/db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb b/db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb new file mode 100644 index 00000000000..ef7675be106 --- /dev/null +++ b/db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb @@ -0,0 +1,10 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddParentIdToGpgKeys < ActiveRecord::Migration + DOWNTIME = false + + def change + add_column :gpg_keys, :parent_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 17be774e9de..9b1457c9a03 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -586,6 +586,7 @@ ActiveRecord::Schema.define(version: 20171004121444) do t.binary "primary_keyid" t.binary "fingerprint" t.text "key" + t.integer "parent_id" end add_index "gpg_keys", ["fingerprint"], name: "index_gpg_keys_on_fingerprint", unique: true, using: :btree -- cgit v1.2.1 From 328f4a505bcd2e7b38f907a24df437f8c35bc3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Wed, 27 Sep 2017 12:27:39 -0500 Subject: Use a separate model to handle GPG subkeys --- db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb | 10 ---------- db/migrate/20170927161718_create_gpg_key_subkeys.rb | 9 +++++++++ db/schema.rb | 10 +++++++++- 3 files changed, 18 insertions(+), 11 deletions(-) delete mode 100644 db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb create mode 100644 db/migrate/20170927161718_create_gpg_key_subkeys.rb (limited to 'db') diff --git a/db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb b/db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb deleted file mode 100644 index ef7675be106..00000000000 --- a/db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb +++ /dev/null @@ -1,10 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddParentIdToGpgKeys < ActiveRecord::Migration - DOWNTIME = false - - def change - add_column :gpg_keys, :parent_id, :integer - end -end diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb new file mode 100644 index 00000000000..d61b669f517 --- /dev/null +++ b/db/migrate/20170927161718_create_gpg_key_subkeys.rb @@ -0,0 +1,9 @@ +class CreateGpgKeySubkeys < ActiveRecord::Migration + def change + create_table :gpg_key_subkeys do |t| + t.binary :keyid + t.binary :fingerprint + t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade } + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 9b1457c9a03..0d02e584d0c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -579,6 +579,14 @@ ActiveRecord::Schema.define(version: 20171004121444) do add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree + create_table "gpg_key_subkeys", force: :cascade do |t| + t.binary "keyid" + t.binary "fingerprint" + t.integer "gpg_key_id", null: false + end + + add_index "gpg_key_subkeys", ["gpg_key_id"], name: "index_gpg_key_subkeys_on_gpg_key_id", using: :btree + create_table "gpg_keys", force: :cascade do |t| t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "updated_at", null: false @@ -586,7 +594,6 @@ ActiveRecord::Schema.define(version: 20171004121444) do t.binary "primary_keyid" t.binary "fingerprint" t.text "key" - t.integer "parent_id" end add_index "gpg_keys", ["fingerprint"], name: "index_gpg_keys_on_fingerprint", unique: true, using: :btree @@ -1727,6 +1734,7 @@ ActiveRecord::Schema.define(version: 20171004121444) do add_foreign_key "events", "projects", on_delete: :cascade add_foreign_key "events", "users", column: "author_id", name: "fk_edfd187b6f", on_delete: :cascade add_foreign_key "forked_project_links", "projects", column: "forked_to_project_id", name: "fk_434510edb0", on_delete: :cascade + add_foreign_key "gpg_key_subkeys", "gpg_keys", on_delete: :cascade add_foreign_key "gpg_keys", "users", on_delete: :cascade add_foreign_key "gpg_signatures", "gpg_keys", on_delete: :nullify add_foreign_key "gpg_signatures", "projects", on_delete: :cascade -- cgit v1.2.1 From 9b4990a4d71b057f0fec14399cd1f2a421901963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Wed, 27 Sep 2017 19:45:19 -0500 Subject: Associate GgpSignature with GpgKeySubkey if comes from a subkey Additionally we're delegating missing method calls on GpgKeySubkey to GpgKey since most of the info required when verifying a signature is found on GpgKey which is the parent of GpgKeySubkey --- .../20170927232658_add_gpg_key_subkey_id_to_gpg_signatures.rb | 10 ++++++++++ db/schema.rb | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 db/migrate/20170927232658_add_gpg_key_subkey_id_to_gpg_signatures.rb (limited to 'db') diff --git a/db/migrate/20170927232658_add_gpg_key_subkey_id_to_gpg_signatures.rb b/db/migrate/20170927232658_add_gpg_key_subkey_id_to_gpg_signatures.rb new file mode 100644 index 00000000000..74b43d732d5 --- /dev/null +++ b/db/migrate/20170927232658_add_gpg_key_subkey_id_to_gpg_signatures.rb @@ -0,0 +1,10 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddGpgKeySubkeyIdToGpgSignatures < ActiveRecord::Migration + DOWNTIME = false + + def change + add_reference(:gpg_signatures, :gpg_key_subkey, index: true, foreign_key: { on_delete: :nullify }) + end +end diff --git a/db/schema.rb b/db/schema.rb index 0d02e584d0c..0beebc16cbb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -610,11 +610,13 @@ ActiveRecord::Schema.define(version: 20171004121444) do t.text "gpg_key_user_name" t.text "gpg_key_user_email" t.integer "verification_status", limit: 2, default: 0, null: false + t.integer "gpg_key_subkey_id" end add_index "gpg_signatures", ["commit_sha"], name: "index_gpg_signatures_on_commit_sha", unique: true, using: :btree add_index "gpg_signatures", ["gpg_key_id"], name: "index_gpg_signatures_on_gpg_key_id", using: :btree add_index "gpg_signatures", ["gpg_key_primary_keyid"], name: "index_gpg_signatures_on_gpg_key_primary_keyid", using: :btree + add_index "gpg_signatures", ["gpg_key_subkey_id"], name: "index_gpg_signatures_on_gpg_key_subkey_id", using: :btree add_index "gpg_signatures", ["project_id"], name: "index_gpg_signatures_on_project_id", using: :btree create_table "identities", force: :cascade do |t| @@ -1736,6 +1738,7 @@ ActiveRecord::Schema.define(version: 20171004121444) do add_foreign_key "forked_project_links", "projects", column: "forked_to_project_id", name: "fk_434510edb0", on_delete: :cascade add_foreign_key "gpg_key_subkeys", "gpg_keys", on_delete: :cascade add_foreign_key "gpg_keys", "users", on_delete: :cascade + add_foreign_key "gpg_signatures", "gpg_key_subkeys", on_delete: :nullify add_foreign_key "gpg_signatures", "gpg_keys", on_delete: :nullify add_foreign_key "gpg_signatures", "projects", on_delete: :cascade add_foreign_key "issue_assignees", "issues", name: "fk_b7d881734a", on_delete: :cascade -- cgit v1.2.1 From 4b6d045c0c3c8d8ab70dd80feb960f193e498d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Wed, 27 Sep 2017 20:47:15 -0500 Subject: Add missing DOWNTIME declaration --- db/migrate/20170927161718_create_gpg_key_subkeys.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'db') diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb index d61b669f517..9f69e299874 100644 --- a/db/migrate/20170927161718_create_gpg_key_subkeys.rb +++ b/db/migrate/20170927161718_create_gpg_key_subkeys.rb @@ -1,4 +1,6 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration + DOWNTIME = false + def change create_table :gpg_key_subkeys do |t| t.binary :keyid -- cgit v1.2.1 From b27549df97151f773c6fbfac4c9dc3aa491a8b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Thu, 28 Sep 2017 13:26:16 -0500 Subject: Add some basic specs and refactor model and validations --- db/migrate/20170927161718_create_gpg_key_subkeys.rb | 14 +++++++++++++- ...170927232658_add_gpg_key_subkey_id_to_gpg_signatures.rb | 10 ---------- db/schema.rb | 2 ++ 3 files changed, 15 insertions(+), 11 deletions(-) delete mode 100644 db/migrate/20170927232658_add_gpg_key_subkey_id_to_gpg_signatures.rb (limited to 'db') diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb index 9f69e299874..ffe06ce1231 100644 --- a/db/migrate/20170927161718_create_gpg_key_subkeys.rb +++ b/db/migrate/20170927161718_create_gpg_key_subkeys.rb @@ -1,11 +1,23 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration DOWNTIME = false - def change + def up create_table :gpg_key_subkeys do |t| t.binary :keyid t.binary :fingerprint + t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade } + + t.index :keyid, unique: true, length: Gitlab::Database.mysql? ? 20 : nil + t.index :fingerprint, unique: true, length: Gitlab::Database.mysql? ? 20 : nil end + + add_reference :gpg_signatures, :gpg_key_subkey, index: true, foreign_key: { on_delete: :nullify } + end + + def down + remove_reference(:gpg_signatures, :gpg_key_subkey, index: true, foreign_key: true) + + drop_table :gpg_key_subkeys end end diff --git a/db/migrate/20170927232658_add_gpg_key_subkey_id_to_gpg_signatures.rb b/db/migrate/20170927232658_add_gpg_key_subkey_id_to_gpg_signatures.rb deleted file mode 100644 index 74b43d732d5..00000000000 --- a/db/migrate/20170927232658_add_gpg_key_subkey_id_to_gpg_signatures.rb +++ /dev/null @@ -1,10 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddGpgKeySubkeyIdToGpgSignatures < ActiveRecord::Migration - DOWNTIME = false - - def change - add_reference(:gpg_signatures, :gpg_key_subkey, index: true, foreign_key: { on_delete: :nullify }) - end -end diff --git a/db/schema.rb b/db/schema.rb index 0beebc16cbb..b9de70b742a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -585,7 +585,9 @@ ActiveRecord::Schema.define(version: 20171004121444) do t.integer "gpg_key_id", null: false end + add_index "gpg_key_subkeys", ["fingerprint"], name: "index_gpg_key_subkeys_on_fingerprint", unique: true, using: :btree add_index "gpg_key_subkeys", ["gpg_key_id"], name: "index_gpg_key_subkeys_on_gpg_key_id", using: :btree + add_index "gpg_key_subkeys", ["keyid"], name: "index_gpg_key_subkeys_on_keyid", unique: true, using: :btree create_table "gpg_keys", force: :cascade do |t| t.datetime_with_timezone "created_at", null: false -- cgit v1.2.1 From ecfe6292d3a5d40d7179cf763fb60cf73adb30e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Mon, 2 Oct 2017 20:46:19 -0500 Subject: Add migration to generate GpgKeySubkeys records and update signatures --- ...create_gpg_key_subkeys_for_existing_gpg_keys.rb | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 db/migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb (limited to 'db') diff --git a/db/migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb b/db/migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb new file mode 100644 index 00000000000..355fbfbbede --- /dev/null +++ b/db/migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb @@ -0,0 +1,59 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CreateGpgKeySubkeysForExistingGpgKeys < ActiveRecord::Migration + disable_ddl_transaction! + + DOWNTIME = false + + class GpgKey < ActiveRecord::Base + self.table_name = 'gpg_keys' + + include EachBatch + include ShaAttribute + + sha_attribute :primary_keyid + sha_attribute :fingerprint + + has_many :subkeys, class_name: 'GpgKeySubkey' + end + + class GpgKeySubkey < ActiveRecord::Base + self.table_name = 'gpg_key_subkeys' + + include ShaAttribute + + sha_attribute :keyid + sha_attribute :fingerprint + end + + def up + GpgKey.each_batch do |batch| + batch.each do |gpg_key| + create_subkeys(gpg_key) && update_signatures(gpg_key) + end + end + end + + def down + end + + private + + def create_subkeys(gpg_key) + gpg_subkeys = Gitlab::Gpg.subkeys_from_key(gpg_key.key) + + gpg_subkeys[gpg_key.primary_keyid.upcase]&.each do |subkey_data| + gpg_key.subkeys.build(keyid: subkey_data[:keyid], fingerprint: subkey_data[:fingerprint]) + end + + # Improve latency by doing all INSERTs in a single call + GpgKey.transaction do + gpg_key.save! + end + end + + def update_signatures(gpg_key) + InvalidGpgSignatureUpdateWorker.perform_async(gpg_key.id) + end +end -- cgit v1.2.1 From 8d296b62e4534820feb94cfe0d8b5d3e34f6ee33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Mon, 2 Oct 2017 21:08:59 -0500 Subject: Convert migration to a post deployment migration This migration can take a bit of time to complete and I don't want to delay the deployment process. --- ...create_gpg_key_subkeys_for_existing_gpg_keys.rb | 59 ---------------------- ...create_gpg_key_subkeys_for_existing_gpg_keys.rb | 59 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 59 deletions(-) delete mode 100644 db/migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb create mode 100644 db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb (limited to 'db') diff --git a/db/migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb b/db/migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb deleted file mode 100644 index 355fbfbbede..00000000000 --- a/db/migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb +++ /dev/null @@ -1,59 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CreateGpgKeySubkeysForExistingGpgKeys < ActiveRecord::Migration - disable_ddl_transaction! - - DOWNTIME = false - - class GpgKey < ActiveRecord::Base - self.table_name = 'gpg_keys' - - include EachBatch - include ShaAttribute - - sha_attribute :primary_keyid - sha_attribute :fingerprint - - has_many :subkeys, class_name: 'GpgKeySubkey' - end - - class GpgKeySubkey < ActiveRecord::Base - self.table_name = 'gpg_key_subkeys' - - include ShaAttribute - - sha_attribute :keyid - sha_attribute :fingerprint - end - - def up - GpgKey.each_batch do |batch| - batch.each do |gpg_key| - create_subkeys(gpg_key) && update_signatures(gpg_key) - end - end - end - - def down - end - - private - - def create_subkeys(gpg_key) - gpg_subkeys = Gitlab::Gpg.subkeys_from_key(gpg_key.key) - - gpg_subkeys[gpg_key.primary_keyid.upcase]&.each do |subkey_data| - gpg_key.subkeys.build(keyid: subkey_data[:keyid], fingerprint: subkey_data[:fingerprint]) - end - - # Improve latency by doing all INSERTs in a single call - GpgKey.transaction do - gpg_key.save! - end - end - - def update_signatures(gpg_key) - InvalidGpgSignatureUpdateWorker.perform_async(gpg_key.id) - end -end diff --git a/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb b/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb new file mode 100644 index 00000000000..355fbfbbede --- /dev/null +++ b/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb @@ -0,0 +1,59 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CreateGpgKeySubkeysForExistingGpgKeys < ActiveRecord::Migration + disable_ddl_transaction! + + DOWNTIME = false + + class GpgKey < ActiveRecord::Base + self.table_name = 'gpg_keys' + + include EachBatch + include ShaAttribute + + sha_attribute :primary_keyid + sha_attribute :fingerprint + + has_many :subkeys, class_name: 'GpgKeySubkey' + end + + class GpgKeySubkey < ActiveRecord::Base + self.table_name = 'gpg_key_subkeys' + + include ShaAttribute + + sha_attribute :keyid + sha_attribute :fingerprint + end + + def up + GpgKey.each_batch do |batch| + batch.each do |gpg_key| + create_subkeys(gpg_key) && update_signatures(gpg_key) + end + end + end + + def down + end + + private + + def create_subkeys(gpg_key) + gpg_subkeys = Gitlab::Gpg.subkeys_from_key(gpg_key.key) + + gpg_subkeys[gpg_key.primary_keyid.upcase]&.each do |subkey_data| + gpg_key.subkeys.build(keyid: subkey_data[:keyid], fingerprint: subkey_data[:fingerprint]) + end + + # Improve latency by doing all INSERTs in a single call + GpgKey.transaction do + gpg_key.save! + end + end + + def update_signatures(gpg_key) + InvalidGpgSignatureUpdateWorker.perform_async(gpg_key.id) + end +end -- cgit v1.2.1 From 2577cc99818bd0332aa78018de666579971341c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Wed, 4 Oct 2017 10:34:50 -0500 Subject: Address some feedback from last code review --- db/migrate/20170927161718_create_gpg_key_subkeys.rb | 4 ++-- .../20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb | 4 +++- db/schema.rb | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb index ffe06ce1231..c03c40416a8 100644 --- a/db/migrate/20170927161718_create_gpg_key_subkeys.rb +++ b/db/migrate/20170927161718_create_gpg_key_subkeys.rb @@ -3,11 +3,11 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration def up create_table :gpg_key_subkeys do |t| + t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade } + t.binary :keyid t.binary :fingerprint - t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade } - t.index :keyid, unique: true, length: Gitlab::Database.mysql? ? 20 : nil t.index :fingerprint, unique: true, length: Gitlab::Database.mysql? ? 20 : nil end diff --git a/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb b/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb index 355fbfbbede..346dfb1a4b6 100644 --- a/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb +++ b/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb @@ -28,8 +28,10 @@ class CreateGpgKeySubkeysForExistingGpgKeys < ActiveRecord::Migration end def up - GpgKey.each_batch do |batch| + GpgKey.with_subkeys.each_batch do |batch| batch.each do |gpg_key| + return if gpg_key.subkeys.any? + create_subkeys(gpg_key) && update_signatures(gpg_key) end end diff --git a/db/schema.rb b/db/schema.rb index b9de70b742a..3bcfbcc3fd1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -580,9 +580,9 @@ ActiveRecord::Schema.define(version: 20171004121444) do add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree create_table "gpg_key_subkeys", force: :cascade do |t| + t.integer "gpg_key_id", null: false t.binary "keyid" t.binary "fingerprint" - t.integer "gpg_key_id", null: false end add_index "gpg_key_subkeys", ["fingerprint"], name: "index_gpg_key_subkeys_on_fingerprint", unique: true, using: :btree -- cgit v1.2.1 From dd139e65b53f30eae2d8bb50dff180e8eab11fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Wed, 4 Oct 2017 18:44:49 -0500 Subject: Invalidate GpgSignatures associated to GpgKeySubkeys when revoking the GpgKey --- .../20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb b/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb index 346dfb1a4b6..04c81ea684f 100644 --- a/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb +++ b/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb @@ -30,7 +30,7 @@ class CreateGpgKeySubkeysForExistingGpgKeys < ActiveRecord::Migration def up GpgKey.with_subkeys.each_batch do |batch| batch.each do |gpg_key| - return if gpg_key.subkeys.any? + next if gpg_key.subkeys.any? create_subkeys(gpg_key) && update_signatures(gpg_key) end -- cgit v1.2.1 From 6e0a4fc10e745f8d8be65f8ee420c75d36057c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Thu, 5 Oct 2017 08:14:34 -0500 Subject: Convert migrations to generate subkeys to a background migration --- ...create_gpg_key_subkeys_for_existing_gpg_keys.rb | 61 ---------------------- ...chedule_create_gpg_key_subkeys_from_gpg_keys.rb | 25 +++++++++ db/schema.rb | 2 +- 3 files changed, 26 insertions(+), 62 deletions(-) delete mode 100644 db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb create mode 100644 db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb (limited to 'db') diff --git a/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb b/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb deleted file mode 100644 index 04c81ea684f..00000000000 --- a/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb +++ /dev/null @@ -1,61 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CreateGpgKeySubkeysForExistingGpgKeys < ActiveRecord::Migration - disable_ddl_transaction! - - DOWNTIME = false - - class GpgKey < ActiveRecord::Base - self.table_name = 'gpg_keys' - - include EachBatch - include ShaAttribute - - sha_attribute :primary_keyid - sha_attribute :fingerprint - - has_many :subkeys, class_name: 'GpgKeySubkey' - end - - class GpgKeySubkey < ActiveRecord::Base - self.table_name = 'gpg_key_subkeys' - - include ShaAttribute - - sha_attribute :keyid - sha_attribute :fingerprint - end - - def up - GpgKey.with_subkeys.each_batch do |batch| - batch.each do |gpg_key| - next if gpg_key.subkeys.any? - - create_subkeys(gpg_key) && update_signatures(gpg_key) - end - end - end - - def down - end - - private - - def create_subkeys(gpg_key) - gpg_subkeys = Gitlab::Gpg.subkeys_from_key(gpg_key.key) - - gpg_subkeys[gpg_key.primary_keyid.upcase]&.each do |subkey_data| - gpg_key.subkeys.build(keyid: subkey_data[:keyid], fingerprint: subkey_data[:fingerprint]) - end - - # Improve latency by doing all INSERTs in a single call - GpgKey.transaction do - gpg_key.save! - end - end - - def update_signatures(gpg_key) - InvalidGpgSignatureUpdateWorker.perform_async(gpg_key.id) - end -end diff --git a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb new file mode 100644 index 00000000000..c8bbfbccc08 --- /dev/null +++ b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb @@ -0,0 +1,25 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class ScheduleCreateGpgKeySubkeysFromGpgKeys < ActiveRecord::Migration + disable_ddl_transaction! + + DOWNTIME = false + + class GpgKey < ActiveRecord::Base + self.table_name = 'gpg_keys' + end + + def up + GpgKey.select(:id).in_batches do |relation| + jobs = relation.pluck(:id).map do |id| + ['CreateGpgKeySubkeysFromGpgKeys', [id]] + end + + BackgroundMigrationWorker.perform_bulk(jobs) + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 3bcfbcc3fd1..3a69e3d3056 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171004121444) do +ActiveRecord::Schema.define(version: 20171005130944) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.1 From 2178cd44c59effb67cef0743064a75f5073c9f45 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Thu, 5 Oct 2017 17:09:00 +0200 Subject: Optimise gcp_clusters table schema --- db/migrate/20170924094327_create_gcp_clusters.rb | 16 ++++++++++------ db/schema.rb | 8 ++++---- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'db') 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 -- cgit v1.2.1 From 5595d73763caf224df4109ab2d52e616cd843d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Thu, 5 Oct 2017 10:17:18 -0500 Subject: Small refactor and fix for RuboCop --- .../20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb index c8bbfbccc08..08c9ce1d3bb 100644 --- a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb +++ b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb @@ -8,11 +8,13 @@ class ScheduleCreateGpgKeySubkeysFromGpgKeys < ActiveRecord::Migration class GpgKey < ActiveRecord::Base self.table_name = 'gpg_keys' + + include EachBatch end def up - GpgKey.select(:id).in_batches do |relation| - jobs = relation.pluck(:id).map do |id| + GpgKey.select(:id).each_batch do |gpg_keys| + jobs = gpg_keys.pluck(:id).map do |id| ['CreateGpgKeySubkeysFromGpgKeys', [id]] end -- cgit v1.2.1 From 555f50b3e68e82968ea2eb4916a3f5beeeef7b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Thu, 5 Oct 2017 22:43:44 -0500 Subject: Add more specs. --- .../20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb index 08c9ce1d3bb..01d56fbd490 100644 --- a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb +++ b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb @@ -5,6 +5,7 @@ class ScheduleCreateGpgKeySubkeysFromGpgKeys < ActiveRecord::Migration disable_ddl_transaction! DOWNTIME = false + MIGRATION = 'CreateGpgKeySubkeysFromGpgKeys' class GpgKey < ActiveRecord::Base self.table_name = 'gpg_keys' @@ -15,7 +16,7 @@ class ScheduleCreateGpgKeySubkeysFromGpgKeys < ActiveRecord::Migration def up GpgKey.select(:id).each_batch do |gpg_keys| jobs = gpg_keys.pluck(:id).map do |id| - ['CreateGpgKeySubkeysFromGpgKeys', [id]] + [MIGRATION, [id]] end BackgroundMigrationWorker.perform_bulk(jobs) -- cgit v1.2.1