diff options
Diffstat (limited to 'db')
29 files changed, 411 insertions, 160 deletions
diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb index aea0a72b633..4bc735916c1 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -155,7 +155,7 @@ class Gitlab::Seeder::CycleAnalytics issue.project.repository.add_branch(@user, branch_name, 'master') - commit_sha = issue.project.repository.create_file(@user, filename, "content", options, message: "Commit for ##{issue.iid}", branch_name: branch_name) + commit_sha = issue.project.repository.create_file(@user, filename, "content", message: "Commit for ##{issue.iid}", branch_name: branch_name) issue.project.repository.commit(commit_sha) GitPushService.new(issue.project, diff --git a/db/migrate/20160919145149_add_group_id_to_labels.rb b/db/migrate/20160919145149_add_group_id_to_labels.rb index 828b6afddb1..e20e693f3aa 100644 --- a/db/migrate/20160919145149_add_group_id_to_labels.rb +++ b/db/migrate/20160919145149_add_group_id_to_labels.rb @@ -12,8 +12,8 @@ class AddGroupIdToLabels < ActiveRecord::Migration end def down + remove_foreign_key :labels, column: :group_id remove_index :labels, :group_id if index_exists? :labels, :group_id - remove_foreign_key :labels, :namespaces, column: :group_id remove_column :labels, :group_id end end diff --git a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb index ad3eb4a26f9..35ad22b6c01 100644 --- a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb +++ b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb @@ -32,8 +32,8 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration end def down + remove_foreign_key :merge_request_metrics, column: :pipeline_id remove_index :merge_request_metrics, :pipeline_id if index_exists? :merge_request_metrics, :pipeline_id - remove_foreign_key :merge_request_metrics, :ci_commits, column: :pipeline_id remove_column :merge_request_metrics, :pipeline_id end end diff --git a/db/migrate/20161031171301_add_project_id_to_subscriptions.rb b/db/migrate/20161031171301_add_project_id_to_subscriptions.rb index d5c343dc527..8b1c10a124f 100644 --- a/db/migrate/20161031171301_add_project_id_to_subscriptions.rb +++ b/db/migrate/20161031171301_add_project_id_to_subscriptions.rb @@ -9,6 +9,7 @@ class AddProjectIdToSubscriptions < ActiveRecord::Migration end def down + remove_foreign_key :subscriptions, column: :project_id remove_column :subscriptions, :project_id end end diff --git a/db/migrate/20161201160452_migrate_project_statistics.rb b/db/migrate/20161201160452_migrate_project_statistics.rb index 3ae3f2c159b..82fbdf02444 100644 --- a/db/migrate/20161201160452_migrate_project_statistics.rb +++ b/db/migrate/20161201160452_migrate_project_statistics.rb @@ -16,8 +16,9 @@ class MigrateProjectStatistics < ActiveRecord::Migration remove_column :projects, :commit_count end + # rubocop: disable Migration/AddColumn def down - add_column_with_default :projects, :repository_size, :float, default: 0.0 - add_column_with_default :projects, :commit_count, :integer, default: 0 + add_column :projects, :repository_size, :float, default: 0.0 + add_column :projects, :commit_count, :integer, default: 0 end end diff --git a/db/migrate/20161207231621_create_environment_name_unique_index.rb b/db/migrate/20161207231621_create_environment_name_unique_index.rb index ac680c8d10f..5ff0f5bae4d 100644 --- a/db/migrate/20161207231621_create_environment_name_unique_index.rb +++ b/db/migrate/20161207231621_create_environment_name_unique_index.rb @@ -12,7 +12,7 @@ class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration end def down - remove_index :environments, [:project_id, :name], unique: true - add_concurrent_index :environments, [:project_id, :name] + remove_index :environments, [:project_id, :name] + add_concurrent_index :environments, [:project_id, :name], unique: true end end diff --git a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb index d7ef1aa83d9..ede0316e860 100644 --- a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb +++ b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb @@ -14,6 +14,6 @@ class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration end def down - remove_index :environments, [:project_id, :slug], unique: true if index_exists? :environments, [:project_id, :slug] + remove_index :environments, [:project_id, :slug] if index_exists? :environments, [:project_id, :slug] end end diff --git a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb index 6958500306f..53f4c6bbb18 100644 --- a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb +++ b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb @@ -17,6 +17,6 @@ class AddLowerPathIndexToRoutes < ActiveRecord::Migration def down return unless Gitlab::Database.postgresql? - remove_index :routes, name: :index_on_routes_lower_path + remove_index :routes, name: :index_on_routes_lower_path if index_exists?(:routes, name: :index_on_routes_lower_path) end end diff --git a/db/migrate/20170123061730_add_notified_of_own_activity_to_users.rb b/db/migrate/20170123061730_add_notified_of_own_activity_to_users.rb deleted file mode 100644 index f90637e1e35..00000000000 --- a/db/migrate/20170123061730_add_notified_of_own_activity_to_users.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddNotifiedOfOwnActivityToUsers < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_column_with_default :users, :notified_of_own_activity, :boolean, default: false - end - - def down - remove_column :users, :notified_of_own_activity - end -end diff --git a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb index 69bfa2d3fc4..a7d4e141a1a 100644 --- a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb +++ b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb @@ -49,6 +49,9 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration Timelog.where('issue_id IS NOT NULL').update_all("trackable_id = issue_id, trackable_type = 'Issue'") Timelog.where('merge_request_id IS NOT NULL').update_all("trackable_id = merge_request_id, trackable_type = 'MergeRequest'") + remove_foreign_key :timelogs, name: 'fk_timelogs_issues_issue_id' + remove_foreign_key :timelogs, name: 'fk_timelogs_merge_requests_merge_request_id' + remove_columns :timelogs, :issue_id, :merge_request_id end end diff --git a/db/migrate/20170130204620_add_index_to_project_authorizations.rb b/db/migrate/20170130204620_add_index_to_project_authorizations.rb index e9a0aee4d6a..629b49436e3 100644 --- a/db/migrate/20170130204620_add_index_to_project_authorizations.rb +++ b/db/migrate/20170130204620_add_index_to_project_authorizations.rb @@ -8,4 +8,9 @@ class AddIndexToProjectAuthorizations < ActiveRecord::Migration def up add_concurrent_index(:project_authorizations, :project_id) end + + def down + remove_index(:project_authorizations, :project_id) if + Gitlab::Database.postgresql? + end end diff --git a/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb b/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb index 65adc90c2c1..8a96a784c97 100644 --- a/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb +++ b/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb @@ -5,7 +5,7 @@ class AddIndexForLatestSuccessfulPipeline < ActiveRecord::Migration disable_ddl_transaction! def up - add_concurrent_index :ci_commits, [:gl_project_id, :ref, :status] + add_concurrent_index(:ci_commits, [:gl_project_id, :ref, :status]) end def down diff --git a/db/migrate/20170216141440_drop_index_for_builds_project_status.rb b/db/migrate/20170216141440_drop_index_for_builds_project_status.rb index 906711b9f3f..a2839f52d89 100644 --- a/db/migrate/20170216141440_drop_index_for_builds_project_status.rb +++ b/db/migrate/20170216141440_drop_index_for_builds_project_status.rb @@ -3,6 +3,6 @@ class DropIndexForBuildsProjectStatus < ActiveRecord::Migration DOWNTIME = false def change - remove_index(:ci_commits, [:gl_project_id, :status]) + remove_index(:ci_commits, column: [:gl_project_id, :status]) end end diff --git a/db/migrate/20170222143317_drop_ci_projects.rb b/db/migrate/20170222143317_drop_ci_projects.rb new file mode 100644 index 00000000000..4db8658f36f --- /dev/null +++ b/db/migrate/20170222143317_drop_ci_projects.rb @@ -0,0 +1,34 @@ +class DropCiProjects < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + drop_table :ci_projects + end + + def down + create_table "ci_projects", force: :cascade do |t| + t.string "name" + t.integer "timeout", default: 3600, null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "token" + t.string "default_ref" + t.string "path" + t.boolean "always_build", default: false, null: false + t.integer "polling_interval" + t.boolean "public", default: false, null: false + t.string "ssh_url_to_repo" + t.integer "gitlab_id" + t.boolean "allow_git_fetch", default: true, null: false + t.string "email_recipients", default: "", null: false + t.boolean "email_add_pusher", default: true, null: false + t.boolean "email_only_broken_builds", default: true, null: false + t.string "skip_refs" + t.string "coverage_regex" + t.boolean "shared_runners_enabled", default: false + t.text "generated_yaml_config" + end + end +end diff --git a/db/migrate/20170222143500_remove_old_project_id_columns.rb b/db/migrate/20170222143500_remove_old_project_id_columns.rb new file mode 100644 index 00000000000..eac93e8e407 --- /dev/null +++ b/db/migrate/20170222143500_remove_old_project_id_columns.rb @@ -0,0 +1,28 @@ +class RemoveOldProjectIdColumns < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + DOWNTIME = true + DOWNTIME_REASON = 'Unused columns are being removed.' + + def up + remove_index :ci_builds, :project_id if + index_exists?(:ci_builds, :project_id) + + remove_column :ci_builds, :project_id + remove_column :ci_commits, :project_id + remove_column :ci_runner_projects, :project_id + remove_column :ci_triggers, :project_id + remove_column :ci_variables, :project_id + end + + def down + add_column :ci_builds, :project_id, :integer + add_column :ci_commits, :project_id, :integer + add_column :ci_runner_projects, :project_id, :integer + add_column :ci_triggers, :project_id, :integer + add_column :ci_variables, :project_id, :integer + + add_concurrent_index :ci_builds, :project_id + end +end diff --git a/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb b/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb new file mode 100644 index 00000000000..7c19d471557 --- /dev/null +++ b/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb @@ -0,0 +1,14 @@ +class RenameGlProjectIdToProjectId < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = true + DOWNTIME_REASON = 'Renaming an actively used column.' + + def change + rename_column :ci_builds, :gl_project_id, :project_id + rename_column :ci_commits, :gl_project_id, :project_id + rename_column :ci_runner_projects, :gl_project_id, :project_id + rename_column :ci_triggers, :gl_project_id, :project_id + rename_column :ci_variables, :gl_project_id, :project_id + end +end diff --git a/db/migrate/20170301125302_add_printing_merge_request_link_enabled_to_project.rb b/db/migrate/20170301125302_add_printing_merge_request_link_enabled_to_project.rb new file mode 100644 index 00000000000..f54608ecceb --- /dev/null +++ b/db/migrate/20170301125302_add_printing_merge_request_link_enabled_to_project.rb @@ -0,0 +1,18 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddPrintingMergeRequestLinkEnabledToProject < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + add_column_with_default(:projects, :printing_merge_request_link_enabled, :boolean, default: true) + end + + def down + remove_column(:projects, :printing_merge_request_link_enabled) + end +end diff --git a/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb b/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb new file mode 100644 index 00000000000..4f061d96392 --- /dev/null +++ b/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb @@ -0,0 +1,10 @@ +class RenameCiCommitsToCiPipelines < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = true + DOWNTIME_REASON = 'Rename table ci_commits to ci_pipelines' + + def change + rename_table 'ci_commits', 'ci_pipelines' + end +end diff --git a/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb b/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb new file mode 100644 index 00000000000..1e2abea5254 --- /dev/null +++ b/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb @@ -0,0 +1,83 @@ +class RemoveUnusedCiTablesAndColumns < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = true + DOWNTIME_REASON = + 'Remove unused columns in used tables.' \ + ' Downtime required in case Rails caches them' + + def up + %w[ci_application_settings + ci_events + ci_jobs + ci_sessions + ci_taggings + ci_tags].each do |table| + drop_table(table) + end + + remove_column :ci_pipelines, :push_data, :text + remove_column :ci_builds, :job_id, :integer + remove_column :ci_builds, :deploy, :boolean + end + + def down + add_column :ci_builds, :deploy, :boolean + add_column :ci_builds, :job_id, :integer + add_column :ci_pipelines, :push_data, :text + + create_table "ci_tags", force: :cascade do |t| + t.string "name" + t.integer "taggings_count", default: 0 + end + + create_table "ci_taggings", force: :cascade do |t| + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" + t.integer "tagger_id" + t.string "tagger_type" + t.string "context", limit: 128 + t.datetime "created_at" + end + + add_index "ci_taggings", %w[taggable_id taggable_type context] + + create_table "ci_sessions", force: :cascade do |t| + t.string "session_id", null: false + t.text "data" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "ci_jobs", force: :cascade do |t| + t.integer "project_id", null: false + t.text "commands" + t.boolean "active", default: true, null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "name" + t.boolean "build_branches", default: true, null: false + t.boolean "build_tags", default: false, null: false + t.string "job_type", default: "parallel" + t.string "refs" + t.datetime "deleted_at" + end + + create_table "ci_events", force: :cascade do |t| + t.integer "project_id" + t.integer "user_id" + t.integer "is_admin" + t.text "description" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "ci_application_settings", force: :cascade do |t| + t.boolean "all_broken_builds" + t.boolean "add_pusher" + t.datetime "created_at" + t.datetime "updated_at" + end + end +end diff --git a/db/migrate/20170305203726_add_owner_id_foreign_key.rb b/db/migrate/20170305203726_add_owner_id_foreign_key.rb index 3eece0e2eb5..5fbdc45f1a7 100644 --- a/db/migrate/20170305203726_add_owner_id_foreign_key.rb +++ b/db/migrate/20170305203726_add_owner_id_foreign_key.rb @@ -5,7 +5,11 @@ class AddOwnerIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :cascade end + + def down + remove_foreign_key :ci_triggers, column: :owner_id + end end diff --git a/db/migrate/20170313213916_add_index_to_user_ghost.rb b/db/migrate/20170313213916_add_index_to_user_ghost.rb new file mode 100644 index 00000000000..c429039c275 --- /dev/null +++ b/db/migrate/20170313213916_add_index_to_user_ghost.rb @@ -0,0 +1,24 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddIndexToUserGhost < 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 = '' + + disable_ddl_transaction! + + def up + add_concurrent_index :users, :ghost + end + + def down + remove_index :users, :ghost + end +end diff --git a/db/migrate/20170315174634_revert_add_notified_of_own_activity_to_users.rb b/db/migrate/20170315174634_revert_add_notified_of_own_activity_to_users.rb new file mode 100644 index 00000000000..b39c0a3be0f --- /dev/null +++ b/db/migrate/20170315174634_revert_add_notified_of_own_activity_to_users.rb @@ -0,0 +1,24 @@ +class RevertAddNotifiedOfOwnActivityToUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + DOWNTIME = false + + def up + if our_column_exists? + remove_column :users, :notified_of_own_activity + end + end + + def down + unless our_column_exists? + add_column_with_default :users, :notified_of_own_activity, :boolean, default: false + end + end + + private + + def our_column_exists? + column_exists?(:users, :notified_of_own_activity) + end +end diff --git a/db/migrate/20170315194013_add_closed_at_to_issues.rb b/db/migrate/20170315194013_add_closed_at_to_issues.rb new file mode 100644 index 00000000000..1326118cc8d --- /dev/null +++ b/db/migrate/20170315194013_add_closed_at_to_issues.rb @@ -0,0 +1,7 @@ +class AddClosedAtToIssues < ActiveRecord::Migration + DOWNTIME = false + + def change + add_column :issues, :closed_at, :datetime + end +end diff --git a/db/migrate/20170317203554_index_routes_path_for_like.rb b/db/migrate/20170317203554_index_routes_path_for_like.rb new file mode 100644 index 00000000000..264ecd322c3 --- /dev/null +++ b/db/migrate/20170317203554_index_routes_path_for_like.rb @@ -0,0 +1,29 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class IndexRoutesPathForLike < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + INDEX_NAME = 'index_routes_on_path_text_pattern_ops' + + disable_ddl_transaction! + + def up + return unless Gitlab::Database.postgresql? + + unless index_exists?(:routes, name: INDEX_NAME) + execute("CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON routes (path varchar_pattern_ops);") + end + end + + def down + return unless Gitlab::Database.postgresql? + + if index_exists?(:routes, name: INDEX_NAME) + execute("DROP INDEX CONCURRENTLY #{INDEX_NAME};") + end + end +end diff --git a/db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb b/db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb index 89aa753646c..aee0c1b6245 100644 --- a/db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb +++ b/db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb @@ -18,6 +18,7 @@ class RemoveTrackableColumnsFromTimelogs < ActiveRecord::Migration # disable_ddl_transaction! def change - remove_columns :timelogs, :trackable_id, :trackable_type + remove_column :timelogs, :trackable_id, :integer + remove_column :timelogs, :trackable_type, :string end end diff --git a/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb new file mode 100644 index 00000000000..2dd14ee5a78 --- /dev/null +++ b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb @@ -0,0 +1,87 @@ +class MigrateBuildEventsToPipelineEvents < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + include Gitlab::Database + + DOWNTIME = false + + def up + Gitlab::Database.with_connection_pool(2) do |pool| + threads = [] + + threads << Thread.new do + pool.with_connection do |connection| + Thread.current[:foreign_key_connection] = connection + + execute(<<-SQL.strip_heredoc) + UPDATE services + SET properties = replace(properties, + 'notify_only_broken_builds', + 'notify_only_broken_pipelines') + , pipeline_events = #{true_value} + , build_events = #{false_value} + WHERE type IN + ('SlackService', 'MattermostService', 'HipchatService') + AND build_events = #{true_value}; + SQL + end + end + + threads << Thread.new do + pool.with_connection do |connection| + Thread.current[:foreign_key_connection] = connection + + execute(update_pipeline_services_sql) + end + end + + threads.each(&:join) + end + end + + def down + # Don't bother to migrate the data back + end + + def connection + # Rails memoizes connection objects, but this causes them to be shared + # amongst threads; we don't want that. + Thread.current[:foreign_key_connection] || ActiveRecord::Base.connection + end + + private + + def update_pipeline_services_sql + if Gitlab::Database.postgresql? + <<-SQL + UPDATE services + SET type = 'PipelinesEmailService' + , properties = replace(properties, + 'notify_only_broken_builds', + 'notify_only_broken_pipelines') + , pipeline_events = #{true_value} + , build_events = #{false_value} + WHERE type = 'BuildsEmailService' + AND + (SELECT 1 FROM services pipeline_services + WHERE pipeline_services.project_id = services.project_id + AND pipeline_services.type = 'PipelinesEmailService' LIMIT 1) + IS NULL; + SQL + else + <<-SQL + UPDATE services build_services + LEFT OUTER JOIN services pipeline_services + ON build_services.project_id = pipeline_services.project_id + AND pipeline_services.type = 'PipelinesEmailService' + SET build_services.type = 'PipelinesEmailService' + , build_services.properties = replace(build_services.properties, + 'notify_only_broken_builds', + 'notify_only_broken_pipelines') + , build_services.pipeline_events = #{true_value} + , build_services.build_events = #{false_value} + WHERE build_services.type = 'BuildsEmailService' + AND pipeline_services.id IS NULL; + SQL + end.strip_heredoc + end +end diff --git a/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb b/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb index 9020e0d054c..ec6e8cdfc45 100644 --- a/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb +++ b/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb @@ -4,6 +4,8 @@ class MigrateLegacyManualActions < ActiveRecord::Migration DOWNTIME = false def up + disable_statement_timeout + execute <<-EOS UPDATE ci_builds SET status = 'manual', allow_failure = true WHERE ci_builds.when = 'manual' AND ci_builds.status = 'skipped'; @@ -11,6 +13,8 @@ class MigrateLegacyManualActions < ActiveRecord::Migration end def down + disable_statement_timeout + execute <<-EOS UPDATE ci_builds SET status = 'skipped', allow_failure = false WHERE ci_builds.when = 'manual' AND ci_builds.status = 'manual'; diff --git a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb index 9dfe77bedb7..44c688fa134 100644 --- a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb +++ b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb @@ -6,41 +6,12 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration DOWNTIME = false - THREAD_COUNT = 8 - KNOWN_PATHS = %w(artifacts graphs refs badges).freeze def up - queues = Array.new(THREAD_COUNT) { Queue.new } - start = false - - threads = Array.new(THREAD_COUNT) do |index| - Thread.new do - queue = queues[index] - - # Wait until we have input to process. - until start; end - - rename_projects(queue.pop) until queue.empty? - end - end - - enum = queues.each - reserved_projects.each_slice(100) do |slice| - begin - queue = enum.next - rescue StopIteration - enum.rewind - retry - end - - queue << slice + rename_projects(slice) end - - start = true - - threads.each(&:join) end def down diff --git a/db/schema.rb b/db/schema.rb index ca88198079f..904fef4a381 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: 20170313133418) do +ActiveRecord::Schema.define(version: 20170317203554) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -185,15 +185,7 @@ ActiveRecord::Schema.define(version: 20170313133418) do add_index "chat_teams", ["namespace_id"], name: "index_chat_teams_on_namespace_id", unique: true, using: :btree - create_table "ci_application_settings", force: :cascade do |t| - t.boolean "all_broken_builds" - t.boolean "add_pusher" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "ci_builds", force: :cascade do |t| - t.integer "project_id" t.string "status" t.datetime "finished_at" t.text "trace" @@ -204,9 +196,7 @@ ActiveRecord::Schema.define(version: 20170313133418) do t.float "coverage" t.integer "commit_id" t.text "commands" - t.integer "job_id" t.string "name" - t.boolean "deploy", default: false t.text "options" t.boolean "allow_failure", default: false, null: false t.string "stage" @@ -219,7 +209,7 @@ ActiveRecord::Schema.define(version: 20170313133418) do t.string "target_url" t.string "description" t.text "artifacts_file" - t.integer "gl_project_id" + t.integer "project_id" t.text "artifacts_metadata" t.integer "erased_by_id" t.datetime "erased_at" @@ -238,25 +228,22 @@ ActiveRecord::Schema.define(version: 20170313133418) 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", ["gl_project_id"], name: "index_ci_builds_on_gl_project_id", using: :btree add_index "ci_builds", ["project_id"], name: "index_ci_builds_on_project_id", using: :btree add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree add_index "ci_builds", ["status", "type", "runner_id"], name: "index_ci_builds_on_status_and_type_and_runner_id", using: :btree add_index "ci_builds", ["status"], name: "index_ci_builds_on_status", using: :btree add_index "ci_builds", ["token"], name: "index_ci_builds_on_token", unique: true, using: :btree - create_table "ci_commits", force: :cascade do |t| - t.integer "project_id" + create_table "ci_pipelines", force: :cascade do |t| t.string "ref" t.string "sha" t.string "before_sha" - t.text "push_data" t.datetime "created_at" t.datetime "updated_at" t.boolean "tag", default: false t.text "yaml_errors" t.datetime "committed_at" - t.integer "gl_project_id" + t.integer "project_id" t.string "status" t.datetime "started_at" t.datetime "finished_at" @@ -265,67 +252,20 @@ ActiveRecord::Schema.define(version: 20170313133418) do t.integer "lock_version" end - add_index "ci_commits", ["gl_project_id", "ref", "status"], name: "index_ci_commits_on_gl_project_id_and_ref_and_status", using: :btree - add_index "ci_commits", ["gl_project_id", "sha"], name: "index_ci_commits_on_gl_project_id_and_sha", using: :btree - add_index "ci_commits", ["gl_project_id"], name: "index_ci_commits_on_gl_project_id", using: :btree - add_index "ci_commits", ["status"], name: "index_ci_commits_on_status", using: :btree - add_index "ci_commits", ["user_id"], name: "index_ci_commits_on_user_id", using: :btree - - create_table "ci_events", force: :cascade do |t| - t.integer "project_id" - t.integer "user_id" - t.integer "is_admin" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "ci_jobs", force: :cascade do |t| - t.integer "project_id", null: false - t.text "commands" - t.boolean "active", default: true, null: false - t.datetime "created_at" - t.datetime "updated_at" - t.string "name" - t.boolean "build_branches", default: true, null: false - t.boolean "build_tags", default: false, null: false - t.string "job_type", default: "parallel" - t.string "refs" - t.datetime "deleted_at" - end - - create_table "ci_projects", force: :cascade do |t| - t.string "name" - t.integer "timeout", default: 3600, null: false - t.datetime "created_at" - t.datetime "updated_at" - t.string "token" - t.string "default_ref" - t.string "path" - t.boolean "always_build", default: false, null: false - t.integer "polling_interval" - t.boolean "public", default: false, null: false - t.string "ssh_url_to_repo" - t.integer "gitlab_id" - t.boolean "allow_git_fetch", default: true, null: false - t.string "email_recipients", default: "", null: false - t.boolean "email_add_pusher", default: true, null: false - t.boolean "email_only_broken_builds", default: true, null: false - t.string "skip_refs" - t.string "coverage_regex" - t.boolean "shared_runners_enabled", default: false - t.text "generated_yaml_config" - end + 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 + add_index "ci_pipelines", ["status"], name: "index_ci_pipelines_on_status", using: :btree + add_index "ci_pipelines", ["user_id"], name: "index_ci_pipelines_on_user_id", using: :btree create_table "ci_runner_projects", force: :cascade do |t| t.integer "runner_id", null: false - t.integer "project_id" t.datetime "created_at" t.datetime "updated_at" - t.integer "gl_project_id" + t.integer "project_id" end - add_index "ci_runner_projects", ["gl_project_id"], name: "index_ci_runner_projects_on_gl_project_id", using: :btree + add_index "ci_runner_projects", ["project_id"], name: "index_ci_runner_projects_on_project_id", using: :btree add_index "ci_runner_projects", ["runner_id"], name: "index_ci_runner_projects_on_runner_id", using: :btree create_table "ci_runners", force: :cascade do |t| @@ -349,30 +289,6 @@ ActiveRecord::Schema.define(version: 20170313133418) do add_index "ci_runners", ["locked"], name: "index_ci_runners_on_locked", using: :btree add_index "ci_runners", ["token"], name: "index_ci_runners_on_token", using: :btree - create_table "ci_sessions", force: :cascade do |t| - t.string "session_id", null: false - t.text "data" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "ci_taggings", force: :cascade do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", limit: 128 - t.datetime "created_at" - end - - add_index "ci_taggings", ["taggable_id", "taggable_type", "context"], name: "index_ci_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree - - create_table "ci_tags", force: :cascade do |t| - t.string "name" - t.integer "taggings_count", default: 0 - end - create_table "ci_trigger_requests", force: :cascade do |t| t.integer "trigger_id", null: false t.text "variables" @@ -385,28 +301,26 @@ ActiveRecord::Schema.define(version: 20170313133418) do create_table "ci_triggers", force: :cascade do |t| t.string "token" - t.integer "project_id" t.datetime "deleted_at" t.datetime "created_at" t.datetime "updated_at" - t.integer "gl_project_id" + t.integer "project_id" t.integer "owner_id" t.string "description" end - add_index "ci_triggers", ["gl_project_id"], name: "index_ci_triggers_on_gl_project_id", using: :btree + add_index "ci_triggers", ["project_id"], name: "index_ci_triggers_on_project_id", using: :btree create_table "ci_variables", force: :cascade do |t| - t.integer "project_id" t.string "key" t.text "value" t.text "encrypted_value" t.string "encrypted_value_salt" t.string "encrypted_value_iv" - t.integer "gl_project_id" + t.integer "project_id" end - add_index "ci_variables", ["gl_project_id"], name: "index_ci_variables_on_gl_project_id", using: :btree + add_index "ci_variables", ["project_id"], name: "index_ci_variables_on_project_id", using: :btree create_table "deploy_keys_projects", force: :cascade do |t| t.integer "deploy_key_id", null: false @@ -531,6 +445,7 @@ ActiveRecord::Schema.define(version: 20170313133418) do t.text "description_html" t.integer "time_estimate" t.integer "relative_position" + t.datetime "closed_at" end add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree @@ -1003,6 +918,7 @@ ActiveRecord::Schema.define(version: 20170313133418) do t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" + t.boolean "printing_merge_request_link_enabled", default: true, null: false end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree @@ -1069,6 +985,7 @@ ActiveRecord::Schema.define(version: 20170313133418) do end add_index "routes", ["path"], name: "index_routes_on_path", unique: true, using: :btree + add_index "routes", ["path"], name: "index_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"} add_index "routes", ["source_type", "source_id"], name: "index_routes_on_source_type_and_source_id", unique: true, using: :btree create_table "sent_notifications", force: :cascade do |t| @@ -1318,7 +1235,6 @@ ActiveRecord::Schema.define(version: 20170313133418) do t.string "incoming_email_token" t.string "organization" t.boolean "authorized_projects_populated" - t.boolean "notified_of_own_activity", default: false, null: false t.boolean "ghost" end @@ -1329,6 +1245,7 @@ ActiveRecord::Schema.define(version: 20170313133418) do 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 add_index "users", ["incoming_email_token"], name: "index_users_on_incoming_email_token", using: :btree add_index "users", ["name"], name: "index_users_on_name", using: :btree add_index "users", ["name"], name: "index_users_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} @@ -1378,7 +1295,7 @@ ActiveRecord::Schema.define(version: 20170313133418) do add_foreign_key "labels", "namespaces", column: "group_id", on_delete: :cascade add_foreign_key "lists", "boards" add_foreign_key "lists", "labels" - add_foreign_key "merge_request_metrics", "ci_commits", column: "pipeline_id", on_delete: :cascade + add_foreign_key "merge_request_metrics", "ci_pipelines", column: "pipeline_id", on_delete: :cascade add_foreign_key "merge_request_metrics", "merge_requests", on_delete: :cascade add_foreign_key "merge_requests_closing_issues", "issues", on_delete: :cascade add_foreign_key "merge_requests_closing_issues", "merge_requests", on_delete: :cascade |