From f211e47eb20959fdebc5ae0aabf66267ea521ee7 Mon Sep 17 00:00:00 2001 From: haseeb Date: Fri, 9 Feb 2018 23:53:55 +0530 Subject: closed by field added --- db/migrate/20180209165249_add_closed_by_to_issues.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/migrate/20180209165249_add_closed_by_to_issues.rb (limited to 'db') diff --git a/db/migrate/20180209165249_add_closed_by_to_issues.rb b/db/migrate/20180209165249_add_closed_by_to_issues.rb new file mode 100644 index 00000000000..043e3ef8688 --- /dev/null +++ b/db/migrate/20180209165249_add_closed_by_to_issues.rb @@ -0,0 +1,13 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddClosedByToIssues < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def change + add_column :issues, :closed_by_id, :integer + end +end -- cgit v1.2.1 From 9b0e8a09b1b35cc8fc893003afc59c78f5dc846f Mon Sep 17 00:00:00 2001 From: haseeb Date: Tue, 27 Feb 2018 21:48:01 +0530 Subject: added forign key and specs --- db/migrate/20180209165249_add_closed_by_to_issues.rb | 9 ++++++++- db/schema.rb | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20180209165249_add_closed_by_to_issues.rb b/db/migrate/20180209165249_add_closed_by_to_issues.rb index 043e3ef8688..e251afd7b49 100644 --- a/db/migrate/20180209165249_add_closed_by_to_issues.rb +++ b/db/migrate/20180209165249_add_closed_by_to_issues.rb @@ -4,10 +4,17 @@ class AddClosedByToIssues < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! # Set this constant to true if this migration requires downtime. DOWNTIME = false - def change + def up add_column :issues, :closed_by_id, :integer + add_concurrent_foreign_key :issues, :users, column: :closed_by_id, on_delete: :nullify + end + + def down + remove_foreign_key :issues, column: :closed_by_id + remove_column :issues, :closed_by_id end end diff --git a/db/schema.rb b/db/schema.rb index 5bb461169f1..cb4362a5306 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -876,6 +876,7 @@ ActiveRecord::Schema.define(version: 20180216121030) do t.integer "last_edited_by_id" t.boolean "discussion_locked" t.datetime_with_timezone "closed_at" + t.integer "closed_by_id" end add_index "issues", ["author_id"], name: "index_issues_on_author_id", using: :btree @@ -2013,6 +2014,7 @@ ActiveRecord::Schema.define(version: 20180216121030) do add_foreign_key "issues", "milestones", name: "fk_96b1dd429c", on_delete: :nullify add_foreign_key "issues", "projects", name: "fk_899c8f3231", on_delete: :cascade add_foreign_key "issues", "users", column: "author_id", name: "fk_05f1e72feb", on_delete: :nullify + add_foreign_key "issues", "users", column: "closed_by_id", name: "fk_c63cbf6c25", on_delete: :nullify add_foreign_key "issues", "users", column: "updated_by_id", name: "fk_ffed080f01", on_delete: :nullify add_foreign_key "label_priorities", "labels", on_delete: :cascade add_foreign_key "label_priorities", "projects", on_delete: :cascade -- cgit v1.2.1 From 93bf4d1f264b4609137e4afd9d0728bc47a1964f Mon Sep 17 00:00:00 2001 From: haseeb Date: Tue, 27 Feb 2018 22:14:47 +0530 Subject: schema version change --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index cb4362a5306..ae3585d1030 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: 20180216121030) do +ActiveRecord::Schema.define(version: 20180209165249) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.1 From fdc4aeb26982c94d876024a3d56b56ba6358b62e Mon Sep 17 00:00:00 2001 From: haseeb Date: Wed, 28 Feb 2018 19:40:05 +0530 Subject: schema version change --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index ae3585d1030..cb4362a5306 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: 20180209165249) do +ActiveRecord::Schema.define(version: 20180216121030) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.1 From 52967b107b7b2f1472b4c005f70f21346079cd95 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 3 Apr 2018 11:00:33 +0000 Subject: Merge branch 'jej/mattermost-notification-confidentiality-10-6' into 'security-10-6' [10.6] Prevent notes on confidential issues from being sent to chat See merge request gitlab/gitlabhq!2366 # Conflicts: # app/helpers/services_helper.rb --- ...26_add_confidential_note_events_to_web_hooks.rb | 15 ++++++++++++++ ...548_add_confidential_note_events_to_services.rb | 16 +++++++++++++++ ...ule_set_confidential_note_events_on_webhooks.rb | 23 ++++++++++++++++++++++ ...ule_set_confidential_note_events_on_services.rb | 23 ++++++++++++++++++++++ db/schema.rb | 2 ++ 5 files changed, 79 insertions(+) create mode 100644 db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb create mode 100644 db/migrate/20180103123548_add_confidential_note_events_to_services.rb create mode 100644 db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb create mode 100644 db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb (limited to 'db') diff --git a/db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb b/db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb new file mode 100644 index 00000000000..900a6386922 --- /dev/null +++ b/db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb @@ -0,0 +1,15 @@ +class AddConfidentialNoteEventsToWebHooks < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column :web_hooks, :confidential_note_events, :boolean + end + + def down + remove_column :web_hooks, :confidential_note_events + end +end diff --git a/db/migrate/20180103123548_add_confidential_note_events_to_services.rb b/db/migrate/20180103123548_add_confidential_note_events_to_services.rb new file mode 100644 index 00000000000..b54ad88df43 --- /dev/null +++ b/db/migrate/20180103123548_add_confidential_note_events_to_services.rb @@ -0,0 +1,16 @@ +class AddConfidentialNoteEventsToServices < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column :services, :confidential_note_events, :boolean + change_column_default :services, :confidential_note_events, true + end + + def down + remove_column :services, :confidential_note_events + end +end diff --git a/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb b/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb new file mode 100644 index 00000000000..fa51ac83619 --- /dev/null +++ b/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb @@ -0,0 +1,23 @@ +class ScheduleSetConfidentialNoteEventsOnWebhooks < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 1_000 + INTERVAL = 5.minutes + + disable_ddl_transaction! + + def up + migration = Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks + migration_name = migration.to_s.demodulize + relation = migration::WebHook.hooks_to_update + + queue_background_migration_jobs_by_range_at_intervals(relation, + migration_name, + INTERVAL, + batch_size: BATCH_SIZE) + end + + def down + end +end diff --git a/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb b/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb new file mode 100644 index 00000000000..a3ff9f1719e --- /dev/null +++ b/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb @@ -0,0 +1,23 @@ +class ScheduleSetConfidentialNoteEventsOnServices < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 1_000 + INTERVAL = 20.minutes + + disable_ddl_transaction! + + def up + migration = Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices + migration_name = migration.to_s.demodulize + relation = migration::Service.services_to_update + + queue_background_migration_jobs_by_range_at_intervals(relation, + migration_name, + INTERVAL, + batch_size: BATCH_SIZE) + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 06fc1a9d7e9..25e7d720761 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1684,6 +1684,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do t.boolean "confidential_issues_events", default: true, null: false t.boolean "commit_events", default: true, null: false t.boolean "job_events", default: false, null: false + t.boolean "confidential_note_events", default: true end add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree @@ -2022,6 +2023,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do t.boolean "confidential_issues_events", default: false, null: false t.boolean "repository_update_events", default: false, null: false t.boolean "job_events", default: false, null: false + t.boolean "confidential_note_events" end add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree -- cgit v1.2.1 From dbee81480b6a2a88535a0b042012c9fbf287e32b Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 5 Apr 2018 10:53:39 +0200 Subject: Reschedule pipeline stages migration to run it again --- ...0180212101928_schedule_build_stage_migration.rb | 25 ++++------------ ...405101928_reschedule_builds_stages_migration.rb | 33 ++++++++++++++++++++++ db/schema.rb | 2 +- 3 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb (limited to 'db') diff --git a/db/post_migrate/20180212101928_schedule_build_stage_migration.rb b/db/post_migrate/20180212101928_schedule_build_stage_migration.rb index df15b2cd9d4..0f61fa81832 100644 --- a/db/post_migrate/20180212101928_schedule_build_stage_migration.rb +++ b/db/post_migrate/20180212101928_schedule_build_stage_migration.rb @@ -1,26 +1,11 @@ class ScheduleBuildStageMigration < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - MIGRATION = 'MigrateBuildStage'.freeze - BATCH_SIZE = 500 - - disable_ddl_transaction! - - class Build < ActiveRecord::Base - include EachBatch - self.table_name = 'ci_builds' - end + ## + # This migration has been rescheduled to run again, see + # `20180405101928_reschedule_builds_stages_migration.rb` + # def up - disable_statement_timeout - - Build.where('stage_id IS NULL').tap do |relation| - queue_background_migration_jobs_by_range_at_intervals(relation, - MIGRATION, - 5.minutes, - batch_size: BATCH_SIZE) - end + # noop end def down diff --git a/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb b/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb new file mode 100644 index 00000000000..e19387bce1e --- /dev/null +++ b/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb @@ -0,0 +1,33 @@ +class RescheduleBuildsStagesMigration < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + ## + # Rescheduled `20180212101928_schedule_build_stage_migration.rb` + # + + DOWNTIME = false + MIGRATION = 'MigrateBuildStage'.freeze + BATCH_SIZE = 500 + + disable_ddl_transaction! + + class Build < ActiveRecord::Base + include EachBatch + self.table_name = 'ci_builds' + end + + def up + disable_statement_timeout + + Build.where('stage_id IS NULL').tap do |relation| + queue_background_migration_jobs_by_range_at_intervals(relation, + MIGRATION, + 5.minutes, + batch_size: BATCH_SIZE) + end + end + + def down + # noop + end +end diff --git a/db/schema.rb b/db/schema.rb index 06fc1a9d7e9..1dd87c12144 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: 20180327101207) do +ActiveRecord::Schema.define(version: 20180405101928) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.1 From db18993f652425b72c4b854e18a002e0ec44b196 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Mon, 19 Mar 2018 10:11:12 -0600 Subject: Create barebones for Deploytoken Includes: - Model, factories, create service and controller actions - As usual, includes specs for everything - Builds UI (copy from PAT) - Add revoke action Closes #31591 --- db/migrate/20180319190020_create_deploy_tokens.rb | 16 ++++++++++++++++ db/schema.rb | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 db/migrate/20180319190020_create_deploy_tokens.rb (limited to 'db') diff --git a/db/migrate/20180319190020_create_deploy_tokens.rb b/db/migrate/20180319190020_create_deploy_tokens.rb new file mode 100644 index 00000000000..53808300fc1 --- /dev/null +++ b/db/migrate/20180319190020_create_deploy_tokens.rb @@ -0,0 +1,16 @@ +class CreateDeployTokens < ActiveRecord::Migration + DOWNTIME = false + + def change + create_table :deploy_tokens do |t| + t.references :project, index: true, foreign_key: true, null: false + t.string :name, null: false + t.string :token, index: { unique: true }, null: false + t.string :scopes + t.boolean :revoked, default: false + t.datetime :expires_at + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 2cd51b200b3..333baa245b7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -683,6 +683,20 @@ ActiveRecord::Schema.define(version: 20180405101928) do add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree + create_table "deploy_tokens", force: :cascade do |t| + t.integer "project_id", null: false + t.string "name", null: false + t.string "token", null: false + t.string "scopes" + t.boolean "revoked", default: false + t.datetime "expires_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "deploy_tokens", ["project_id"], name: "index_deploy_tokens_on_project_id", using: :btree + add_index "deploy_tokens", ["token"], name: "index_deploy_tokens_on_token", unique: true, using: :btree + create_table "deployments", force: :cascade do |t| t.integer "iid", null: false t.integer "project_id", null: false @@ -2072,6 +2086,7 @@ ActiveRecord::Schema.define(version: 20180405101928) do add_foreign_key "clusters_applications_runners", "clusters", on_delete: :cascade add_foreign_key "container_repositories", "projects" add_foreign_key "deploy_keys_projects", "projects", name: "fk_58a901ca7e", on_delete: :cascade + add_foreign_key "deploy_tokens", "projects" add_foreign_key "deployments", "projects", name: "fk_b9a3851b82", on_delete: :cascade add_foreign_key "environments", "projects", name: "fk_d1c8c1da6a", on_delete: :cascade add_foreign_key "events", "projects", on_delete: :cascade -- cgit v1.2.1 From 8315861c9a50675b4f4f4ca536f0da90f27994f3 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Thu, 5 Apr 2018 12:22:34 -0500 Subject: Include ProjectDeployTokens Also: - Changes scopes from serializer to use boolean columns - Fixes broken specs --- db/migrate/20180319190020_create_deploy_tokens.rb | 4 ++-- .../20180405142733_create_project_deploy_tokens.rb | 24 ++++++++++++++++++++++ db/schema.rb | 16 +++++++++++---- 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20180405142733_create_project_deploy_tokens.rb (limited to 'db') diff --git a/db/migrate/20180319190020_create_deploy_tokens.rb b/db/migrate/20180319190020_create_deploy_tokens.rb index 53808300fc1..dfe85b3b552 100644 --- a/db/migrate/20180319190020_create_deploy_tokens.rb +++ b/db/migrate/20180319190020_create_deploy_tokens.rb @@ -3,10 +3,10 @@ class CreateDeployTokens < ActiveRecord::Migration def change create_table :deploy_tokens do |t| - t.references :project, index: true, foreign_key: true, null: false t.string :name, null: false t.string :token, index: { unique: true }, null: false - t.string :scopes + t.boolean :read_repository, default: false + t.boolean :read_registry, default: false t.boolean :revoked, default: false t.datetime :expires_at diff --git a/db/migrate/20180405142733_create_project_deploy_tokens.rb b/db/migrate/20180405142733_create_project_deploy_tokens.rb new file mode 100644 index 00000000000..c12f468828b --- /dev/null +++ b/db/migrate/20180405142733_create_project_deploy_tokens.rb @@ -0,0 +1,24 @@ +class CreateProjectDeployTokens < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + create_table :project_deploy_tokens do |t| + t.integer :project_id, null: false + t.integer :deploy_token_id, null: false + + t.timestamps null: false + end + + add_concurrent_index :project_deploy_tokens, [:project_id, :deploy_token_id] + end + + def down + drop_table :project_deploy_tokens + + remove_index :project_deploy_tokens, column: [:project_id, :deploy_token_id] if index_exists?(:project_deploy_tokens, [:project_id, :deploy_token_id]) + end +end diff --git a/db/schema.rb b/db/schema.rb index 333baa245b7..6f1f3ba3e89 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: 20180405101928) do +ActiveRecord::Schema.define(version: 20180405142733) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -684,17 +684,16 @@ ActiveRecord::Schema.define(version: 20180405101928) do add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree create_table "deploy_tokens", force: :cascade do |t| - t.integer "project_id", null: false t.string "name", null: false t.string "token", null: false - t.string "scopes" + t.boolean "read_repository", default: false + t.boolean "read_registry", default: false t.boolean "revoked", default: false t.datetime "expires_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - add_index "deploy_tokens", ["project_id"], name: "index_deploy_tokens_on_project_id", using: :btree add_index "deploy_tokens", ["token"], name: "index_deploy_tokens_on_token", unique: true, using: :btree create_table "deployments", force: :cascade do |t| @@ -1444,6 +1443,15 @@ ActiveRecord::Schema.define(version: 20180405101928) do add_index "project_custom_attributes", ["key", "value"], name: "index_project_custom_attributes_on_key_and_value", using: :btree add_index "project_custom_attributes", ["project_id", "key"], name: "index_project_custom_attributes_on_project_id_and_key", unique: true, using: :btree + create_table "project_deploy_tokens", force: :cascade do |t| + t.integer "project_id", null: false + t.integer "deploy_token_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "project_deploy_tokens", ["project_id", "deploy_token_id"], name: "index_project_deploy_tokens_on_project_id_and_deploy_token_id", using: :btree + create_table "project_features", force: :cascade do |t| t.integer "project_id" t.integer "merge_requests_access_level" -- cgit v1.2.1 From 6b2954ec8a2e17c913872c32386cb2b08f2db1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Thu, 5 Apr 2018 23:37:39 +0200 Subject: Fix and optimise DB schema --- db/migrate/20180319190020_create_deploy_tokens.rb | 11 ++++++----- db/migrate/20180405142733_create_project_deploy_tokens.rb | 15 +++++---------- db/schema.rb | 14 ++++++++------ 3 files changed, 19 insertions(+), 21 deletions(-) (limited to 'db') diff --git a/db/migrate/20180319190020_create_deploy_tokens.rb b/db/migrate/20180319190020_create_deploy_tokens.rb index dfe85b3b552..6a681ba79d6 100644 --- a/db/migrate/20180319190020_create_deploy_tokens.rb +++ b/db/migrate/20180319190020_create_deploy_tokens.rb @@ -3,14 +3,15 @@ class CreateDeployTokens < ActiveRecord::Migration def change create_table :deploy_tokens do |t| - t.string :name, null: false - t.string :token, index: { unique: true }, null: false - t.boolean :read_repository, default: false - t.boolean :read_registry, default: false t.boolean :revoked, default: false - t.datetime :expires_at + t.boolean :read_repository, null: false, default: false + t.boolean :read_registry, null: false, default: false + t.datetime :expires_at t.timestamps null: false + + t.string :name, null: false + t.string :token, index: { unique: true }, null: false end end end diff --git a/db/migrate/20180405142733_create_project_deploy_tokens.rb b/db/migrate/20180405142733_create_project_deploy_tokens.rb index c12f468828b..6cfb092a420 100644 --- a/db/migrate/20180405142733_create_project_deploy_tokens.rb +++ b/db/migrate/20180405142733_create_project_deploy_tokens.rb @@ -3,22 +3,17 @@ class CreateProjectDeployTokens < ActiveRecord::Migration DOWNTIME = false - disable_ddl_transaction! - - def up + def change create_table :project_deploy_tokens do |t| t.integer :project_id, null: false t.integer :deploy_token_id, null: false + t.foreign_key :deploy_tokens, column: :deploy_token_id, on_delete: :cascade + t.foreign_key :projects, column: :project_id, on_delete: :cascade + t.timestamps null: false end - add_concurrent_index :project_deploy_tokens, [:project_id, :deploy_token_id] - end - - def down - drop_table :project_deploy_tokens - - remove_index :project_deploy_tokens, column: [:project_id, :deploy_token_id] if index_exists?(:project_deploy_tokens, [:project_id, :deploy_token_id]) + add_index :project_deploy_tokens, [:project_id, :deploy_token_id], unique: true end end diff --git a/db/schema.rb b/db/schema.rb index 6f1f3ba3e89..50b8635cb96 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -684,14 +684,14 @@ ActiveRecord::Schema.define(version: 20180405142733) do add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree create_table "deploy_tokens", force: :cascade do |t| - t.string "name", null: false - t.string "token", null: false - t.boolean "read_repository", default: false - t.boolean "read_registry", default: false t.boolean "revoked", default: false + t.boolean "read_repository", default: false, null: false + t.boolean "read_registry", default: false, null: false t.datetime "expires_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "name", null: false + t.string "token", null: false end add_index "deploy_tokens", ["token"], name: "index_deploy_tokens_on_token", unique: true, using: :btree @@ -1450,7 +1450,7 @@ ActiveRecord::Schema.define(version: 20180405142733) do t.datetime "updated_at", null: false end - add_index "project_deploy_tokens", ["project_id", "deploy_token_id"], name: "index_project_deploy_tokens_on_project_id_and_deploy_token_id", using: :btree + add_index "project_deploy_tokens", ["project_id", "deploy_token_id"], name: "index_project_deploy_tokens_on_project_id_and_deploy_token_id", unique: true, using: :btree create_table "project_features", force: :cascade do |t| t.integer "project_id" @@ -1639,6 +1639,7 @@ ActiveRecord::Schema.define(version: 20180405142733) do t.string "path", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.boolean "permanent" end add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree @@ -2094,7 +2095,6 @@ ActiveRecord::Schema.define(version: 20180405142733) do add_foreign_key "clusters_applications_runners", "clusters", on_delete: :cascade add_foreign_key "container_repositories", "projects" add_foreign_key "deploy_keys_projects", "projects", name: "fk_58a901ca7e", on_delete: :cascade - add_foreign_key "deploy_tokens", "projects" add_foreign_key "deployments", "projects", name: "fk_b9a3851b82", on_delete: :cascade add_foreign_key "environments", "projects", name: "fk_d1c8c1da6a", on_delete: :cascade add_foreign_key "events", "projects", on_delete: :cascade @@ -2160,6 +2160,8 @@ ActiveRecord::Schema.define(version: 20180405142733) do add_foreign_key "project_authorizations", "users", on_delete: :cascade add_foreign_key "project_auto_devops", "projects", on_delete: :cascade add_foreign_key "project_custom_attributes", "projects", on_delete: :cascade + add_foreign_key "project_deploy_tokens", "deploy_tokens", on_delete: :cascade + add_foreign_key "project_deploy_tokens", "projects", on_delete: :cascade add_foreign_key "project_features", "projects", name: "fk_18513d9b92", on_delete: :cascade add_foreign_key "project_group_links", "projects", name: "fk_daa8cee94c", on_delete: :cascade add_foreign_key "project_import_data", "projects", name: "fk_ffb9ee3a10", on_delete: :cascade -- cgit v1.2.1 From 2c6c61815edada16c4477c938209c24c647e1798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Fri, 6 Apr 2018 00:07:36 +0200 Subject: Get rid of Redis when dealing with deploy tokens We use controller actions to pass a newly created token and errors --- db/migrate/20180405142733_create_project_deploy_tokens.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/migrate/20180405142733_create_project_deploy_tokens.rb b/db/migrate/20180405142733_create_project_deploy_tokens.rb index 6cfb092a420..adc4c526c9b 100644 --- a/db/migrate/20180405142733_create_project_deploy_tokens.rb +++ b/db/migrate/20180405142733_create_project_deploy_tokens.rb @@ -7,13 +7,12 @@ class CreateProjectDeployTokens < ActiveRecord::Migration create_table :project_deploy_tokens do |t| t.integer :project_id, null: false t.integer :deploy_token_id, null: false + t.timestamps null: false t.foreign_key :deploy_tokens, column: :deploy_token_id, on_delete: :cascade t.foreign_key :projects, column: :project_id, on_delete: :cascade - t.timestamps null: false + t.index [:project_id, :deploy_token_id], unique: true end - - add_index :project_deploy_tokens, [:project_id, :deploy_token_id], unique: true end end -- cgit v1.2.1 From a475411f4380ef4d0260940206e2553da3b2f3ee Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Thu, 5 Apr 2018 20:04:11 -0500 Subject: Fixes broken schema and minor changes --- db/schema.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 50b8635cb96..0c8938b015d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1639,7 +1639,6 @@ ActiveRecord::Schema.define(version: 20180405142733) do t.string "path", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.boolean "permanent" end add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree -- cgit v1.2.1 From 29913816309c6f6387b20c8702bcc8e90ef3a984 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Fri, 6 Apr 2018 09:30:21 -0500 Subject: Addresses database comments - Adds a default on expires_at datetime - Modifies deploy tokens views to handle default expires at value - Use datetime_with_timezone where possible - Remove unused scopes --- db/migrate/20180319190020_create_deploy_tokens.rb | 6 ++++-- db/migrate/20180405142733_create_project_deploy_tokens.rb | 4 +--- db/schema.rb | 9 ++++----- 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'db') diff --git a/db/migrate/20180319190020_create_deploy_tokens.rb b/db/migrate/20180319190020_create_deploy_tokens.rb index 6a681ba79d6..b8f77f5ae17 100644 --- a/db/migrate/20180319190020_create_deploy_tokens.rb +++ b/db/migrate/20180319190020_create_deploy_tokens.rb @@ -7,11 +7,13 @@ class CreateDeployTokens < ActiveRecord::Migration t.boolean :read_repository, null: false, default: false t.boolean :read_registry, null: false, default: false - t.datetime :expires_at - t.timestamps null: false + t.datetime_with_timezone :expires_at, null: false, default: '3000-01-01' + t.datetime_with_timezone :created_at, null: false t.string :name, null: false t.string :token, index: { unique: true }, null: false + + t.index [:token, :expires_at], where: "(revoked IS FALSE)" end end end diff --git a/db/migrate/20180405142733_create_project_deploy_tokens.rb b/db/migrate/20180405142733_create_project_deploy_tokens.rb index adc4c526c9b..9d8f89243a8 100644 --- a/db/migrate/20180405142733_create_project_deploy_tokens.rb +++ b/db/migrate/20180405142733_create_project_deploy_tokens.rb @@ -1,13 +1,11 @@ class CreateProjectDeployTokens < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - DOWNTIME = false def change create_table :project_deploy_tokens do |t| t.integer :project_id, null: false t.integer :deploy_token_id, null: false - t.timestamps null: false + t.datetime_with_timezone :created_at, null: false t.foreign_key :deploy_tokens, column: :deploy_token_id, on_delete: :cascade t.foreign_key :projects, column: :project_id, on_delete: :cascade diff --git a/db/schema.rb b/db/schema.rb index 0c8938b015d..b0174a4ed46 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -687,13 +687,13 @@ ActiveRecord::Schema.define(version: 20180405142733) do t.boolean "revoked", default: false t.boolean "read_repository", default: false, null: false t.boolean "read_registry", default: false, null: false - t.datetime "expires_at" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "expires_at", default: '3000-01-01 00:00:00', null: false + t.datetime_with_timezone "created_at", null: false t.string "name", null: false t.string "token", null: false end + add_index "deploy_tokens", ["token", "expires_at"], name: "index_deploy_tokens_on_token_and_expires_at", where: "(revoked IS FALSE)", using: :btree add_index "deploy_tokens", ["token"], name: "index_deploy_tokens_on_token", unique: true, using: :btree create_table "deployments", force: :cascade do |t| @@ -1446,8 +1446,7 @@ ActiveRecord::Schema.define(version: 20180405142733) do create_table "project_deploy_tokens", force: :cascade do |t| t.integer "project_id", null: false t.integer "deploy_token_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime_with_timezone "created_at", null: false end add_index "project_deploy_tokens", ["project_id", "deploy_token_id"], name: "index_project_deploy_tokens_on_project_id_and_deploy_token_id", unique: true, using: :btree -- cgit v1.2.1 From 18a1569319af918fe3aff7564e344143d04d6aca Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Fri, 6 Apr 2018 11:23:45 -0500 Subject: Handles default expires_at date directly into DeployToken model --- db/migrate/20180319190020_create_deploy_tokens.rb | 2 +- db/schema.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20180319190020_create_deploy_tokens.rb b/db/migrate/20180319190020_create_deploy_tokens.rb index b8f77f5ae17..318ad3f0610 100644 --- a/db/migrate/20180319190020_create_deploy_tokens.rb +++ b/db/migrate/20180319190020_create_deploy_tokens.rb @@ -7,7 +7,7 @@ class CreateDeployTokens < ActiveRecord::Migration t.boolean :read_repository, null: false, default: false t.boolean :read_registry, null: false, default: false - t.datetime_with_timezone :expires_at, null: false, default: '3000-01-01' + t.datetime_with_timezone :expires_at, null: false t.datetime_with_timezone :created_at, null: false t.string :name, null: false diff --git a/db/schema.rb b/db/schema.rb index b0174a4ed46..a50c5fba969 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -687,7 +687,7 @@ ActiveRecord::Schema.define(version: 20180405142733) do t.boolean "revoked", default: false t.boolean "read_repository", default: false, null: false t.boolean "read_registry", default: false, null: false - t.datetime_with_timezone "expires_at", default: '3000-01-01 00:00:00', null: false + t.datetime_with_timezone "expires_at", null: false t.datetime_with_timezone "created_at", null: false t.string "name", null: false t.string "token", null: false -- cgit v1.2.1 From d6450717abefbe4dbf891cb4d285f6c84e44f168 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Fri, 6 Apr 2018 13:54:39 -0500 Subject: Modifies index on DeployTokens to use id --- db/migrate/20180319190020_create_deploy_tokens.rb | 2 +- db/schema.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20180319190020_create_deploy_tokens.rb b/db/migrate/20180319190020_create_deploy_tokens.rb index 318ad3f0610..d129459ea0a 100644 --- a/db/migrate/20180319190020_create_deploy_tokens.rb +++ b/db/migrate/20180319190020_create_deploy_tokens.rb @@ -13,7 +13,7 @@ class CreateDeployTokens < ActiveRecord::Migration t.string :name, null: false t.string :token, index: { unique: true }, null: false - t.index [:token, :expires_at], where: "(revoked IS FALSE)" + t.index [:token, :expires_at, :id], where: "(revoked IS FALSE)" end end end diff --git a/db/schema.rb b/db/schema.rb index a50c5fba969..fd75b176318 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -693,7 +693,7 @@ ActiveRecord::Schema.define(version: 20180405142733) do t.string "token", null: false end - add_index "deploy_tokens", ["token", "expires_at"], name: "index_deploy_tokens_on_token_and_expires_at", where: "(revoked IS FALSE)", using: :btree + add_index "deploy_tokens", ["token", "expires_at", "id"], name: "index_deploy_tokens_on_token_and_expires_at_and_id", where: "(revoked IS FALSE)", using: :btree add_index "deploy_tokens", ["token"], name: "index_deploy_tokens_on_token", unique: true, using: :btree create_table "deployments", force: :cascade do |t| -- cgit v1.2.1 From 8ad1573f85a699564b202aeb300d269798f99586 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 10 Apr 2018 15:00:06 +0200 Subject: Make sure hooks run when seeding admin user --- db/fixtures/development/01_admin.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'db') diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb index dfb50c195c1..1e260236dc5 100644 --- a/db/fixtures/development/01_admin.rb +++ b/db/fixtures/development/01_admin.rb @@ -1,14 +1,14 @@ require './spec/support/sidekiq' Gitlab::Seeder.quiet do - User.seed do |s| - s.id = 1 - s.name = 'Administrator' - s.email = 'admin@example.com' - s.notification_email = 'admin@example.com' - s.username = 'root' - s.password = '5iveL!fe' - s.admin = true - s.confirmed_at = DateTime.now - end + User.create!( + name: 'Administrator', + email: 'admin@example.com', + username: 'root', + password: '5iveL!fe', + admin: true, + confirmed_at: DateTime.now + ) + + print '.' end -- cgit v1.2.1