diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-04-17 12:07:56 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-04-17 12:07:56 +0900 |
commit | 23634e45678b13954fc00fd4e57425ff5cb559aa (patch) | |
tree | 636a39d3306c664d25df413f8e6c329fcf3a8fea /db | |
parent | 76485cbf8ba555c929fd2f54ca2051a382760f20 (diff) | |
parent | c39ad568e469b288a510c03b1aebefd78d8a9ee5 (diff) | |
download | gitlab-ce-23634e45678b13954fc00fd4e57425ff5cb559aa.tar.gz |
Merge branch 'master' into live-trace-v2
Diffstat (limited to 'db')
-rw-r--r-- | db/fixtures/development/01_admin.rb | 20 | ||||
-rw-r--r-- | db/fixtures/development/10_merge_requests.rb | 8 | ||||
-rw-r--r-- | db/fixtures/development/19_environments.rb | 6 | ||||
-rw-r--r-- | db/migrate/20180319190020_create_deploy_tokens.rb | 19 | ||||
-rw-r--r-- | db/migrate/20180405142733_create_project_deploy_tokens.rb | 16 | ||||
-rw-r--r-- | db/schema.rb | 23 |
6 files changed, 79 insertions, 13 deletions
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 diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb index 30244ee4431..bcfdd058a1c 100644 --- a/db/fixtures/development/10_merge_requests.rb +++ b/db/fixtures/development/10_merge_requests.rb @@ -4,7 +4,7 @@ Gitlab::Seeder.quiet do # Limit the number of merge requests per project to avoid long seeds MAX_NUM_MERGE_REQUESTS = 10 - Project.all.reject(&:empty_repo?).each do |project| + Project.non_archived.with_merge_requests_enabled.reject(&:empty_repo?).each do |project| branches = project.repository.branch_names.sample(MAX_NUM_MERGE_REQUESTS * 2) branches.each do |branch_name| @@ -21,7 +21,11 @@ Gitlab::Seeder.quiet do assignee: project.team.users.sample } - MergeRequests::CreateService.new(project, project.team.users.sample, params).execute + # Only create MRs with users that are allowed to create MRs + developer = project.team.developers.sample + break unless developer + + MergeRequests::CreateService.new(project, developer, params).execute print '.' end end diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb index c1bbc9af6d6..00a14f458d1 100644 --- a/db/fixtures/development/19_environments.rb +++ b/db/fixtures/development/19_environments.rb @@ -28,7 +28,11 @@ class Gitlab::Seeder::Environments end def create_merge_request_review_deployments! - @project.merge_requests.sample(4).map do |merge_request| + @project + .merge_requests + .select { |mr| mr.source_branch.match(/\p{Alnum}+/) } + .sample(4) + .each do |merge_request| next unless merge_request.diff_head_sha create_deployment!( diff --git a/db/migrate/20180319190020_create_deploy_tokens.rb b/db/migrate/20180319190020_create_deploy_tokens.rb new file mode 100644 index 00000000000..d129459ea0a --- /dev/null +++ b/db/migrate/20180319190020_create_deploy_tokens.rb @@ -0,0 +1,19 @@ +class CreateDeployTokens < ActiveRecord::Migration + DOWNTIME = false + + def change + create_table :deploy_tokens do |t| + t.boolean :revoked, default: false + t.boolean :read_repository, null: false, default: false + t.boolean :read_registry, null: false, default: 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, index: { unique: true }, null: false + + t.index [:token, :expires_at, :id], 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 new file mode 100644 index 00000000000..9d8f89243a8 --- /dev/null +++ b/db/migrate/20180405142733_create_project_deploy_tokens.rb @@ -0,0 +1,16 @@ +class CreateProjectDeployTokens < ActiveRecord::Migration + 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.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 + + t.index [:project_id, :deploy_token_id], unique: true + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 69d7997b4bf..16753af746c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -692,6 +692,19 @@ ActiveRecord::Schema.define(version: 20180406204716) 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.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", 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", "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| t.integer "iid", null: false t.integer "project_id", null: false @@ -1439,6 +1452,14 @@ ActiveRecord::Schema.define(version: 20180406204716) 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_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 + create_table "project_features", force: :cascade do |t| t.integer "project_id" t.integer "merge_requests_access_level" @@ -2147,6 +2168,8 @@ ActiveRecord::Schema.define(version: 20180406204716) 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 |