diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/fixtures/development/19_environments.rb | 70 | ||||
-rw-r--r-- | db/fixtures/development/20_nested_groups.rb (renamed from db/fixtures/development/19_nested_groups.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140502125220_migrate_repo_size.rb | 5 | ||||
-rw-r--r-- | db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb | 25 | ||||
-rw-r--r-- | db/schema.rb | 3 |
5 files changed, 98 insertions, 5 deletions
diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb new file mode 100644 index 00000000000..93214b9d3e7 --- /dev/null +++ b/db/fixtures/development/19_environments.rb @@ -0,0 +1,70 @@ +require './spec/support/sidekiq' + +class Gitlab::Seeder::Environments + def initialize(project) + @project = project + end + + def seed! + @project.create_mock_deployment_service!(active: true) + @project.create_mock_monitoring_service!(active: true) + + create_master_deployments!('production') + create_master_deployments!('staging') + create_merge_request_review_deployments! + end + + private + + def create_master_deployments!(name) + @project.repository.commits('master', limit: 4).map do |commit| + create_deployment!( + @project, + name, + 'master', + commit.id + ) + end + end + + def create_merge_request_review_deployments! + @project.merge_requests.sample(4).map do |merge_request| + next unless merge_request.diff_head_sha + + create_deployment!( + merge_request.source_project, + "review/#{merge_request.source_branch}", + merge_request.source_branch, + merge_request.diff_head_sha + ) + end + end + + def create_deployment!(project, name, ref, sha) + environment = find_or_create_environment!(project, name) + environment.deployments.create!( + project: project, + ref: ref, + sha: sha, + tag: false, + deployable: find_deployable(project, name) + ) + end + + def find_or_create_environment!(project, name) + project.environments.find_or_create_by!(name: name).tap do |environment| + environment.update(external_url: "https://google.com/#{name}") + end + end + + def find_deployable(project, environment) + project.builds.where(environment: environment).sample + end +end + +Gitlab::Seeder.quiet do + Project.all.sample(5).each do |project| + project_environments = Gitlab::Seeder::Environments.new(project) + project_environments.seed! + end +end diff --git a/db/fixtures/development/19_nested_groups.rb b/db/fixtures/development/20_nested_groups.rb index d8dddc3fee9..d8dddc3fee9 100644 --- a/db/fixtures/development/19_nested_groups.rb +++ b/db/fixtures/development/20_nested_groups.rb diff --git a/db/migrate/20140502125220_migrate_repo_size.rb b/db/migrate/20140502125220_migrate_repo_size.rb index 66203486d53..f5d5d834307 100644 --- a/db/migrate/20140502125220_migrate_repo_size.rb +++ b/db/migrate/20140502125220_migrate_repo_size.rb @@ -8,11 +8,10 @@ class MigrateRepoSize < ActiveRecord::Migration project_data.each do |project| id = project['id'] namespace_path = project['namespace_path'] || '' - repos_path = Gitlab.config.gitlab_shell['repos_path'] || Gitlab.config.repositories.storages.default['path'] - path = File.join(repos_path, namespace_path, project['project_path'] + '.git') + path = File.join(namespace_path, project['project_path'] + '.git') begin - repo = Gitlab::Git::Repository.new(path) + repo = Gitlab::Git::Repository.new('default', path) if repo.empty? print '-' else diff --git a/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb b/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb new file mode 100644 index 00000000000..8316ee9eb9f --- /dev/null +++ b/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.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 RemoveIndexForUsersCurrentSignInAt < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + if index_exists? :users, :current_sign_in_at + if Gitlab::Database.postgresql? + execute 'DROP INDEX CONCURRENTLY index_users_on_current_sign_in_at;' + else + remove_index :users, :current_sign_in_at + end + end + end + + def down + add_concurrent_index :users, :current_sign_in_at + end +end diff --git a/db/schema.rb b/db/schema.rb index 9ee1d0e6aef..646c937de73 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: 20170329124448) do +ActiveRecord::Schema.define(version: 20170402231018) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1262,7 +1262,6 @@ ActiveRecord::Schema.define(version: 20170329124448) do add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree add_index "users", ["created_at"], name: "index_users_on_created_at", using: :btree - add_index "users", ["current_sign_in_at"], name: "index_users_on_current_sign_in_at", using: :btree add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["email"], name: "index_users_on_email_trigram", using: :gin, opclasses: {"email"=>"gin_trgm_ops"} add_index "users", ["ghost"], name: "index_users_on_ghost", using: :btree |