diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2019-07-02 16:14:24 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2019-07-02 16:14:24 +0300 |
commit | e07ebe66af957c46e7c69329b3ab561bb539351b (patch) | |
tree | 9a4d6d52f94b99aea154ad53000a39d172b18cdb | |
parent | 58786e2086b9d8db5784771f4dbfe8b5c107df18 (diff) | |
parent | 6aeb6996447ead0f6daf71faab85c99e11ab8ae8 (diff) |
Merge branch '59177-squash-old-migrations' into 'master'
Squash old migrations
Closes #59177
See merge request gitlab-org/gitlab-ce!30226
876 files changed, 1855 insertions, 22421 deletions
diff --git a/.gitlab/ci/rails.gitlab-ci.yml b/.gitlab/ci/rails.gitlab-ci.yml index 9d24099b85c..f2ada743bf3 100644 --- a/.gitlab/ci/rails.gitlab-ci.yml +++ b/.gitlab/ci/rails.gitlab-ci.yml @@ -245,7 +245,7 @@ migration:path-pg: .db-rollback: &db-rollback extends: .dedicated-no-docs-and-no-qa-pull-cache-job script: - - bundle exec rake db:migrate VERSION=20170523121229 + - bundle exec rake db:migrate VERSION=20180101160629 - bundle exec rake db:migrate SKIP_SCHEMA_VERSION_CHECK=true dependencies: - setup-test-env diff --git a/db/migrate/20140313092127_init_schema.rb b/db/migrate/20140313092127_init_schema.rb deleted file mode 100644 index 4188599b4b4..00000000000 --- a/db/migrate/20140313092127_init_schema.rb +++ /dev/null @@ -1,338 +0,0 @@ -class InitSchema < ActiveRecord::Migration[4.2] - DOWNTIME = true - - # rubocop:disable Metrics/AbcSize - def up - create_table "broadcast_messages", force: :cascade do |t| - t.text "message", null: false - t.datetime "starts_at" - t.datetime "ends_at" - t.integer "alert_type" - t.datetime "created_at" - t.datetime "updated_at" - t.string "color" - t.string "font" - end - create_table "deploy_keys_projects", force: :cascade do |t| - t.integer "deploy_key_id", null: false - t.integer "project_id", null: false - t.datetime "created_at" - t.datetime "updated_at" - end - add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree - create_table "emails", force: :cascade do |t| - t.integer "user_id", null: false - t.string "email", null: false - t.datetime "created_at" - t.datetime "updated_at" - end - 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 - create_table "events", force: :cascade do |t| - t.string "target_type" - t.integer "target_id" - t.string "title" - t.text "data" - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "action" - t.integer "author_id" - end - add_index "events", ["action"], name: "index_events_on_action", using: :btree - add_index "events", ["author_id"], name: "index_events_on_author_id", using: :btree - add_index "events", ["created_at"], name: "index_events_on_created_at", using: :btree - add_index "events", ["project_id"], name: "index_events_on_project_id", using: :btree - add_index "events", ["target_id"], name: "index_events_on_target_id", using: :btree - add_index "events", ["target_type"], name: "index_events_on_target_type", using: :btree - create_table "forked_project_links", force: :cascade do |t| - t.integer "forked_to_project_id", null: false - t.integer "forked_from_project_id", null: false - t.datetime "created_at" - t.datetime "updated_at" - end - 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 "issues", force: :cascade do |t| - t.string "title" - t.integer "assignee_id" - t.integer "author_id" - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "position", default: 0 - t.string "branch_name" - t.text "description" - t.integer "milestone_id" - t.string "state" - t.integer "iid" - end - add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree - add_index "issues", ["author_id"], name: "index_issues_on_author_id", using: :btree - add_index "issues", ["created_at"], name: "index_issues_on_created_at", using: :btree - add_index "issues", ["milestone_id"], name: "index_issues_on_milestone_id", using: :btree - add_index "issues", ["project_id"], name: "index_issues_on_project_id", using: :btree - add_index "issues", ["title"], name: "index_issues_on_title", using: :btree - create_table "keys", force: :cascade do |t| - t.integer "user_id" - t.datetime "created_at" - t.datetime "updated_at" - t.text "key" - t.string "title" - t.string "type" - t.string "fingerprint" - end - add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree - create_table "merge_request_diffs", force: :cascade do |t| - t.string "state", default: "collected", null: false - t.text "st_commits" - t.text "st_diffs" - t.integer "merge_request_id", null: false - t.datetime "created_at" - t.datetime "updated_at" - end - add_index "merge_request_diffs", ["merge_request_id"], name: "index_merge_request_diffs_on_merge_request_id", unique: true, using: :btree - create_table "merge_requests", force: :cascade do |t| - t.string "target_branch", null: false - t.string "source_branch", null: false - t.integer "source_project_id", null: false - t.integer "author_id" - t.integer "assignee_id" - t.string "title" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "milestone_id" - t.string "state" - t.string "merge_status" - t.integer "target_project_id", null: false - t.integer "iid" - t.text "description" - end - add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree - add_index "merge_requests", ["author_id"], name: "index_merge_requests_on_author_id", using: :btree - add_index "merge_requests", ["created_at"], name: "index_merge_requests_on_created_at", using: :btree - add_index "merge_requests", ["milestone_id"], name: "index_merge_requests_on_milestone_id", using: :btree - add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree - add_index "merge_requests", ["source_project_id"], name: "index_merge_requests_on_source_project_id", using: :btree - add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree - add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree - create_table "milestones", force: :cascade do |t| - t.string "title", null: false - t.integer "project_id", null: false - t.text "description" - t.date "due_date" - t.datetime "created_at" - t.datetime "updated_at" - t.string "state" - t.integer "iid" - end - add_index "milestones", ["due_date"], name: "index_milestones_on_due_date", using: :btree - add_index "milestones", ["project_id"], name: "index_milestones_on_project_id", using: :btree - create_table "namespaces", force: :cascade do |t| - t.string "name", null: false - t.string "path", null: false - t.integer "owner_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "type" - t.string "description", default: "", null: false - t.string "avatar" - end - add_index "namespaces", ["name"], name: "index_namespaces_on_name", using: :btree - add_index "namespaces", ["owner_id"], name: "index_namespaces_on_owner_id", using: :btree - add_index "namespaces", ["path"], name: "index_namespaces_on_path", using: :btree - add_index "namespaces", ["type"], name: "index_namespaces_on_type", using: :btree - create_table "notes", force: :cascade do |t| - t.text "note" - t.string "noteable_type" - t.integer "author_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "project_id" - t.string "attachment" - t.string "line_code" - t.string "commit_id" - t.integer "noteable_id" - t.boolean "system", default: false, null: false - t.text "st_diff" - end - add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree - add_index "notes", ["commit_id"], name: "index_notes_on_commit_id", using: :btree - add_index "notes", ["created_at"], name: "index_notes_on_created_at", using: :btree - add_index "notes", %w[noteable_id noteable_type], name: "index_notes_on_noteable_id_and_noteable_type", using: :btree - add_index "notes", ["noteable_type"], name: "index_notes_on_noteable_type", using: :btree - add_index "notes", %w[project_id noteable_type], name: "index_notes_on_project_id_and_noteable_type", using: :btree - add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree - create_table "project_group_links", force: :cascade do |t| - t.integer "project_id", null: false - t.integer "group_id", null: false - t.datetime "created_at" - t.datetime "updated_at" - t.integer "group_access", default: 30, null: false - end - create_table "projects", force: :cascade do |t| - t.string "name" - t.string "path" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "creator_id" - t.boolean "issues_enabled", default: true, null: false - t.boolean "wall_enabled", default: true, null: false - t.boolean "merge_requests_enabled", default: true, null: false - t.boolean "wiki_enabled", default: true, null: false - t.integer "namespace_id" - t.string "issues_tracker", default: "gitlab", null: false - t.string "issues_tracker_id" - t.boolean "snippets_enabled", default: true, null: false - t.datetime "last_activity_at" - t.string "import_url" - t.integer "visibility_level", default: 0, null: false - t.boolean "archived", default: false, null: false - t.string "avatar" - t.string "import_status" - end - add_index "projects", ["creator_id"], name: "index_projects_on_creator_id", using: :btree - add_index "projects", ["last_activity_at"], name: "index_projects_on_last_activity_at", using: :btree - add_index "projects", ["namespace_id"], name: "index_projects_on_namespace_id", using: :btree - create_table "protected_branches", force: :cascade do |t| - t.integer "project_id", null: false - t.string "name", null: false - t.datetime "created_at" - t.datetime "updated_at" - end - add_index "protected_branches", ["project_id"], name: "index_protected_branches_on_project_id", using: :btree - create_table "services", force: :cascade do |t| - t.string "type" - t.string "title" - t.string "token" - t.integer "project_id", null: false - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "active", default: false, null: false - t.string "project_url" - t.string "subdomain" - t.string "room" - t.text "recipients" - t.string "api_key" - end - add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree - create_table "snippets", force: :cascade do |t| - t.string "title" - t.text "content" - t.integer "author_id", null: false - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "file_name" - t.datetime "expires_at" - t.boolean "private", default: true, null: false - t.string "type" - end - add_index "snippets", ["author_id"], name: "index_snippets_on_author_id", using: :btree - add_index "snippets", ["created_at"], name: "index_snippets_on_created_at", using: :btree - add_index "snippets", ["expires_at"], name: "index_snippets_on_expires_at", using: :btree - add_index "snippets", ["project_id"], name: "index_snippets_on_project_id", using: :btree - create_table "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" - t.datetime "created_at" - end - add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree - add_index "taggings", %w[taggable_id taggable_type context], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree - create_table "tags", force: :cascade do |t| - t.string "name" - end - create_table "users", force: :cascade do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0 - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.datetime "created_at" - t.datetime "updated_at" - t.string "name" - t.boolean "admin", default: false, null: false - t.integer "projects_limit", default: 10 - t.string "skype", default: "", null: false - t.string "linkedin", default: "", null: false - t.string "twitter", default: "", null: false - t.string "authentication_token" - t.integer "theme_id", default: 1, null: false - t.string "bio" - t.integer "failed_attempts", default: 0 - t.datetime "locked_at" - t.string "extern_uid" - t.string "provider" - t.string "username" - t.boolean "can_create_group", default: true, null: false - t.boolean "can_create_team", default: true, null: false - t.string "state" - t.integer "color_scheme_id", default: 1, null: false - t.integer "notification_level", default: 1, null: false - t.datetime "password_expires_at" - t.integer "created_by_id" - t.datetime "last_credential_check_at" - t.string "avatar" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.boolean "hide_no_ssh_key", default: false - t.string "website_url", default: "", null: false - end - add_index "users", ["admin"], name: "index_users_on_admin", using: :btree - 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", ["email"], name: "index_users_on_email", unique: true, using: :btree - add_index "users", %w[extern_uid provider], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree - add_index "users", ["name"], name: "index_users_on_name", using: :btree - add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree - add_index "users", ["username"], name: "index_users_on_username", using: :btree - create_table "users_groups", force: :cascade do |t| - t.integer "group_access", null: false - t.integer "group_id", null: false - t.integer "user_id", null: false - t.datetime "created_at" - t.datetime "updated_at" - t.integer "notification_level", default: 3, null: false - end - add_index "users_groups", ["user_id"], name: "index_users_groups_on_user_id", using: :btree - create_table "users_projects", force: :cascade do |t| - t.integer "user_id", null: false - t.integer "project_id", null: false - t.datetime "created_at" - t.datetime "updated_at" - t.integer "project_access", default: 0, null: false - t.integer "notification_level", default: 3, null: false - end - add_index "users_projects", ["project_access"], name: "index_users_projects_on_project_access", using: :btree - add_index "users_projects", ["project_id"], name: "index_users_projects_on_project_id", using: :btree - add_index "users_projects", ["user_id"], name: "index_users_projects_on_user_id", using: :btree - create_table "web_hooks", force: :cascade do |t| - t.string "url" - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "type", default: "ProjectHook" - t.integer "service_id" - t.boolean "push_events", default: true, null: false - t.boolean "issues_events", default: false, null: false - t.boolean "merge_requests_events", default: false, null: false - t.boolean "tag_push_events", default: false - end - add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree - end - - def down - raise ActiveRecord::IrreversibleMigration, "The initial migration is not revertable" - end -end diff --git a/db/migrate/20140407135544_fix_namespaces.rb b/db/migrate/20140407135544_fix_namespaces.rb deleted file mode 100644 index b16d65c4b51..00000000000 --- a/db/migrate/20140407135544_fix_namespaces.rb +++ /dev/null @@ -1,16 +0,0 @@ -class FixNamespaces < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - namespaces = exec_query('SELECT id, path FROM namespaces WHERE name <> path and type is null') - - namespaces.each do |row| - id = row['id'] - path = row['path'] - exec_query("UPDATE namespaces SET name = '#{path}' WHERE id = #{id}") - end - end - - def down - end -end diff --git a/db/migrate/20140414131055_change_state_to_allow_empty_merge_request_diffs.rb b/db/migrate/20140414131055_change_state_to_allow_empty_merge_request_diffs.rb deleted file mode 100644 index 1f9ae3f0080..00000000000 --- a/db/migrate/20140414131055_change_state_to_allow_empty_merge_request_diffs.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ChangeStateToAllowEmptyMergeRequestDiffs < ActiveRecord::Migration[4.2] - def up - change_column :merge_request_diffs, :state, :string, null: true, - default: nil - end - - def down - change_column :merge_request_diffs, :state, :string, null: false, - default: 'collected' - end -end diff --git a/db/migrate/20140415124820_limits_to_mysql.rb b/db/migrate/20140415124820_limits_to_mysql.rb deleted file mode 100644 index 3f6e62617c5..00000000000 --- a/db/migrate/20140415124820_limits_to_mysql.rb +++ /dev/null @@ -1 +0,0 @@ -require_relative 'limits_to_mysql' diff --git a/db/migrate/20140416074002_add_index_on_iid.rb b/db/migrate/20140416074002_add_index_on_iid.rb deleted file mode 100644 index c7f707ca123..00000000000 --- a/db/migrate/20140416074002_add_index_on_iid.rb +++ /dev/null @@ -1,33 +0,0 @@ -# rubocop:disable all -class AddIndexOnIid < ActiveRecord::Migration[4.2] - def change - RemoveDuplicateIid.clean(Issue) - RemoveDuplicateIid.clean(MergeRequest, 'target_project_id') - RemoveDuplicateIid.clean(Milestone) - - add_index :issues, [:project_id, :iid], unique: true - add_index :merge_requests, [:target_project_id, :iid], unique: true - add_index :milestones, [:project_id, :iid], unique: true - end -end - -class RemoveDuplicateIid - def self.clean(klass, project_field = 'project_id') - duplicates = klass.find_by_sql("SELECT iid, #{project_field} FROM #{klass.table_name} GROUP BY #{project_field}, iid HAVING COUNT(*) > 1") - - duplicates.each do |duplicate| - project_id = duplicate.send(project_field) - iid = duplicate.iid - items = klass.of_projects(project_id).where(iid: iid) - - if items.size > 1 - puts "Remove #{klass.name} duplicates for iid: #{iid} and project_id: #{project_id}" - items.shift - items.each do |item| - item.destroy - puts '.' - end - end - end - end -end diff --git a/db/migrate/20140416185734_index_on_current_sign_in_at.rb b/db/migrate/20140416185734_index_on_current_sign_in_at.rb deleted file mode 100644 index 7dabcb937b3..00000000000 --- a/db/migrate/20140416185734_index_on_current_sign_in_at.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class IndexOnCurrentSignInAt < ActiveRecord::Migration[4.2] - def change - add_index :users, :current_sign_in_at - end -end diff --git a/db/migrate/20140428105831_add_notes_index_updated_at.rb b/db/migrate/20140428105831_add_notes_index_updated_at.rb deleted file mode 100644 index 25bdf477e24..00000000000 --- a/db/migrate/20140428105831_add_notes_index_updated_at.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddNotesIndexUpdatedAt < ActiveRecord::Migration[4.2] - def change - add_index :notes, :updated_at - end -end diff --git a/db/migrate/20140502115131_add_repo_size_to_db.rb b/db/migrate/20140502115131_add_repo_size_to_db.rb deleted file mode 100644 index 4cb7a01bbf2..00000000000 --- a/db/migrate/20140502115131_add_repo_size_to_db.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddRepoSizeToDb < ActiveRecord::Migration[4.2] - def change - add_column :projects, :repository_size, :float, default: 0 - end -end diff --git a/db/migrate/20140502125220_migrate_repo_size.rb b/db/migrate/20140502125220_migrate_repo_size.rb deleted file mode 100644 index bff1f01c654..00000000000 --- a/db/migrate/20140502125220_migrate_repo_size.rb +++ /dev/null @@ -1,31 +0,0 @@ -# rubocop:disable all -class MigrateRepoSize < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - project_data = execute('SELECT projects.id, namespaces.path AS namespace_path, projects.path AS project_path FROM projects LEFT JOIN namespaces ON projects.namespace_id = namespaces.id') - - project_data.each do |project| - id = project['id'] - namespace_path = project['namespace_path'] || '' - path = File.join(namespace_path, project['project_path'] + '.git') - - begin - repo = Gitlab::Git::Repository.new('default', path, '', '') - if repo.empty? - print '-' - else - size = repo.size - print '.' - execute("UPDATE projects SET repository_size = #{size} WHERE id = #{id}") - end - rescue => e - puts "\nFailed to update project #{id}: #{e}" - end - end - puts "\nDone" - end - - def down - end -end diff --git a/db/migrate/20140611135229_add_position_to_merge_request.rb b/db/migrate/20140611135229_add_position_to_merge_request.rb deleted file mode 100644 index 6ec644eecce..00000000000 --- a/db/migrate/20140611135229_add_position_to_merge_request.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddPositionToMergeRequest < ActiveRecord::Migration[4.2] - def change - add_column :merge_requests, :position, :integer, default: 0 - end -end diff --git a/db/migrate/20140625115202_create_users_star_projects.rb b/db/migrate/20140625115202_create_users_star_projects.rb deleted file mode 100644 index 2237927fc78..00000000000 --- a/db/migrate/20140625115202_create_users_star_projects.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable all -class CreateUsersStarProjects < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :users_star_projects do |t| - t.integer :project_id, null: false - t.integer :user_id, null: false - t.timestamps null: true - end - add_index :users_star_projects, :user_id - add_index :users_star_projects, :project_id - add_index :users_star_projects, [:user_id, :project_id], unique: true - - add_column :projects, :star_count, :integer, default: 0, null: false - add_index :projects, :star_count, using: :btree - end -end diff --git a/db/migrate/20140729134820_create_labels.rb b/db/migrate/20140729134820_create_labels.rb deleted file mode 100644 index 1060610b660..00000000000 --- a/db/migrate/20140729134820_create_labels.rb +++ /dev/null @@ -1,14 +0,0 @@ -# rubocop:disable all -class CreateLabels < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :labels do |t| - t.string :title - t.string :color - t.integer :project_id - - t.timestamps null: true - end - end -end diff --git a/db/migrate/20140729140420_create_label_links.rb b/db/migrate/20140729140420_create_label_links.rb deleted file mode 100644 index b8596a44a21..00000000000 --- a/db/migrate/20140729140420_create_label_links.rb +++ /dev/null @@ -1,14 +0,0 @@ -# rubocop:disable all -class CreateLabelLinks < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :label_links do |t| - t.integer :label_id - t.integer :target_id - t.string :target_type - - t.timestamps null: true - end - end -end diff --git a/db/migrate/20140729145339_migrate_project_tags.rb b/db/migrate/20140729145339_migrate_project_tags.rb deleted file mode 100644 index 711a2d262aa..00000000000 --- a/db/migrate/20140729145339_migrate_project_tags.rb +++ /dev/null @@ -1,9 +0,0 @@ -class MigrateProjectTags < ActiveRecord::Migration[4.2] - def up - ActsAsTaggableOn::Tagging.where(taggable_type: 'Project', context: 'labels').update_all(context: 'tags') - end - - def down - ActsAsTaggableOn::Tagging.where(taggable_type: 'Project', context: 'tags').update_all(context: 'labels') - end -end diff --git a/db/migrate/20140729152420_migrate_taggable_labels.rb b/db/migrate/20140729152420_migrate_taggable_labels.rb deleted file mode 100644 index a8bf8022dfc..00000000000 --- a/db/migrate/20140729152420_migrate_taggable_labels.rb +++ /dev/null @@ -1,36 +0,0 @@ -# rubocop:disable all -class MigrateTaggableLabels < ActiveRecord::Migration[4.2] - def up - taggings = ActsAsTaggableOn::Tagging.where(taggable_type: ['Issue', 'MergeRequest'], context: 'labels') - taggings.find_each(batch_size: 500) do |tagging| - # Clean up orphaned taggings while we are here - if tagging.taggable.blank? || tagging.tag.nil? - tagging.destroy - print 'D' - next - end - create_label_from_tagging(tagging) - end - end - - def down - Label.destroy_all - LabelLink.destroy_all - end - - private - - def create_label_from_tagging(tagging) - target = tagging.taggable - label_name = tagging.tag.name - # '?', '&' and ',' are no longer allowed in label names so we remove them - label_name.tr!('?&,', '') - label = target.project.labels.find_or_create_by(title: label_name, color: Label::DEFAULT_COLOR) - - if label.valid? && LabelLink.create(label: label, target: target) - print '.' - else - print 'F' - end - end -end diff --git a/db/migrate/20140730111702_add_index_to_labels.rb b/db/migrate/20140730111702_add_index_to_labels.rb deleted file mode 100644 index 21f9dfd5d47..00000000000 --- a/db/migrate/20140730111702_add_index_to_labels.rb +++ /dev/null @@ -1,8 +0,0 @@ -# rubocop:disable all -class AddIndexToLabels < ActiveRecord::Migration[4.2] - def change - add_index "labels", :project_id - add_index "label_links", :label_id - add_index "label_links", [:target_id, :target_type] - end -end diff --git a/db/migrate/20140903115954_migrate_to_new_shell.rb b/db/migrate/20140903115954_migrate_to_new_shell.rb deleted file mode 100644 index cc0cce483b1..00000000000 --- a/db/migrate/20140903115954_migrate_to_new_shell.rb +++ /dev/null @@ -1,13 +0,0 @@ -# rubocop:disable all -class MigrateToNewShell < ActiveRecord::Migration[4.2] - def change - return if Rails.env.test? - - gitlab_shell_path = Gitlab.config.gitlab_shell.path - if system("#{gitlab_shell_path}/bin/create-hooks") - puts 'Repositories updated with new hooks' - else - raise 'Failed to rewrite gitlab-shell hooks in repositories' - end - end -end diff --git a/db/migrate/20140907220153_serialize_service_properties.rb b/db/migrate/20140907220153_serialize_service_properties.rb deleted file mode 100644 index bf94c64654b..00000000000 --- a/db/migrate/20140907220153_serialize_service_properties.rb +++ /dev/null @@ -1,43 +0,0 @@ -# rubocop:disable all -class SerializeServiceProperties < ActiveRecord::Migration[4.2] - def change - unless column_exists?(:services, :properties) - add_column :services, :properties, :text - end - - Service.reset_column_information - - associations = - { - AssemblaService: [:token, :subdomain], - CampfireService: [:token, :subdomain, :room], - EmailsOnPushService: [:recipients], - FlowdockService: [:token], - GemnasiumService: [:api_key, :token], - GitlabCiService: [:token, :project_url], - HipchatService: [:token, :room], - PivotaltrackerService: [:token], - SlackService: [:subdomain, :token, :room], - JenkinsService: [:project_url], - JiraService: [:project_url, :username, :password, - :api_version, :jira_issue_transition_id], - } - - Service.find_each(batch_size: 500).each do |service| - associations[service.type.to_sym].each do |attribute| - service.send("#{attribute}=", service.attributes[attribute.to_s]) - end - - service.save(validate: false) - end - - if column_exists?(:services, :project_url) - remove_column :services, :project_url, :string - remove_column :services, :subdomain, :string - remove_column :services, :room, :string - remove_column :services, :recipients, :text - remove_column :services, :api_key, :string - remove_column :services, :token, :string - end - end -end diff --git a/db/migrate/20140914113604_add_members_table.rb b/db/migrate/20140914113604_add_members_table.rb deleted file mode 100644 index 312ea1b94df..00000000000 --- a/db/migrate/20140914113604_add_members_table.rb +++ /dev/null @@ -1,22 +0,0 @@ -# rubocop:disable all -class AddMembersTable < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :members do |t| - t.integer :access_level, null: false - t.integer :source_id, null: false - t.string :source_type, null: false - t.integer :user_id, null: false - t.integer :notification_level, null: false - t.string :type - - t.timestamps null: true - end - - add_index :members, :type - add_index :members, :user_id - add_index :members, :access_level - add_index :members, [:source_id, :source_type] - end -end diff --git a/db/migrate/20140914145549_migrate_to_new_members_model.rb b/db/migrate/20140914145549_migrate_to_new_members_model.rb deleted file mode 100644 index 22d8b3d651b..00000000000 --- a/db/migrate/20140914145549_migrate_to_new_members_model.rb +++ /dev/null @@ -1,12 +0,0 @@ -# rubocop:disable all -class MigrateToNewMembersModel < ActiveRecord::Migration[4.2] - def up - execute "INSERT INTO members ( user_id, source_id, source_type, access_level, notification_level, type ) SELECT user_id, group_id, 'Namespace', group_access, notification_level, 'GroupMember' FROM users_groups" - execute "INSERT INTO members ( user_id, source_id, source_type, access_level, notification_level, type ) SELECT user_id, project_id, 'Project', project_access, notification_level, 'ProjectMember' FROM users_projects" - end - - def down - Member.delete_all - end -end - diff --git a/db/migrate/20140914173417_remove_old_member_tables.rb b/db/migrate/20140914173417_remove_old_member_tables.rb deleted file mode 100644 index edd69caa470..00000000000 --- a/db/migrate/20140914173417_remove_old_member_tables.rb +++ /dev/null @@ -1,29 +0,0 @@ -# rubocop:disable all -class RemoveOldMemberTables < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - drop_table :users_groups - drop_table :users_projects - end - - def down - create_table :users_groups do |t| - t.integer :group_access, null: false - t.integer :group_id, null: false - t.integer :user_id, null: false - t.integer :notification_level, null: false, default: 3 - - t.timestamps null: true - end - - create_table :users_projects do |t| - t.integer :project_access, null: false - t.integer :project_id, null: false - t.integer :user_id, null: false - t.integer :notification_level, null: false, default: 3 - - t.timestamps null: true - end - end -end diff --git a/db/migrate/20141006143943_move_slack_service_to_webhook.rb b/db/migrate/20141006143943_move_slack_service_to_webhook.rb deleted file mode 100644 index 1c9a1a74a4e..00000000000 --- a/db/migrate/20141006143943_move_slack_service_to_webhook.rb +++ /dev/null @@ -1,22 +0,0 @@ -# rubocop:disable all -class MoveSlackServiceToWebhook < ActiveRecord::Migration[4.2] - - DOWNTIME = true - DOWNTIME_REASON = 'Move old fields "token" and "subdomain" to one single field "webhook"' - - def change - SlackService.all.each do |slack_service| - if ["token", "subdomain"].all? { |property| slack_service.properties.key? property } - token = slack_service.properties['token'] - subdomain = slack_service.properties['subdomain'] - webhook = "https://#{subdomain}.slack.com/services/hooks/incoming-webhook?token=#{token}" - slack_service.properties['webhook'] = webhook - slack_service.properties.delete('token') - slack_service.properties.delete('subdomain') - # Room is configured on the Slack side - slack_service.properties.delete('room') - slack_service.save(validate: false) - end - end - end -end diff --git a/db/migrate/20141007100818_add_visibility_level_to_snippet.rb b/db/migrate/20141007100818_add_visibility_level_to_snippet.rb deleted file mode 100644 index 9501aed8931..00000000000 --- a/db/migrate/20141007100818_add_visibility_level_to_snippet.rb +++ /dev/null @@ -1,24 +0,0 @@ -# rubocop:disable all -class AddVisibilityLevelToSnippet < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def up - add_column :snippets, :visibility_level, :integer, :default => 0, :null => false - - execute("UPDATE snippets SET visibility_level = #{Gitlab::VisibilityLevel::PRIVATE} WHERE private = #{true_value}") - execute("UPDATE snippets SET visibility_level = #{Gitlab::VisibilityLevel::INTERNAL} WHERE private = #{false_value}") - - add_index :snippets, :visibility_level - - remove_column :snippets, :private - end - - def down - add_column :snippets, :private, :boolean, :default => false, :null => false - - execute("UPDATE snippets SET private = #{false_value} WHERE visibility_level = #{Gitlab::VisibilityLevel::INTERNAL}") - execute("UPDATE snippets SET private = #{true_value} WHERE visibility_level = #{Gitlab::VisibilityLevel::PRIVATE}") - - remove_column :snippets, :visibility_level - end -end diff --git a/db/migrate/20141118150935_add_audit_event.rb b/db/migrate/20141118150935_add_audit_event.rb deleted file mode 100644 index 1e7dba568c9..00000000000 --- a/db/migrate/20141118150935_add_audit_event.rb +++ /dev/null @@ -1,25 +0,0 @@ -# rubocop:disable all -class AddAuditEvent < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :audit_events do |t| - t.integer :author_id, null: false - t.string :type, null: false - - # "Namespace" where the change occurs - # eg. On a project, group or user - t.integer :entity_id, null: false - t.string :entity_type, null: false - - # Details for the event - t.text :details - - t.timestamps null: true - end - - add_index :audit_events, :author_id - add_index :audit_events, :type - add_index :audit_events, [:entity_id, :entity_type] - end -end diff --git a/db/migrate/20141121133009_add_timestamps_to_members.rb b/db/migrate/20141121133009_add_timestamps_to_members.rb deleted file mode 100644 index cb575fc9ed7..00000000000 --- a/db/migrate/20141121133009_add_timestamps_to_members.rb +++ /dev/null @@ -1,15 +0,0 @@ -# In 20140914145549_migrate_to_new_members_model.rb we forgot to set the -# created_at and updated_at times for new records in the 'members' table. This -# became a problem after commit c8e78d972a5a628870eefca0f2ccea0199c55bda which -# was added in GitLab 7.5. With this migration we ensure that all rows in -# 'members' have at least some created_at and updated_at timestamp. -class AddTimestampsToMembers < ActiveRecord::Migration[4.2] - def up - execute "UPDATE members SET created_at = NOW() WHERE created_at is NULL" - execute "UPDATE members SET updated_at = NOW() WHERE updated_at is NULL" - end - - def down - # no change - end -end diff --git a/db/migrate/20141121161704_add_identity_table.rb b/db/migrate/20141121161704_add_identity_table.rb deleted file mode 100644 index 92f7a568077..00000000000 --- a/db/migrate/20141121161704_add_identity_table.rb +++ /dev/null @@ -1,47 +0,0 @@ -# rubocop:disable all -class AddIdentityTable < ActiveRecord::Migration[4.2] - def up - create_table :identities do |t| - t.string :extern_uid - t.string :provider - t.references :user - end - - add_index :identities, :user_id - - execute <<eos -INSERT INTO identities (provider, extern_uid, user_id) -SELECT provider, extern_uid, id FROM users -WHERE provider IS NOT NULL -eos - - if index_exists?(:users, ["extern_uid", "provider"]) - remove_index :users, ["extern_uid", "provider"] - end - - remove_column :users, :extern_uid - remove_column :users, :provider - end - - def down - add_column :users, :extern_uid, :string - add_column :users, :provider, :string - - if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' - execute <<eos -UPDATE users u -SET provider = i.provider, extern_uid = i.extern_uid -FROM identities i -WHERE i.user_id = u.id -eos - else - execute "UPDATE users u, identities i SET u.provider = i.provider, u.extern_uid = i.extern_uid WHERE u.id = i.user_id" - end - - drop_table :identities - - unless index_exists?(:users, ["extern_uid", "provider"]) - add_index "users", ["extern_uid", "provider"], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree - end - end -end diff --git a/db/migrate/20141126120926_add_merge_request_rebase_enabled_to_projects.rb b/db/migrate/20141126120926_add_merge_request_rebase_enabled_to_projects.rb deleted file mode 100644 index b9d8a5cb435..00000000000 --- a/db/migrate/20141126120926_add_merge_request_rebase_enabled_to_projects.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable all -class AddMergeRequestRebaseEnabledToProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:projects, :merge_requests_rebase_enabled, :boolean, default: false) - end - - def down - remove_column(:projects, :merge_requests_rebase_enabled) - end -end diff --git a/db/migrate/20141205134006_add_locked_at_to_merge_request.rb b/db/migrate/20141205134006_add_locked_at_to_merge_request.rb deleted file mode 100644 index 6fdfb3eb974..00000000000 --- a/db/migrate/20141205134006_add_locked_at_to_merge_request.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddLockedAtToMergeRequest < ActiveRecord::Migration[4.2] - def change - add_column :merge_requests, :locked_at, :datetime - end -end diff --git a/db/migrate/20141216155758_create_doorkeeper_tables.rb b/db/migrate/20141216155758_create_doorkeeper_tables.rb deleted file mode 100644 index 7bd0a15e7f5..00000000000 --- a/db/migrate/20141216155758_create_doorkeeper_tables.rb +++ /dev/null @@ -1,45 +0,0 @@ -# rubocop:disable all -class CreateDoorkeeperTables < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :oauth_applications do |t| - t.string :name, null: false - t.string :uid, null: false - t.string :secret, null: false - t.text :redirect_uri, null: false - t.string :scopes, null: false, default: '' - t.timestamps null: true - end - - add_index :oauth_applications, :uid, unique: true - - create_table :oauth_access_grants do |t| - t.integer :resource_owner_id, null: false - t.integer :application_id, null: false - t.string :token, null: false - t.integer :expires_in, null: false - t.text :redirect_uri, null: false - t.datetime :created_at, null: false - t.datetime :revoked_at - t.string :scopes - end - - add_index :oauth_access_grants, :token, unique: true - - create_table :oauth_access_tokens do |t| - t.integer :resource_owner_id - t.integer :application_id - t.string :token, null: false - t.string :refresh_token - t.integer :expires_in - t.datetime :revoked_at - t.datetime :created_at, null: false - t.string :scopes - end - - add_index :oauth_access_tokens, :token, unique: true - add_index :oauth_access_tokens, :resource_owner_id - add_index :oauth_access_tokens, :refresh_token, unique: true - end -end diff --git a/db/migrate/20141217125223_add_owner_to_application.rb b/db/migrate/20141217125223_add_owner_to_application.rb deleted file mode 100644 index 482a53f3ad5..00000000000 --- a/db/migrate/20141217125223_add_owner_to_application.rb +++ /dev/null @@ -1,8 +0,0 @@ -# rubocop:disable all -class AddOwnerToApplication < ActiveRecord::Migration[4.2] - def change - add_column :oauth_applications, :owner_id, :integer, null: true - add_column :oauth_applications, :owner_type, :string, null: true - add_index :oauth_applications, [:owner_id, :owner_type] - end -end
\ No newline at end of file diff --git a/db/migrate/20141223135007_add_import_data_to_project_table.rb b/db/migrate/20141223135007_add_import_data_to_project_table.rb deleted file mode 100644 index 516f58d645e..00000000000 --- a/db/migrate/20141223135007_add_import_data_to_project_table.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddImportDataToProjectTable < ActiveRecord::Migration[4.2] - def change - add_column :projects, :import_type, :string - add_column :projects, :import_source, :string - - add_column :users, :github_access_token, :string - end -end diff --git a/db/migrate/20141226080412_add_developers_can_push_to_protected_branches.rb b/db/migrate/20141226080412_add_developers_can_push_to_protected_branches.rb deleted file mode 100644 index 43b7de85228..00000000000 --- a/db/migrate/20141226080412_add_developers_can_push_to_protected_branches.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddDevelopersCanPushToProtectedBranches < ActiveRecord::Migration[4.2] - def change - add_column :protected_branches, :developers_can_push, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20150108073740_create_application_settings.rb b/db/migrate/20150108073740_create_application_settings.rb deleted file mode 100644 index be139fee63a..00000000000 --- a/db/migrate/20150108073740_create_application_settings.rb +++ /dev/null @@ -1,16 +0,0 @@ -# rubocop:disable all -class CreateApplicationSettings < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :application_settings do |t| - t.integer :default_projects_limit - t.boolean :signup_enabled - t.boolean :signin_enabled - t.boolean :gravatar_enabled - t.text :sign_in_text - - t.timestamps null: true - end - end -end diff --git a/db/migrate/20150116234544_add_home_page_url_for_application_settings.rb b/db/migrate/20150116234544_add_home_page_url_for_application_settings.rb deleted file mode 100644 index e630e2cc878..00000000000 --- a/db/migrate/20150116234544_add_home_page_url_for_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddHomePageUrlForApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :home_page_url, :string - end -end diff --git a/db/migrate/20150116234545_add_gitlab_access_token_to_user.rb b/db/migrate/20150116234545_add_gitlab_access_token_to_user.rb deleted file mode 100644 index 673628e106b..00000000000 --- a/db/migrate/20150116234545_add_gitlab_access_token_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddGitlabAccessTokenToUser < ActiveRecord::Migration[4.2] - def change - add_column :users, :gitlab_access_token, :string - end -end diff --git a/db/migrate/20150125163100_add_default_branch_protection_setting.rb b/db/migrate/20150125163100_add_default_branch_protection_setting.rb deleted file mode 100644 index f6bfa422124..00000000000 --- a/db/migrate/20150125163100_add_default_branch_protection_setting.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddDefaultBranchProtectionSetting < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :default_branch_protection, :integer, :default => 2 - end -end diff --git a/db/migrate/20150205211843_add_timestamps_to_identities.rb b/db/migrate/20150205211843_add_timestamps_to_identities.rb deleted file mode 100644 index c535a7ec781..00000000000 --- a/db/migrate/20150205211843_add_timestamps_to_identities.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddTimestampsToIdentities < ActiveRecord::Migration[4.2] - def change - add_timestamps(:identities) - end -end diff --git a/db/migrate/20150206181414_add_index_to_created_at.rb b/db/migrate/20150206181414_add_index_to_created_at.rb deleted file mode 100644 index 501acd6a720..00000000000 --- a/db/migrate/20150206181414_add_index_to_created_at.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable all -class AddIndexToCreatedAt < ActiveRecord::Migration[4.2] - def change - add_index "users", [:created_at, :id] - add_index "members", [:created_at, :id] - add_index "projects", [:created_at, :id] - add_index "issues", [:created_at, :id] - add_index "merge_requests", [:created_at, :id] - add_index "milestones", [:created_at, :id] - add_index "namespaces", [:created_at, :id] - add_index "notes", [:created_at, :id] - add_index "identities", [:created_at, :id] - add_index "keys", [:created_at, :id] - add_index "web_hooks", [:created_at, :id] - add_index "snippets", [:created_at, :id] - end -end diff --git a/db/migrate/20150206222854_add_notification_email_to_user.rb b/db/migrate/20150206222854_add_notification_email_to_user.rb deleted file mode 100644 index 7b0c251db4f..00000000000 --- a/db/migrate/20150206222854_add_notification_email_to_user.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddNotificationEmailToUser < ActiveRecord::Migration[4.2] - def up - add_column :users, :notification_email, :string - - execute "UPDATE users SET notification_email = email" - end - - def down - remove_column :users, :notification_email - end -end diff --git a/db/migrate/20150209222013_add_missing_index.rb b/db/migrate/20150209222013_add_missing_index.rb deleted file mode 100644 index 99544ab3928..00000000000 --- a/db/migrate/20150209222013_add_missing_index.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddMissingIndex < ActiveRecord::Migration[4.2] - def change - add_index "services", [:created_at, :id] - end -end diff --git a/db/migrate/20150211172122_add_template_to_service.rb b/db/migrate/20150211172122_add_template_to_service.rb deleted file mode 100644 index dd192a0fe76..00000000000 --- a/db/migrate/20150211172122_add_template_to_service.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddTemplateToService < ActiveRecord::Migration[4.2] - def change - add_column :services, :template, :boolean, default: false - end -end diff --git a/db/migrate/20150211174341_allow_null_in_services_project_id.rb b/db/migrate/20150211174341_allow_null_in_services_project_id.rb deleted file mode 100644 index 4c90bf9c419..00000000000 --- a/db/migrate/20150211174341_allow_null_in_services_project_id.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AllowNullInServicesProjectId < ActiveRecord::Migration[4.2] - def change - change_column :services, :project_id, :integer, null: true - end -end diff --git a/db/migrate/20150213104043_add_twitter_sharing_enabled_to_application_settings.rb b/db/migrate/20150213104043_add_twitter_sharing_enabled_to_application_settings.rb deleted file mode 100644 index 7d7b9242cd6..00000000000 --- a/db/migrate/20150213104043_add_twitter_sharing_enabled_to_application_settings.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddTwitterSharingEnabledToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :twitter_sharing_enabled, :boolean, default: true - end -end diff --git a/db/migrate/20150213114800_add_hide_no_password_to_user.rb b/db/migrate/20150213114800_add_hide_no_password_to_user.rb deleted file mode 100644 index 348c0d22aba..00000000000 --- a/db/migrate/20150213114800_add_hide_no_password_to_user.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddHideNoPasswordToUser < ActiveRecord::Migration[4.2] - def change - add_column :users, :hide_no_password, :boolean, default: false - end -end diff --git a/db/migrate/20150213121042_add_password_automatically_set_to_user.rb b/db/migrate/20150213121042_add_password_automatically_set_to_user.rb deleted file mode 100644 index d0eb753b887..00000000000 --- a/db/migrate/20150213121042_add_password_automatically_set_to_user.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddPasswordAutomaticallySetToUser < ActiveRecord::Migration[4.2] - def change - add_column :users, :password_automatically_set, :boolean, default: false - end -end diff --git a/db/migrate/20150217123345_add_bitbucket_access_token_and_secret_to_user.rb b/db/migrate/20150217123345_add_bitbucket_access_token_and_secret_to_user.rb deleted file mode 100644 index 639644174ca..00000000000 --- a/db/migrate/20150217123345_add_bitbucket_access_token_and_secret_to_user.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddBitbucketAccessTokenAndSecretToUser < ActiveRecord::Migration[4.2] - def change - add_column :users, :bitbucket_access_token, :string - add_column :users, :bitbucket_access_token_secret, :string - end -end diff --git a/db/migrate/20150219004514_add_events_to_services.rb b/db/migrate/20150219004514_add_events_to_services.rb deleted file mode 100644 index 7072056adcb..00000000000 --- a/db/migrate/20150219004514_add_events_to_services.rb +++ /dev/null @@ -1,9 +0,0 @@ -# rubocop:disable all -class AddEventsToServices < ActiveRecord::Migration[4.2] - def change - add_column :services, :push_events, :boolean, :default => true - add_column :services, :issues_events, :boolean, :default => true - add_column :services, :merge_requests_events, :boolean, :default => true - add_column :services, :tag_push_events, :boolean, :default => true - end -end diff --git a/db/migrate/20150223022001_set_missing_last_activity_at.rb b/db/migrate/20150223022001_set_missing_last_activity_at.rb deleted file mode 100644 index c77ffbd4ebd..00000000000 --- a/db/migrate/20150223022001_set_missing_last_activity_at.rb +++ /dev/null @@ -1,8 +0,0 @@ -class SetMissingLastActivityAt < ActiveRecord::Migration[4.2] - def up - execute "UPDATE projects SET last_activity_at = updated_at WHERE last_activity_at IS NULL" - end - - def down - end -end diff --git a/db/migrate/20150225065047_add_note_events_to_services.rb b/db/migrate/20150225065047_add_note_events_to_services.rb deleted file mode 100644 index 32c538e8681..00000000000 --- a/db/migrate/20150225065047_add_note_events_to_services.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddNoteEventsToServices < ActiveRecord::Migration[4.2] - def change - add_column :services, :note_events, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20150301014758_add_restricted_visibility_levels_to_application_settings.rb b/db/migrate/20150301014758_add_restricted_visibility_levels_to_application_settings.rb deleted file mode 100644 index 3091790f199..00000000000 --- a/db/migrate/20150301014758_add_restricted_visibility_levels_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRestrictedVisibilityLevelsToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :restricted_visibility_levels, :text - end -end diff --git a/db/migrate/20150306023106_fix_namespace_duplication.rb b/db/migrate/20150306023106_fix_namespace_duplication.rb deleted file mode 100644 index 49be152a75c..00000000000 --- a/db/migrate/20150306023106_fix_namespace_duplication.rb +++ /dev/null @@ -1,22 +0,0 @@ -# rubocop:disable all -class FixNamespaceDuplication < ActiveRecord::Migration[4.2] - def up - #fixes path duplication - select_all('SELECT MAX(id) max, COUNT(id) cnt, path FROM namespaces GROUP BY path HAVING COUNT(id) > 1').each do |nms| - bad_nms_ids = select_all("SELECT id FROM namespaces WHERE path = '#{nms['path']}' AND id <> #{nms['max']}").map{|x| x["id"]} - execute("UPDATE projects SET namespace_id = #{nms["max"]} WHERE namespace_id IN(#{bad_nms_ids.join(', ')})") - execute("DELETE FROM namespaces WHERE id IN(#{bad_nms_ids.join(', ')})") - end - - #fixes name duplication - select_all('SELECT MAX(id) max, COUNT(id) cnt, name FROM namespaces GROUP BY name HAVING COUNT(id) > 1').each do |nms| - bad_nms_ids = select_all("SELECT id FROM namespaces WHERE name = '#{nms['name']}' AND id <> #{nms['max']}").map{|x| x["id"]} - execute("UPDATE projects SET namespace_id = #{nms["max"]} WHERE namespace_id IN(#{bad_nms_ids.join(', ')})") - execute("DELETE FROM namespaces WHERE id IN(#{bad_nms_ids.join(', ')})") - end - end - - def down - # not implemented - end -end diff --git a/db/migrate/20150306023112_add_unique_index_to_namespace.rb b/db/migrate/20150306023112_add_unique_index_to_namespace.rb deleted file mode 100644 index 11472324cbf..00000000000 --- a/db/migrate/20150306023112_add_unique_index_to_namespace.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable all -class AddUniqueIndexToNamespace < ActiveRecord::Migration[4.2] - def change - remove_index :namespaces, column: :name if index_exists?(:namespaces, :name) - remove_index :namespaces, column: :path if index_exists?(:namespaces, :path) - - add_index :namespaces, :name, unique: true - add_index :namespaces, :path, unique: true - end -end diff --git a/db/migrate/20150310194358_add_version_check_to_application_settings.rb b/db/migrate/20150310194358_add_version_check_to_application_settings.rb deleted file mode 100644 index cc1b19f302e..00000000000 --- a/db/migrate/20150310194358_add_version_check_to_application_settings.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddVersionCheckToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :version_check_enabled, :boolean, default: true - end -end diff --git a/db/migrate/20150313012111_create_subscriptions_table.rb b/db/migrate/20150313012111_create_subscriptions_table.rb deleted file mode 100644 index 37011504b49..00000000000 --- a/db/migrate/20150313012111_create_subscriptions_table.rb +++ /dev/null @@ -1,19 +0,0 @@ -# rubocop:disable all -class CreateSubscriptionsTable < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :subscriptions do |t| - t.integer :user_id - t.references :subscribable, polymorphic: true - t.boolean :subscribed - - t.timestamps null: true - end - - add_index :subscriptions, - [:subscribable_id, :subscribable_type, :user_id], - unique: true, - name: 'subscriptions_user_id_and_ref_fields' - end -end diff --git a/db/migrate/20150320234437_add_location_to_user.rb b/db/migrate/20150320234437_add_location_to_user.rb deleted file mode 100644 index cf273ff916e..00000000000 --- a/db/migrate/20150320234437_add_location_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLocationToUser < ActiveRecord::Migration[4.2] - def change - add_column :users, :location, :string - end -end diff --git a/db/migrate/20150324155957_set_incorrect_assignee_id_to_null.rb b/db/migrate/20150324155957_set_incorrect_assignee_id_to_null.rb deleted file mode 100644 index a895d5f24f5..00000000000 --- a/db/migrate/20150324155957_set_incorrect_assignee_id_to_null.rb +++ /dev/null @@ -1,6 +0,0 @@ -class SetIncorrectAssigneeIdToNull < ActiveRecord::Migration[4.2] - def up - execute "UPDATE issues SET assignee_id = NULL WHERE assignee_id = -1" - execute "UPDATE merge_requests SET assignee_id = NULL WHERE assignee_id = -1" - end -end diff --git a/db/migrate/20150327122227_add_public_to_key.rb b/db/migrate/20150327122227_add_public_to_key.rb deleted file mode 100644 index 58d8c16476f..00000000000 --- a/db/migrate/20150327122227_add_public_to_key.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddPublicToKey < ActiveRecord::Migration[4.2] - def change - add_column :keys, :public, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20150327150017_add_import_data_to_project.rb b/db/migrate/20150327150017_add_import_data_to_project.rb deleted file mode 100644 index 5d393364ee6..00000000000 --- a/db/migrate/20150327150017_add_import_data_to_project.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddImportDataToProject < ActiveRecord::Migration[4.2] - def change - add_column :projects, :import_data, :text - end -end diff --git a/db/migrate/20150327223628_add_devise_two_factor_to_users.rb b/db/migrate/20150327223628_add_devise_two_factor_to_users.rb deleted file mode 100644 index 22202796547..00000000000 --- a/db/migrate/20150327223628_add_devise_two_factor_to_users.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddDeviseTwoFactorToUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :encrypted_otp_secret, :string - add_column :users, :encrypted_otp_secret_iv, :string - add_column :users, :encrypted_otp_secret_salt, :string - add_column :users, :otp_required_for_login, :boolean - end -end diff --git a/db/migrate/20150328132231_add_max_attachment_size_to_application_settings.rb b/db/migrate/20150328132231_add_max_attachment_size_to_application_settings.rb deleted file mode 100644 index 4ce60a257cb..00000000000 --- a/db/migrate/20150328132231_add_max_attachment_size_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMaxAttachmentSizeToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :max_attachment_size, :integer, default: 10, null: false - end -end diff --git a/db/migrate/20150331183602_add_devise_two_factor_backupable_to_users.rb b/db/migrate/20150331183602_add_devise_two_factor_backupable_to_users.rb deleted file mode 100644 index 792b98c91f0..00000000000 --- a/db/migrate/20150331183602_add_devise_two_factor_backupable_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDeviseTwoFactorBackupableToUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :otp_backup_codes, :text - end -end diff --git a/db/migrate/20150406133311_add_invite_data_to_member.rb b/db/migrate/20150406133311_add_invite_data_to_member.rb deleted file mode 100644 index eee991185ab..00000000000 --- a/db/migrate/20150406133311_add_invite_data_to_member.rb +++ /dev/null @@ -1,24 +0,0 @@ -# rubocop:disable all -class AddInviteDataToMember < ActiveRecord::Migration[4.2] - def up - add_column :members, :created_by_id, :integer - add_column :members, :invite_email, :string - add_column :members, :invite_token, :string - add_column :members, :invite_accepted_at, :datetime - - change_column :members, :user_id, :integer, null: true - - add_index :members, :invite_token, unique: true - end - - def down - remove_index :members, :invite_token - - change_column :members, :user_id, :integer, null: false - - remove_column :members, :invite_accepted_at - remove_column :members, :invite_token - remove_column :members, :invite_email - remove_column :members, :created_by_id - end -end diff --git a/db/migrate/20150411000035_fix_identities.rb b/db/migrate/20150411000035_fix_identities.rb deleted file mode 100644 index a449fc51ecc..00000000000 --- a/db/migrate/20150411000035_fix_identities.rb +++ /dev/null @@ -1,45 +0,0 @@ -class FixIdentities < ActiveRecord::Migration[4.2] - def up - # Up until now, legacy 'ldap' references in the database were charitably - # interpreted to point to the first LDAP server specified in the GitLab - # configuration. So if the database said 'provider: ldap' but the first - # LDAP server was called 'ldapmain', then we would try to interpret - # 'provider: ldap' as if it said 'provider: ldapmain'. This migration (and - # accompanying changes in the GitLab LDAP code) get rid of this complicated - # behavior. Any database references to 'provider: ldap' get rewritten to - # whatever the code would have interpreted it as, i.e. as a reference to - # the first LDAP server specified in gitlab.yml / gitlab.rb. - new_provider = if Gitlab.config.ldap.enabled - first_ldap_server = Gitlab.config.ldap.servers.values.first - first_ldap_server['provider_name'] - else - 'ldapmain' - end - - # Delete duplicate identities - # We use a sort of self-join to find rows in identities which match on - # user_id but where one has provider 'ldap'. We delete the duplicate row - # with provider 'ldap'. - delete_statement = '' - case adapter_name.downcase - when /^mysql/ - delete_statement << 'DELETE FROM id1 USING identities AS id1, identities AS id2' - when 'postgresql' - delete_statement << 'DELETE FROM identities AS id1 USING identities AS id2' - else - raise "Unknown DB adapter: #{adapter_name}" - end - delete_statement << " WHERE id1.user_id = id2.user_id AND id1.provider = 'ldap' AND id2.provider = '#{new_provider}'" - execute delete_statement - - # Update legacy identities - execute "UPDATE identities SET provider = '#{new_provider}' WHERE provider = 'ldap'" - - if table_exists?('ldap_group_links') - execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL OR provider = 'ldap'" - end - end - - def down - end -end diff --git a/db/migrate/20150411180045_rename_buildbox_service.rb b/db/migrate/20150411180045_rename_buildbox_service.rb deleted file mode 100644 index ac4ccdfb723..00000000000 --- a/db/migrate/20150411180045_rename_buildbox_service.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RenameBuildboxService < ActiveRecord::Migration[4.2] - def up - execute "UPDATE services SET type = 'BuildkiteService' WHERE type = 'BuildboxService';" - end - - def down - execute "UPDATE services SET type = 'BuildboxService' WHERE type = 'BuildkiteService';" - end -end diff --git a/db/migrate/20150413192223_add_public_email_to_users.rb b/db/migrate/20150413192223_add_public_email_to_users.rb deleted file mode 100644 index 991f0c668c3..00000000000 --- a/db/migrate/20150413192223_add_public_email_to_users.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddPublicEmailToUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :public_email, :string, default: "", null: false - end -end diff --git a/db/migrate/20150417121913_create_project_import_data.rb b/db/migrate/20150417121913_create_project_import_data.rb deleted file mode 100644 index 383f64fd2c6..00000000000 --- a/db/migrate/20150417121913_create_project_import_data.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateProjectImportData < ActiveRecord::Migration[4.2] - def change - create_table :project_import_data do |t| - t.references :project - t.text :data - end - end -end diff --git a/db/migrate/20150417122318_remove_import_data_from_project.rb b/db/migrate/20150417122318_remove_import_data_from_project.rb deleted file mode 100644 index c9a225a9d17..00000000000 --- a/db/migrate/20150417122318_remove_import_data_from_project.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable all -class RemoveImportDataFromProject < ActiveRecord::Migration[4.2] - def up - remove_column :projects, :import_data - end - - def down - add_column :projects, :import_data, :text - end -end diff --git a/db/migrate/20150421120000_remove_periods_at_ends_of_usernames.rb b/db/migrate/20150421120000_remove_periods_at_ends_of_usernames.rb deleted file mode 100644 index d2e7656c9d4..00000000000 --- a/db/migrate/20150421120000_remove_periods_at_ends_of_usernames.rb +++ /dev/null @@ -1,89 +0,0 @@ -# rubocop:disable all -class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration[4.2] - include Gitlab::ShellAdapter - - class Namespace < ActiveRecord::Base - class << self - def find_by_path_or_name(path) - find_by("lower(path) = :path OR lower(name) = :path", path: path.downcase) - end - - def clean_path(path) - path = path.dup - # Get the email username by removing everything after an `@` sign. - path.gsub!(/@.*\z/, "") - # Usernames can't end in .git, so remove it. - path.gsub!(/\.git\z/, "") - # Remove dashes at the start of the username. - path.gsub!(/\A-+/, "") - # Remove periods at the end of the username. - path.gsub!(/\.+\z/, "") - # Remove everything that's not in the list of allowed characters. - path.gsub!(/[^a-zA-Z0-9_\-\.]/, "") - - # Users with the great usernames of "." or ".." would end up with a blank username. - # Work around that by setting their username to "blank", followed by a counter. - path = "blank" if path.blank? - - counter = 0 - base = path - while Namespace.find_by_path_or_name(path) - counter += 1 - path = "#{base}#{counter}" - end - - path - end - end - end - - def up - changed_paths = {} - - select_all("SELECT id, username FROM users WHERE username LIKE '%.'").each do |user| - username_was = user["username"] - username = Namespace.clean_path(username_was) - changed_paths[username_was] = username - - username = quote_string(username) - execute "UPDATE users SET username = '#{username}' WHERE id = #{user["id"]}" - execute "UPDATE namespaces SET path = '#{username}', name = '#{username}' WHERE type IS NULL AND owner_id = #{user["id"]}" - end - - select_all("SELECT id, path FROM namespaces WHERE type = 'Group' AND path LIKE '%.'").each do |group| - path_was = group["path"] - path = Namespace.clean_path(path_was) - changed_paths[path_was] = path - - path = quote_string(path) - execute "UPDATE namespaces SET path = '#{path}' WHERE id = #{group["id"]}" - end - - changed_paths.each do |path_was, path| - # Don't attempt to move if original path only contains periods. - next if path_was =~ /\A\.+\z/ - - if gitlab_shell.mv_namespace(path_was, path) - # If repositories moved successfully we need to remove old satellites - # and send update instructions to users. - # However we cannot allow rollback since we moved namespace dir - # So we basically we mute exceptions in next actions - begin - gitlab_shell.rm_satellites(path_was) - # We cannot send update instructions since models and mailers - # can't safely be used from migrations as they may be written for - # later versions of the database. - # send_update_instructions - rescue - # Returning false does not rollback after_* transaction but gives - # us information about failing some of tasks - false - end - else - # if we cannot move namespace directory we should rollback - # db changes in order to prevent out of sync between db and fs - raise Exception.new('namespace directory cannot be moved') - end - end - end -end diff --git a/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb b/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb deleted file mode 100644 index e0f35da422a..00000000000 --- a/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddDefaultProjectVisibililtyToApplicationSettings < ActiveRecord::Migration[4.2] - def up - add_column :application_settings, :default_project_visibility, :integer - visibility = Settings.gitlab.default_projects_features['visibility_level'] - execute("update application_settings set default_project_visibility = #{visibility}") - end - - def down - remove_column :application_settings, :default_project_visibility - end -end diff --git a/db/migrate/20150425164646_gitlab_change_collation_for_tag_names.acts_as_taggable_on_engine.rb b/db/migrate/20150425164646_gitlab_change_collation_for_tag_names.acts_as_taggable_on_engine.rb deleted file mode 100644 index 5b2e692eb17..00000000000 --- a/db/migrate/20150425164646_gitlab_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,10 +0,0 @@ -# This migration is a duplicate of 20150425164651_change_collation_for_tag_names.acts_as_taggable_on_engine.rb -# It shold be applied before the index additions to ensure that `name` is case sensitive. - -class GitlabChangeCollationForTagNames < ActiveRecord::Migration[4.2] - def up - if ActsAsTaggableOn::Utils.using_mysql? - execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") - end - end -end diff --git a/db/migrate/20150425164647_remove_duplicate_tags.rb b/db/migrate/20150425164647_remove_duplicate_tags.rb deleted file mode 100644 index 5165eb65695..00000000000 --- a/db/migrate/20150425164647_remove_duplicate_tags.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable all -class RemoveDuplicateTags < ActiveRecord::Migration[4.2] - def up - select_all("SELECT name, COUNT(id) as cnt FROM tags GROUP BY name HAVING COUNT(id) > 1").each do |tag| - tag_name = quote_string(tag["name"]) - duplicate_ids = select_all("SELECT id FROM tags WHERE name = '#{tag_name}'").map{|tag| tag["id"]} - origin_tag_id = duplicate_ids.first - duplicate_ids.delete origin_tag_id - - execute("UPDATE taggings SET tag_id = #{origin_tag_id} WHERE tag_id IN(#{duplicate_ids.join(",")})") - execute("DELETE FROM tags WHERE id IN(#{duplicate_ids.join(",")})") - end - end - - def down - - end -end diff --git a/db/migrate/20150425164648_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/db/migrate/20150425164648_add_missing_unique_indices.acts_as_taggable_on_engine.rb deleted file mode 100644 index d1951f640bb..00000000000 --- a/db/migrate/20150425164648_add_missing_unique_indices.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,28 +0,0 @@ -# rubocop:disable all -# This migration comes from acts_as_taggable_on_engine (originally 2) -class AddMissingUniqueIndices < ActiveRecord::Migration[4.2] - def self.up - add_index :tags, :name, unique: true - - # pre-GitLab v6.7.0 may not have these indices since there were no - # migrations for them - if index_exists?(:taggings, :tag_id) - remove_index :taggings, :tag_id - end - - if index_exists?(:taggings, [:taggable_id, :taggable_type, :context]) - remove_index :taggings, [:taggable_id, :taggable_type, :context] - end - add_index :taggings, - [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type], - unique: true, name: 'taggings_idx' - end - - def self.down - remove_index :tags, :name - - remove_index :taggings, name: 'taggings_idx' - add_index :taggings, :tag_id - add_index :taggings, [:taggable_id, :taggable_type, :context] - end -end diff --git a/db/migrate/20150425164649_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/db/migrate/20150425164649_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb deleted file mode 100644 index b9af394f09b..00000000000 --- a/db/migrate/20150425164649_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,16 +0,0 @@ -# rubocop:disable all -# This migration comes from acts_as_taggable_on_engine (originally 3) -class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2] - def self.up - add_column :tags, :taggings_count, :integer, default: 0 - - ActsAsTaggableOn::Tag.reset_column_information - ActsAsTaggableOn::Tag.find_each do |tag| - ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings) - end - end - - def self.down - remove_column :tags, :taggings_count - end -end diff --git a/db/migrate/20150425164650_add_missing_taggable_index.acts_as_taggable_on_engine.rb b/db/migrate/20150425164650_add_missing_taggable_index.acts_as_taggable_on_engine.rb deleted file mode 100644 index f28737615d7..00000000000 --- a/db/migrate/20150425164650_add_missing_taggable_index.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,10 +0,0 @@ -# This migration comes from acts_as_taggable_on_engine (originally 4) -class AddMissingTaggableIndex < ActiveRecord::Migration[4.2] - def self.up - add_index :taggings, [:taggable_id, :taggable_type, :context] - end - - def self.down - remove_index :taggings, [:taggable_id, :taggable_type, :context] - end -end diff --git a/db/migrate/20150425164651_change_collation_for_tag_names.acts_as_taggable_on_engine.rb b/db/migrate/20150425164651_change_collation_for_tag_names.acts_as_taggable_on_engine.rb deleted file mode 100644 index 4c144a8693f..00000000000 --- a/db/migrate/20150425164651_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,10 +0,0 @@ -# This migration comes from acts_as_taggable_on_engine (originally 5) -# This migration is added to circumvent issue #623 and have special characters -# work properly -class ChangeCollationForTagNames < ActiveRecord::Migration[4.2] - def up - if ActsAsTaggableOn::Utils.using_mysql? - execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") - end - end -end diff --git a/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb b/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb deleted file mode 100644 index a3a86d26767..00000000000 --- a/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddDefaultSnippetVisibilityToAppSettings < ActiveRecord::Migration[4.2] - def up - add_column :application_settings, :default_snippet_visibility, :integer - visibility = Settings.gitlab.default_projects_features['visibility_level'] - execute("update application_settings set default_snippet_visibility = #{visibility}") - end - - def down - remove_column :application_settings, :default_snippet_visibility - end -end diff --git a/db/migrate/20150429002313_remove_abandoned_group_members_records.rb b/db/migrate/20150429002313_remove_abandoned_group_members_records.rb deleted file mode 100644 index 370b807dd50..00000000000 --- a/db/migrate/20150429002313_remove_abandoned_group_members_records.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RemoveAbandonedGroupMembersRecords < ActiveRecord::Migration[4.2] - def up - execute("DELETE FROM members WHERE type = 'GroupMember' AND source_id NOT IN(\ - SELECT id FROM namespaces WHERE type='Group')") - end - - def down - end -end diff --git a/db/migrate/20150502064022_add_restricted_signup_domains_to_application_settings.rb b/db/migrate/20150502064022_add_restricted_signup_domains_to_application_settings.rb deleted file mode 100644 index df777263ecb..00000000000 --- a/db/migrate/20150502064022_add_restricted_signup_domains_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRestrictedSignupDomainsToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :restricted_signup_domains, :text - end -end diff --git a/db/migrate/20150509180749_convert_legacy_reference_notes.rb b/db/migrate/20150509180749_convert_legacy_reference_notes.rb deleted file mode 100644 index 84d4eb9e51f..00000000000 --- a/db/migrate/20150509180749_convert_legacy_reference_notes.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Convert legacy Markdown-emphasized notes to the current, non-emphasized format -# -# _mentioned in 54f7727c850972f0401c1312a7c4a6a380de5666_ -# -# becomes -# -# mentioned in 54f7727c850972f0401c1312a7c4a6a380de5666 -class ConvertLegacyReferenceNotes < ActiveRecord::Migration[4.2] - def up - quoted_column_name = ActiveRecord::Base.connection.quote_column_name('system') - execute %Q{UPDATE notes SET note = trim(both '_' from note) WHERE #{quoted_column_name} = true AND note LIKE '\_%\_'} - end - - def down - # noop - end -end diff --git a/db/migrate/20150516060434_add_note_events_to_web_hooks.rb b/db/migrate/20150516060434_add_note_events_to_web_hooks.rb deleted file mode 100644 index ddf26240b8b..00000000000 --- a/db/migrate/20150516060434_add_note_events_to_web_hooks.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable all -class AddNoteEventsToWebHooks < ActiveRecord::Migration[4.2] - def up - add_column :web_hooks, :note_events, :boolean, default: false, null: false - end - - def down - remove_column :web_hooks, :note_events, :boolean - end -end diff --git a/db/migrate/20150529111607_add_user_oauth_applications_to_application_settings.rb b/db/migrate/20150529111607_add_user_oauth_applications_to_application_settings.rb deleted file mode 100644 index 507e905acd6..00000000000 --- a/db/migrate/20150529111607_add_user_oauth_applications_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUserOauthApplicationsToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :user_oauth_applications, :bool, default: true - end -end diff --git a/db/migrate/20150529150354_add_after_sign_out_path_for_application_settings.rb b/db/migrate/20150529150354_add_after_sign_out_path_for_application_settings.rb deleted file mode 100644 index f43f20def5b..00000000000 --- a/db/migrate/20150529150354_add_after_sign_out_path_for_application_settings.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddAfterSignOutPathForApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :after_sign_out_path, :string - end -end
\ No newline at end of file diff --git a/db/migrate/20150609141121_add_session_expire_delay_for_application_settings.rb b/db/migrate/20150609141121_add_session_expire_delay_for_application_settings.rb deleted file mode 100644 index 93959a9010f..00000000000 --- a/db/migrate/20150609141121_add_session_expire_delay_for_application_settings.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddSessionExpireDelayForApplicationSettings < ActiveRecord::Migration[4.2] - def change - unless column_exists?(:application_settings, :session_expire_delay) - add_column :application_settings, :session_expire_delay, :integer, default: 10080, null: false - end - end -end diff --git a/db/migrate/20150610065936_add_dashboard_to_users.rb b/db/migrate/20150610065936_add_dashboard_to_users.rb deleted file mode 100644 index a0bf5f31f00..00000000000 --- a/db/migrate/20150610065936_add_dashboard_to_users.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable all -class AddDashboardToUsers < ActiveRecord::Migration[4.2] - def up - add_column :users, :dashboard, :integer, default: 0 - end - - def down - remove_column :users, :dashboard - end -end diff --git a/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb b/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb deleted file mode 100644 index 4a085ff06f3..00000000000 --- a/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddDefaultOtpRequiredForLoginValue < ActiveRecord::Migration[4.2] - def up - execute %q{UPDATE users SET otp_required_for_login = FALSE WHERE otp_required_for_login IS NULL} - - change_column :users, :otp_required_for_login, :boolean, default: false, null: false - end - - def down - change_column :users, :otp_required_for_login, :boolean, null: true - end -end diff --git a/db/migrate/20150713160110_add_project_view_to_users.rb b/db/migrate/20150713160110_add_project_view_to_users.rb deleted file mode 100644 index fea63576187..00000000000 --- a/db/migrate/20150713160110_add_project_view_to_users.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddProjectViewToUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :project_view, :integer, default: 0 - end -end diff --git a/db/migrate/20150717130904_add_commits_count_to_project.rb b/db/migrate/20150717130904_add_commits_count_to_project.rb deleted file mode 100644 index df6c88f2961..00000000000 --- a/db/migrate/20150717130904_add_commits_count_to_project.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddCommitsCountToProject < ActiveRecord::Migration[4.2] - def change - add_column :projects, :commit_count, :integer, default: 0 - end -end diff --git a/db/migrate/20150730122406_add_updated_by_to_issuables_and_notes.rb b/db/migrate/20150730122406_add_updated_by_to_issuables_and_notes.rb deleted file mode 100644 index fab126c3d04..00000000000 --- a/db/migrate/20150730122406_add_updated_by_to_issuables_and_notes.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddUpdatedByToIssuablesAndNotes < ActiveRecord::Migration[4.2] - def change - add_column :notes, :updated_by_id, :integer - add_column :issues, :updated_by_id, :integer - add_column :merge_requests, :updated_by_id, :integer - end -end diff --git a/db/migrate/20150806104937_create_abuse_reports.rb b/db/migrate/20150806104937_create_abuse_reports.rb deleted file mode 100644 index be4fe8d1cfd..00000000000 --- a/db/migrate/20150806104937_create_abuse_reports.rb +++ /dev/null @@ -1,14 +0,0 @@ -# rubocop:disable all -class CreateAbuseReports < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :abuse_reports do |t| - t.integer :reporter_id - t.integer :user_id - t.text :message - - t.timestamps null: true - end - end -end diff --git a/db/migrate/20150812080800_add_settings_import_sources.rb b/db/migrate/20150812080800_add_settings_import_sources.rb deleted file mode 100644 index 59db31c868a..00000000000 --- a/db/migrate/20150812080800_add_settings_import_sources.rb +++ /dev/null @@ -1,12 +0,0 @@ -# rubocop:disable all -require 'yaml' - -class AddSettingsImportSources < ActiveRecord::Migration[4.2] - def change - unless column_exists?(:application_settings, :import_sources) - add_column :application_settings, :import_sources, :text - import_sources = YAML::dump(Settings.gitlab['import_sources']) - execute("update application_settings set import_sources = '#{import_sources}'") - end - end -end diff --git a/db/migrate/20150814065925_remove_oauth_tokens_from_users.rb b/db/migrate/20150814065925_remove_oauth_tokens_from_users.rb deleted file mode 100644 index f0080ee0b46..00000000000 --- a/db/migrate/20150814065925_remove_oauth_tokens_from_users.rb +++ /dev/null @@ -1,9 +0,0 @@ -# rubocop:disable all -class RemoveOauthTokensFromUsers < ActiveRecord::Migration[4.2] - def change - remove_column :users, :github_access_token, :string - remove_column :users, :gitlab_access_token, :string - remove_column :users, :bitbucket_access_token, :string - remove_column :users, :bitbucket_access_token_secret, :string - end -end diff --git a/db/migrate/20150817163600_deduplicate_user_identities.rb b/db/migrate/20150817163600_deduplicate_user_identities.rb deleted file mode 100644 index 973a87e07ea..00000000000 --- a/db/migrate/20150817163600_deduplicate_user_identities.rb +++ /dev/null @@ -1,15 +0,0 @@ -# rubocop:disable all -class DeduplicateUserIdentities < ActiveRecord::Migration[4.2] - def change - execute 'DROP TABLE IF EXISTS tt_migration_DeduplicateUserIdentities;' - execute 'CREATE TABLE tt_migration_DeduplicateUserIdentities AS SELECT id,provider,user_id FROM identities;' - execute 'DELETE FROM identities WHERE id NOT IN ( SELECT MIN(id) FROM tt_migration_DeduplicateUserIdentities GROUP BY user_id, provider);' - execute 'DROP TABLE IF EXISTS tt_migration_DeduplicateUserIdentities;' - end - - def down - # This is an irreversible migration; - # If someone is trying to rollback for other reasons, we should not throw an Exception. - # raise ActiveRecord::IrreversibleMigration - end -end diff --git a/db/migrate/20150818213832_add_sent_notifications.rb b/db/migrate/20150818213832_add_sent_notifications.rb deleted file mode 100644 index 45e95a843e1..00000000000 --- a/db/migrate/20150818213832_add_sent_notifications.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddSentNotifications < ActiveRecord::Migration[4.2] - def change - create_table :sent_notifications do |t| - t.references :project - t.references :noteable, polymorphic: true - t.references :recipient - t.string :commit_id - t.string :reply_key, null: false - end - - add_index :sent_notifications, :reply_key, unique: true - end -end diff --git a/db/migrate/20150824002011_add_enable_ssl_verification.rb b/db/migrate/20150824002011_add_enable_ssl_verification.rb deleted file mode 100644 index 2d877914f39..00000000000 --- a/db/migrate/20150824002011_add_enable_ssl_verification.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddEnableSslVerification < ActiveRecord::Migration[4.2] - def change - add_column :web_hooks, :enable_ssl_verification, :boolean, default: false - end -end diff --git a/db/migrate/20150826001931_add_ci_tables.rb b/db/migrate/20150826001931_add_ci_tables.rb deleted file mode 100644 index aa2af44a15b..00000000000 --- a/db/migrate/20150826001931_add_ci_tables.rb +++ /dev/null @@ -1,191 +0,0 @@ -# rubocop:disable all -class AddCiTables < ActiveRecord::Migration[4.2] - def change - create_table "ci_application_settings", force: true 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: true do |t| - t.integer "project_id" - t.string "status" - t.datetime "finished_at" - t.text "trace" - t.datetime "created_at" - t.datetime "updated_at" - t.datetime "started_at" - t.integer "runner_id" - 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" - t.integer "trigger_request_id" - end - - add_index "ci_builds", ["commit_id"], name: "index_ci_builds_on_commit_id", using: :btree - add_index "ci_builds", ["project_id", "commit_id"], name: "index_ci_builds_on_project_id_and_commit_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 - - create_table "ci_commits", force: true do |t| - t.integer "project_id" - 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" - end - - add_index "ci_commits", ["project_id", "committed_at"], name: "index_ci_commits_on_project_id_and_committed_at", using: :btree - add_index "ci_commits", ["project_id", "sha"], name: "index_ci_commits_on_project_id_and_sha", using: :btree - add_index "ci_commits", ["project_id"], name: "index_ci_commits_on_project_id", using: :btree - add_index "ci_commits", ["sha"], name: "index_ci_commits_on_sha", using: :btree - - create_table "ci_events", force: true 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 - - add_index "ci_events", ["created_at"], name: "index_ci_events_on_created_at", using: :btree - add_index "ci_events", ["is_admin"], name: "index_ci_events_on_is_admin", using: :btree - add_index "ci_events", ["project_id"], name: "index_ci_events_on_project_id", using: :btree - - create_table "ci_jobs", force: true 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 - - add_index "ci_jobs", ["deleted_at"], name: "index_ci_jobs_on_deleted_at", using: :btree - add_index "ci_jobs", ["project_id"], name: "index_ci_jobs_on_project_id", using: :btree - - create_table "ci_projects", force: true do |t| - t.string "name", null: false - 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 - - create_table "ci_runner_projects", force: true do |t| - t.integer "runner_id", null: false - t.integer "project_id", null: false - t.datetime "created_at" - t.datetime "updated_at" - end - - 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: true do |t| - t.string "token" - t.datetime "created_at" - t.datetime "updated_at" - t.string "description" - t.datetime "contacted_at" - t.boolean "active", default: true, null: false - t.boolean "is_shared", default: false - t.string "name" - t.string "version" - t.string "revision" - t.string "platform" - t.string "architecture" - end - - create_table "ci_services", force: true do |t| - t.string "type" - t.string "title" - t.integer "project_id", null: false - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "active", default: false, null: false - t.text "properties" - end - - add_index "ci_services", ["project_id"], name: "index_ci_services_on_project_id", using: :btree - - create_table "ci_sessions", force: true do |t| - t.string "session_id", null: false - t.text "data" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "ci_sessions", ["session_id"], name: "index_ci_sessions_on_session_id", using: :btree - add_index "ci_sessions", ["updated_at"], name: "index_ci_sessions_on_updated_at", using: :btree - - create_table "ci_trigger_requests", force: true do |t| - t.integer "trigger_id", null: false - t.text "variables" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "commit_id" - end - - create_table "ci_triggers", force: true do |t| - t.string "token" - t.integer "project_id", null: false - t.datetime "deleted_at" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "ci_triggers", ["deleted_at"], name: "index_ci_triggers_on_deleted_at", using: :btree - - create_table "ci_variables", force: true do |t| - t.integer "project_id", null: false - t.string "key" - t.text "value" - t.text "encrypted_value" - t.string "encrypted_value_salt" - t.string "encrypted_value_iv" - end - - add_index "ci_variables", ["project_id"], name: "index_ci_variables_on_project_id", using: :btree - - create_table "ci_web_hooks", force: true do |t| - t.string "url", null: false - t.integer "project_id", null: false - t.datetime "created_at" - t.datetime "updated_at" - end - end -end diff --git a/db/migrate/20150827121444_add_fast_forward_option_to_project.rb b/db/migrate/20150827121444_add_fast_forward_option_to_project.rb deleted file mode 100644 index bf7db2fb12b..00000000000 --- a/db/migrate/20150827121444_add_fast_forward_option_to_project.rb +++ /dev/null @@ -1,23 +0,0 @@ -# rubocop:disable all -class AddFastForwardOptionToProject < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - # We put condition here because of a mistake we made a couple of years ago - # see https://gitlab.com/gitlab-org/gitlab-ce/issues/39382#note_45716103 - unless column_exists?(:projects, :merge_requests_ff_only_enabled) - add_column_with_default(:projects, :merge_requests_ff_only_enabled, :boolean, default: false) - end - end - - def down - if column_exists?(:projects, :merge_requests_ff_only_enabled) - remove_column(:projects, :merge_requests_ff_only_enabled) - end - end -end diff --git a/db/migrate/20150902001023_add_template_to_label.rb b/db/migrate/20150902001023_add_template_to_label.rb deleted file mode 100644 index 10769f29baa..00000000000 --- a/db/migrate/20150902001023_add_template_to_label.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddTemplateToLabel < ActiveRecord::Migration[4.2] - def change - add_column :labels, :template, :boolean, default: false - end -end
\ No newline at end of file diff --git a/db/migrate/20150914215247_add_ci_tags.rb b/db/migrate/20150914215247_add_ci_tags.rb deleted file mode 100644 index 9afa4540540..00000000000 --- a/db/migrate/20150914215247_add_ci_tags.rb +++ /dev/null @@ -1,24 +0,0 @@ -# rubocop:disable all -class AddCiTags < ActiveRecord::Migration[4.2] - def change - create_table "ci_taggings", force: true 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", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "ci_taggings_idx", unique: true, using: :btree - 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: true do |t| - t.string "name" - t.integer "taggings_count", default: 0 - end - - add_index "ci_tags", ["name"], name: "index_ci_tags_on_name", unique: true, using: :btree - end -end diff --git a/db/migrate/20150915001905_enable_ssl_verification_by_default.rb b/db/migrate/20150915001905_enable_ssl_verification_by_default.rb deleted file mode 100644 index ddd07179753..00000000000 --- a/db/migrate/20150915001905_enable_ssl_verification_by_default.rb +++ /dev/null @@ -1,5 +0,0 @@ -class EnableSslVerificationByDefault < ActiveRecord::Migration[4.2] - def change - change_column :web_hooks, :enable_ssl_verification, :boolean, default: true - end -end diff --git a/db/migrate/20150916000405_enable_ssl_verification_for_web_hooks.rb b/db/migrate/20150916000405_enable_ssl_verification_for_web_hooks.rb deleted file mode 100644 index 49081c9d749..00000000000 --- a/db/migrate/20150916000405_enable_ssl_verification_for_web_hooks.rb +++ /dev/null @@ -1,8 +0,0 @@ -class EnableSslVerificationForWebHooks < ActiveRecord::Migration[4.2] - def up - execute("UPDATE web_hooks SET enable_ssl_verification = true") - end - - def down - end -end diff --git a/db/migrate/20150916114643_add_help_page_text_to_application_settings.rb b/db/migrate/20150916114643_add_help_page_text_to_application_settings.rb deleted file mode 100644 index 52867632880..00000000000 --- a/db/migrate/20150916114643_add_help_page_text_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddHelpPageTextToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :help_page_text, :text - end -end diff --git a/db/migrate/20150916145038_add_index_for_committed_at_and_id.rb b/db/migrate/20150916145038_add_index_for_committed_at_and_id.rb deleted file mode 100644 index bf78aacd9f4..00000000000 --- a/db/migrate/20150916145038_add_index_for_committed_at_and_id.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddIndexForCommittedAtAndId < ActiveRecord::Migration[4.2] - def change - add_index :ci_commits, [:project_id, :committed_at, :id] - end -end diff --git a/db/migrate/20150918084513_add_ci_enabled_to_application_settings.rb b/db/migrate/20150918084513_add_ci_enabled_to_application_settings.rb deleted file mode 100644 index 153c1a798c3..00000000000 --- a/db/migrate/20150918084513_add_ci_enabled_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCiEnabledToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :ci_enabled, :boolean, null: false, default: true - end -end diff --git a/db/migrate/20150918161719_remove_invalid_milestones_from_merge_requests.rb b/db/migrate/20150918161719_remove_invalid_milestones_from_merge_requests.rb deleted file mode 100644 index 52651e16324..00000000000 --- a/db/migrate/20150918161719_remove_invalid_milestones_from_merge_requests.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveInvalidMilestonesFromMergeRequests < ActiveRecord::Migration[4.2] - def up - execute("UPDATE merge_requests SET milestone_id = NULL where milestone_id NOT IN (SELECT id FROM milestones)") - end -end diff --git a/db/migrate/20150920010715_add_consumed_timestep_to_users.rb b/db/migrate/20150920010715_add_consumed_timestep_to_users.rb deleted file mode 100644 index c69944b1e94..00000000000 --- a/db/migrate/20150920010715_add_consumed_timestep_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddConsumedTimestepToUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :consumed_timestep, :integer - end -end diff --git a/db/migrate/20150920161119_add_line_code_to_sent_notification.rb b/db/migrate/20150920161119_add_line_code_to_sent_notification.rb deleted file mode 100644 index 671476f0b07..00000000000 --- a/db/migrate/20150920161119_add_line_code_to_sent_notification.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLineCodeToSentNotification < ActiveRecord::Migration[4.2] - def change - add_column :sent_notifications, :line_code, :string - end -end diff --git a/db/migrate/20150924125150_add_project_id_to_ci_commit.rb b/db/migrate/20150924125150_add_project_id_to_ci_commit.rb deleted file mode 100644 index c9f16b0f3f9..00000000000 --- a/db/migrate/20150924125150_add_project_id_to_ci_commit.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddProjectIdToCiCommit < ActiveRecord::Migration[4.2] - def up - add_column :ci_commits, :gl_project_id, :integer - end -end diff --git a/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb b/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb deleted file mode 100644 index ff31e70874f..00000000000 --- a/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb +++ /dev/null @@ -1,6 +0,0 @@ -class MigrateProjectIdForCiCommits < ActiveRecord::Migration[4.2] - def up - subquery = 'SELECT gitlab_id FROM ci_projects WHERE ci_projects.id = ci_commits.project_id' - execute("UPDATE ci_commits SET gl_project_id=(#{subquery}) WHERE gl_project_id IS NULL") - end -end diff --git a/db/migrate/20150930001110_merge_request_error_field.rb b/db/migrate/20150930001110_merge_request_error_field.rb deleted file mode 100644 index 30f012b0a92..00000000000 --- a/db/migrate/20150930001110_merge_request_error_field.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MergeRequestErrorField < ActiveRecord::Migration[4.2] - def up - add_column :merge_requests, :merge_error, :string - end -end diff --git a/db/migrate/20150930095736_add_null_to_name_for_ci_projects.rb b/db/migrate/20150930095736_add_null_to_name_for_ci_projects.rb deleted file mode 100644 index 181f9f059ac..00000000000 --- a/db/migrate/20150930095736_add_null_to_name_for_ci_projects.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddNullToNameForCiProjects < ActiveRecord::Migration[4.2] - def up - change_column_null :ci_projects, :name, true - end - - def down - change_column_null :ci_projects, :name, false - end -end diff --git a/db/migrate/20150930110012_add_group_share_lock.rb b/db/migrate/20150930110012_add_group_share_lock.rb deleted file mode 100644 index 62755765457..00000000000 --- a/db/migrate/20150930110012_add_group_share_lock.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddGroupShareLock < ActiveRecord::Migration[4.2] - def change - add_column :namespaces, :share_with_group_lock, :boolean, default: false - end -end diff --git a/db/migrate/20151002112914_add_stage_idx_to_builds.rb b/db/migrate/20151002112914_add_stage_idx_to_builds.rb deleted file mode 100644 index f73df9dc284..00000000000 --- a/db/migrate/20151002112914_add_stage_idx_to_builds.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddStageIdxToBuilds < ActiveRecord::Migration[4.2] - def change - add_column :ci_builds, :stage_idx, :integer - end -end diff --git a/db/migrate/20151002121400_add_index_for_builds.rb b/db/migrate/20151002121400_add_index_for_builds.rb deleted file mode 100644 index 5e6f80a1d3d..00000000000 --- a/db/migrate/20151002121400_add_index_for_builds.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddIndexForBuilds < ActiveRecord::Migration[4.2] - def up - add_index :ci_builds, [:commit_id, :stage_idx, :created_at] - end -end diff --git a/db/migrate/20151002122929_add_ref_and_tag_to_builds.rb b/db/migrate/20151002122929_add_ref_and_tag_to_builds.rb deleted file mode 100644 index ea41921b6ee..00000000000 --- a/db/migrate/20151002122929_add_ref_and_tag_to_builds.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddRefAndTagToBuilds < ActiveRecord::Migration[4.2] - def change - add_column :ci_builds, :tag, :boolean - add_column :ci_builds, :ref, :string - end -end diff --git a/db/migrate/20151002122943_migrate_ref_and_tag_to_build.rb b/db/migrate/20151002122943_migrate_ref_and_tag_to_build.rb deleted file mode 100644 index b4038e6fa83..00000000000 --- a/db/migrate/20151002122943_migrate_ref_and_tag_to_build.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class MigrateRefAndTagToBuild < ActiveRecord::Migration[4.2] - def change - execute('UPDATE ci_builds SET ref=(SELECT ref FROM ci_commits WHERE ci_commits.id = ci_builds.commit_id) WHERE ref IS NULL') - execute('UPDATE ci_builds SET tag=(SELECT tag FROM ci_commits WHERE ci_commits.id = ci_builds.commit_id) WHERE tag IS NULL') - end -end diff --git a/db/migrate/20151005075649_add_user_id_to_build.rb b/db/migrate/20151005075649_add_user_id_to_build.rb deleted file mode 100644 index 45372bf7cba..00000000000 --- a/db/migrate/20151005075649_add_user_id_to_build.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUserIdToBuild < ActiveRecord::Migration[4.2] - def change - add_column :ci_builds, :user_id, :integer - end -end diff --git a/db/migrate/20151005150751_add_layout_option_for_users.rb b/db/migrate/20151005150751_add_layout_option_for_users.rb deleted file mode 100644 index 66cba21320a..00000000000 --- a/db/migrate/20151005150751_add_layout_option_for_users.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddLayoutOptionForUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :layout, :integer, default: 0 - end -end
\ No newline at end of file diff --git a/db/migrate/20151005162154_remove_ci_enabled_from_application_settings.rb b/db/migrate/20151005162154_remove_ci_enabled_from_application_settings.rb deleted file mode 100644 index a8e6e54062a..00000000000 --- a/db/migrate/20151005162154_remove_ci_enabled_from_application_settings.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class RemoveCiEnabledFromApplicationSettings < ActiveRecord::Migration[4.2] - def change - remove_column :application_settings, :ci_enabled, :boolean, null: false, default: true - end -end diff --git a/db/migrate/20151007120511_namespaces_projects_path_lower_indexes.rb b/db/migrate/20151007120511_namespaces_projects_path_lower_indexes.rb deleted file mode 100644 index d6c21bf8639..00000000000 --- a/db/migrate/20151007120511_namespaces_projects_path_lower_indexes.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable all -class NamespacesProjectsPathLowerIndexes < ActiveRecord::Migration[4.2] - disable_ddl_transaction! - - def up - return unless Gitlab::Database.postgresql? - - execute 'CREATE INDEX CONCURRENTLY index_on_namespaces_lower_path ON namespaces (LOWER(path));' - execute 'CREATE INDEX CONCURRENTLY index_on_projects_lower_path ON projects (LOWER(path));' - end - - def down - return unless Gitlab::Database.postgresql? - - remove_index :namespaces, name: :index_on_namespaces_lower_path - remove_index :projects, name: :index_on_projects_lower_path - end -end diff --git a/db/migrate/20151008110232_add_users_lower_username_email_indexes.rb b/db/migrate/20151008110232_add_users_lower_username_email_indexes.rb deleted file mode 100644 index 2ba1a6146e2..00000000000 --- a/db/migrate/20151008110232_add_users_lower_username_email_indexes.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable all -class AddUsersLowerUsernameEmailIndexes < ActiveRecord::Migration[4.2] - disable_ddl_transaction! - - def up - return unless Gitlab::Database.postgresql? - - execute 'CREATE INDEX CONCURRENTLY index_on_users_lower_username ON users (LOWER(username));' - execute 'CREATE INDEX CONCURRENTLY index_on_users_lower_email ON users (LOWER(email));' - end - - def down - return unless Gitlab::Database.postgresql? - - remove_index :users, :index_on_users_lower_username - remove_index :users, :index_on_users_lower_email - end -end diff --git a/db/migrate/20151008123042_add_type_and_description_to_builds.rb b/db/migrate/20151008123042_add_type_and_description_to_builds.rb deleted file mode 100644 index 309655cf195..00000000000 --- a/db/migrate/20151008123042_add_type_and_description_to_builds.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable all -class AddTypeAndDescriptionToBuilds < ActiveRecord::Migration[4.2] - def change - add_column :ci_builds, :type, :string - add_column :ci_builds, :target_url, :string - add_column :ci_builds, :description, :string - add_index :ci_builds, [:commit_id, :type, :ref] - add_index :ci_builds, [:commit_id, :type, :name, :ref] - end -end diff --git a/db/migrate/20151008130321_migrate_name_to_description_for_builds.rb b/db/migrate/20151008130321_migrate_name_to_description_for_builds.rb deleted file mode 100644 index f4445277a6f..00000000000 --- a/db/migrate/20151008130321_migrate_name_to_description_for_builds.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class MigrateNameToDescriptionForBuilds < ActiveRecord::Migration[4.2] - def change - execute("UPDATE ci_builds SET type='Ci::Build' WHERE type IS NULL") - end -end diff --git a/db/migrate/20151008143519_add_admin_notification_email_setting.rb b/db/migrate/20151008143519_add_admin_notification_email_setting.rb deleted file mode 100644 index 60e0986e5a8..00000000000 --- a/db/migrate/20151008143519_add_admin_notification_email_setting.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAdminNotificationEmailSetting < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :admin_notification_email, :string - end -end diff --git a/db/migrate/20151012173029_set_jira_service_api_url.rb b/db/migrate/20151012173029_set_jira_service_api_url.rb deleted file mode 100644 index 91cc6bbc783..00000000000 --- a/db/migrate/20151012173029_set_jira_service_api_url.rb +++ /dev/null @@ -1,51 +0,0 @@ -# rubocop:disable all -class SetJiraServiceApiUrl < ActiveRecord::Migration[4.2] - # This migration can be performed online without errors, but some Jira API calls may be missed - # when doing so because api_url is not yet available. - - def build_api_url_from_project_url(project_url, api_version) - # this is the exact logic previously used to build the Jira API URL from project_url - server = URI(project_url) - default_ports = [80, 443].include?(server.port) - server_url = "#{server.scheme}://#{server.host}" - server_url.concat(":#{server.port}") unless default_ports - "#{server_url}/rest/api/#{api_version}" - end - - def get_api_version_from_api_url(api_url) - match = /\/rest\/api\/(?<api_version>\w+)$/.match(api_url) - match && match['api_version'] - end - - def change - reversible do |dir| - select_all("SELECT id, properties FROM services WHERE services.type IN ('JiraService')").each do |jira_service| - id = jira_service["id"] - properties = JSON.parse(jira_service["properties"]) - properties_was = properties.clone - - dir.up do - # remove api_version and set api_url - if properties['api_version'].present? && properties['project_url'].present? - begin - properties['api_url'] ||= build_api_url_from_project_url(properties['project_url'], properties['api_version']) - rescue - # looks like project_url was not a valid URL. Do nothing. - end - end - properties.delete('api_version') if properties.include?('api_version') - end - - dir.down do - # remove api_url and set api_version (default to '2') - properties['api_version'] ||= get_api_version_from_api_url(properties['api_url']) || '2' - properties.delete('api_url') if properties.include?('api_url') - end - - if properties != properties_was - execute("UPDATE services SET properties = '#{quote_string(properties.to_json)}' WHERE id = #{id}") - end - end - end - end -end diff --git a/db/migrate/20151013092124_add_artifacts_file_to_builds.rb b/db/migrate/20151013092124_add_artifacts_file_to_builds.rb deleted file mode 100644 index 3936386a2c0..00000000000 --- a/db/migrate/20151013092124_add_artifacts_file_to_builds.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddArtifactsFileToBuilds < ActiveRecord::Migration[4.2] - def change - add_column :ci_builds, :artifacts_file, :text - end -end diff --git a/db/migrate/20151016131433_add_ci_projects_gl_project_id_index.rb b/db/migrate/20151016131433_add_ci_projects_gl_project_id_index.rb deleted file mode 100644 index a9290fef11a..00000000000 --- a/db/migrate/20151016131433_add_ci_projects_gl_project_id_index.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddCiProjectsGlProjectIdIndex < ActiveRecord::Migration[4.2] - def change - add_index :ci_commits, :gl_project_id - end -end diff --git a/db/migrate/20151016195451_add_ci_builds_and_projects_indexes.rb b/db/migrate/20151016195451_add_ci_builds_and_projects_indexes.rb deleted file mode 100644 index c8a79f25ae5..00000000000 --- a/db/migrate/20151016195451_add_ci_builds_and_projects_indexes.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable all -class AddCiBuildsAndProjectsIndexes < ActiveRecord::Migration[4.2] - def change - add_index :ci_projects, :gitlab_id - add_index :ci_projects, :shared_runners_enabled - - add_index :ci_builds, :type - add_index :ci_builds, :status - end -end diff --git a/db/migrate/20151016195706_add_notes_line_code_index.rb b/db/migrate/20151016195706_add_notes_line_code_index.rb deleted file mode 100644 index 0a3ad103009..00000000000 --- a/db/migrate/20151016195706_add_notes_line_code_index.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddNotesLineCodeIndex < ActiveRecord::Migration[4.2] - def change - add_index :notes, :line_code - end -end diff --git a/db/migrate/20151019111551_fix_build_tags.rb b/db/migrate/20151019111551_fix_build_tags.rb deleted file mode 100644 index 3c64388314d..00000000000 --- a/db/migrate/20151019111551_fix_build_tags.rb +++ /dev/null @@ -1,9 +0,0 @@ -class FixBuildTags < ActiveRecord::Migration[4.2] - def up - execute("UPDATE taggings SET taggable_type='CommitStatus' WHERE taggable_type='Ci::Build'") - end - - def down - execute("UPDATE taggings SET taggable_type='Ci::Build' WHERE taggable_type='CommitStatus'") - end -end diff --git a/db/migrate/20151019111703_fail_build_without_names.rb b/db/migrate/20151019111703_fail_build_without_names.rb deleted file mode 100644 index 2dc9ffa32b9..00000000000 --- a/db/migrate/20151019111703_fail_build_without_names.rb +++ /dev/null @@ -1,8 +0,0 @@ -class FailBuildWithoutNames < ActiveRecord::Migration[4.2] - def up - execute("UPDATE ci_builds SET status='failed' WHERE name IS NULL AND status='pending'") - end - - def down - end -end diff --git a/db/migrate/20151020145526_add_services_template_index.rb b/db/migrate/20151020145526_add_services_template_index.rb deleted file mode 100644 index 24c373855e2..00000000000 --- a/db/migrate/20151020145526_add_services_template_index.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddServicesTemplateIndex < ActiveRecord::Migration[4.2] - def change - add_index :services, :template - end -end diff --git a/db/migrate/20151020173516_ci_limits_to_mysql.rb b/db/migrate/20151020173516_ci_limits_to_mysql.rb deleted file mode 100644 index 573922b851b..00000000000 --- a/db/migrate/20151020173516_ci_limits_to_mysql.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CiLimitsToMysql < ActiveRecord::Migration[4.2] - def change - return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/ - - # CI - change_column :ci_builds, :trace, :text, limit: 1073741823 - change_column :ci_commits, :push_data, :text, limit: 16777215 - end -end diff --git a/db/migrate/20151020173906_add_ci_builds_index_for_status.rb b/db/migrate/20151020173906_add_ci_builds_index_for_status.rb deleted file mode 100644 index 231fc4f2a17..00000000000 --- a/db/migrate/20151020173906_add_ci_builds_index_for_status.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddCiBuildsIndexForStatus < ActiveRecord::Migration[4.2] - def change - add_index :ci_builds, [:commit_id, :status, :type] - end -end diff --git a/db/migrate/20151023112551_fail_build_with_empty_name.rb b/db/migrate/20151023112551_fail_build_with_empty_name.rb deleted file mode 100644 index 28f531463bc..00000000000 --- a/db/migrate/20151023112551_fail_build_with_empty_name.rb +++ /dev/null @@ -1,8 +0,0 @@ -class FailBuildWithEmptyName < ActiveRecord::Migration[4.2] - def up - execute("UPDATE ci_builds SET status='failed' WHERE (name IS NULL OR name='') AND status='pending'") - end - - def down - end -end diff --git a/db/migrate/20151023144219_remove_satellites.rb b/db/migrate/20151023144219_remove_satellites.rb deleted file mode 100644 index 2d1310b0208..00000000000 --- a/db/migrate/20151023144219_remove_satellites.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'fileutils' - -class RemoveSatellites < ActiveRecord::Migration[4.2] - def up - satellites = Gitlab.config['satellites'] - return if satellites.nil? - - satellites_path = satellites['path'] - return if satellites_path.nil? - - FileUtils.rm_rf(satellites_path) - end - - def down - # Do nothing - end -end diff --git a/db/migrate/20151026182941_add_project_path_index.rb b/db/migrate/20151026182941_add_project_path_index.rb deleted file mode 100644 index bf0444450cd..00000000000 --- a/db/migrate/20151026182941_add_project_path_index.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable all -class AddProjectPathIndex < ActiveRecord::Migration[4.2] - def up - add_index :projects, :path - end - - def down - remove_index :projects, :path - end -end diff --git a/db/migrate/20151028152939_add_merge_when_build_succeeds_to_merge_request.rb b/db/migrate/20151028152939_add_merge_when_build_succeeds_to_merge_request.rb deleted file mode 100644 index 5b11a430e30..00000000000 --- a/db/migrate/20151028152939_add_merge_when_build_succeeds_to_merge_request.rb +++ /dev/null @@ -1,8 +0,0 @@ -# rubocop:disable all -class AddMergeWhenBuildSucceedsToMergeRequest < ActiveRecord::Migration[4.2] - def change - add_column :merge_requests, :merge_params, :text - add_column :merge_requests, :merge_when_build_succeeds, :boolean, default: false, null: false - add_column :merge_requests, :merge_user_id, :integer - end -end diff --git a/db/migrate/20151103001141_add_public_to_group.rb b/db/migrate/20151103001141_add_public_to_group.rb deleted file mode 100644 index a5590bc1adc..00000000000 --- a/db/migrate/20151103001141_add_public_to_group.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddPublicToGroup < ActiveRecord::Migration[4.2] - def change - add_column :namespaces, :public, :boolean, default: false - end -end diff --git a/db/migrate/20151103133339_add_shared_runners_setting.rb b/db/migrate/20151103133339_add_shared_runners_setting.rb deleted file mode 100644 index 6fc845d1396..00000000000 --- a/db/migrate/20151103133339_add_shared_runners_setting.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddSharedRunnersSetting < ActiveRecord::Migration[4.2] - def up - add_column :application_settings, :shared_runners_enabled, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20151103134857_create_lfs_objects.rb b/db/migrate/20151103134857_create_lfs_objects.rb deleted file mode 100644 index 2ba77e431a1..00000000000 --- a/db/migrate/20151103134857_create_lfs_objects.rb +++ /dev/null @@ -1,13 +0,0 @@ -# rubocop:disable all -class CreateLfsObjects < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :lfs_objects do |t| - t.string :oid, null: false, unique: true - t.integer :size, null: false - - t.timestamps null: true - end - end -end diff --git a/db/migrate/20151103134958_create_lfs_objects_projects.rb b/db/migrate/20151103134958_create_lfs_objects_projects.rb deleted file mode 100644 index 6f8488463b0..00000000000 --- a/db/migrate/20151103134958_create_lfs_objects_projects.rb +++ /dev/null @@ -1,15 +0,0 @@ -# rubocop:disable all -class CreateLfsObjectsProjects < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :lfs_objects_projects do |t| - t.integer :lfs_object_id, null: false - t.integer :project_id, null: false - - t.timestamps null: true - end - - add_index :lfs_objects_projects, :project_id - end -end diff --git a/db/migrate/20151104105513_add_file_to_lfs_objects.rb b/db/migrate/20151104105513_add_file_to_lfs_objects.rb deleted file mode 100644 index 050b1e07503..00000000000 --- a/db/migrate/20151104105513_add_file_to_lfs_objects.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddFileToLfsObjects < ActiveRecord::Migration[4.2] - def change - add_column :lfs_objects, :file, :string - end -end diff --git a/db/migrate/20151105094515_create_releases.rb b/db/migrate/20151105094515_create_releases.rb deleted file mode 100644 index 4b180a59486..00000000000 --- a/db/migrate/20151105094515_create_releases.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable all -class CreateReleases < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :releases do |t| - t.string :tag - t.text :description - t.integer :project_id - - t.timestamps null: true - end - - add_index :releases, :project_id - add_index :releases, [:project_id, :tag] - end -end diff --git a/db/migrate/20151106000015_add_is_award_to_notes.rb b/db/migrate/20151106000015_add_is_award_to_notes.rb deleted file mode 100644 index 1d866fb3213..00000000000 --- a/db/migrate/20151106000015_add_is_award_to_notes.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddIsAwardToNotes < ActiveRecord::Migration[4.2] - def change - add_column :notes, :is_award, :boolean, default: false, null: false - add_index :notes, :is_award - end -end diff --git a/db/migrate/20151109100728_add_max_artifacts_size_to_application_settings.rb b/db/migrate/20151109100728_add_max_artifacts_size_to_application_settings.rb deleted file mode 100644 index 9c14cfd4656..00000000000 --- a/db/migrate/20151109100728_add_max_artifacts_size_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMaxArtifactsSizeToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :max_artifacts_size, :integer, default: 100, null: false - end -end diff --git a/db/migrate/20151109134526_add_issues_state_index.rb b/db/migrate/20151109134526_add_issues_state_index.rb deleted file mode 100644 index c77ca90a0d6..00000000000 --- a/db/migrate/20151109134526_add_issues_state_index.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddIssuesStateIndex < ActiveRecord::Migration[4.2] - def change - add_index :issues, :state - end -end diff --git a/db/migrate/20151109134916_add_projects_visibility_level_index.rb b/db/migrate/20151109134916_add_projects_visibility_level_index.rb deleted file mode 100644 index 1e945f0e56f..00000000000 --- a/db/migrate/20151109134916_add_projects_visibility_level_index.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddProjectsVisibilityLevelIndex < ActiveRecord::Migration[4.2] - def change - add_index :projects, :visibility_level - end -end diff --git a/db/migrate/20151110125604_add_import_error_to_project.rb b/db/migrate/20151110125604_add_import_error_to_project.rb deleted file mode 100644 index 48a15ad0737..00000000000 --- a/db/migrate/20151110125604_add_import_error_to_project.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddImportErrorToProject < ActiveRecord::Migration[4.2] - def change - add_column :projects, :import_error, :text - end -end diff --git a/db/migrate/20151114113410_add_index_for_lfs_oid_and_size.rb b/db/migrate/20151114113410_add_index_for_lfs_oid_and_size.rb deleted file mode 100644 index f2788117cc2..00000000000 --- a/db/migrate/20151114113410_add_index_for_lfs_oid_and_size.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddIndexForLfsOidAndSize < ActiveRecord::Migration[4.2] - def change - add_index :lfs_objects, :oid - add_index :lfs_objects, [:oid, :size] - end -end diff --git a/db/migrate/20151116144118_add_unique_for_lfs_oid_index.rb b/db/migrate/20151116144118_add_unique_for_lfs_oid_index.rb deleted file mode 100644 index 3bfbae67119..00000000000 --- a/db/migrate/20151116144118_add_unique_for_lfs_oid_index.rb +++ /dev/null @@ -1,8 +0,0 @@ -# rubocop:disable all -class AddUniqueForLfsOidIndex < ActiveRecord::Migration[4.2] - def change - remove_index :lfs_objects, :oid - remove_index :lfs_objects, [:oid, :size] - add_index :lfs_objects, :oid, unique: true - end -end diff --git a/db/migrate/20151118162244_add_projects_public_index.rb b/db/migrate/20151118162244_add_projects_public_index.rb deleted file mode 100644 index 3a525c69ad0..00000000000 --- a/db/migrate/20151118162244_add_projects_public_index.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddProjectsPublicIndex < ActiveRecord::Migration[4.2] - def change - add_index :namespaces, :public - end -end diff --git a/db/migrate/20151201203948_raise_hook_url_limit.rb b/db/migrate/20151201203948_raise_hook_url_limit.rb deleted file mode 100644 index c1a4974b8c9..00000000000 --- a/db/migrate/20151201203948_raise_hook_url_limit.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RaiseHookUrlLimit < ActiveRecord::Migration[4.2] - def change - change_column :web_hooks, :url, :string, limit: 2000 - end -end diff --git a/db/migrate/20151203162133_add_hide_project_limit_to_users.rb b/db/migrate/20151203162133_add_hide_project_limit_to_users.rb deleted file mode 100644 index 1b96a0dc550..00000000000 --- a/db/migrate/20151203162133_add_hide_project_limit_to_users.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddHideProjectLimitToUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :hide_project_limit, :boolean, default: false - end -end diff --git a/db/migrate/20151203162134_add_build_events_to_services.rb b/db/migrate/20151203162134_add_build_events_to_services.rb deleted file mode 100644 index c49604f8b61..00000000000 --- a/db/migrate/20151203162134_add_build_events_to_services.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddBuildEventsToServices < ActiveRecord::Migration[4.2] - def change - add_column :services, :build_events, :boolean, default: false, null: false - add_column :web_hooks, :build_events, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20151209144329_migrate_ci_web_hooks.rb b/db/migrate/20151209144329_migrate_ci_web_hooks.rb deleted file mode 100644 index 7562735cb1e..00000000000 --- a/db/migrate/20151209144329_migrate_ci_web_hooks.rb +++ /dev/null @@ -1,16 +0,0 @@ -class MigrateCiWebHooks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def up - execute( - 'INSERT INTO web_hooks (url, project_id, type, created_at, updated_at, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events) ' \ - "SELECT ci_web_hooks.url, projects.id, 'ProjectHook', ci_web_hooks.created_at, ci_web_hooks.updated_at, " \ - "#{false_value}, #{false_value}, #{false_value}, #{false_value}, #{false_value}, #{true_value} FROM ci_web_hooks " \ - 'JOIN ci_projects ON ci_web_hooks.project_id = ci_projects.id ' \ - 'JOIN projects ON ci_projects.gitlab_id = projects.id' - ) - end - - def down - end -end diff --git a/db/migrate/20151209145909_migrate_ci_emails.rb b/db/migrate/20151209145909_migrate_ci_emails.rb deleted file mode 100644 index a1f51c55a55..00000000000 --- a/db/migrate/20151209145909_migrate_ci_emails.rb +++ /dev/null @@ -1,45 +0,0 @@ -class MigrateCiEmails < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def up - # This inserts a new service: BuildsEmailService - # It "manually" constructs the properties (JSON-encoded) - # Migrating all ci_projects e-mail related columns - execute( - 'INSERT INTO services (project_id, type, created_at, updated_at, active, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events, properties) ' \ - "SELECT projects.id, 'BuildsEmailService', ci_services.created_at, ci_services.updated_at, " \ - "#{true_value}, #{false_value}, #{false_value}, #{false_value}, #{false_value}, #{false_value}, #{true_value}, " \ - "CONCAT('{\"notify_only_broken_builds\":\"', #{convert_bool('ci_projects.email_only_broken_builds')}, " \ - "'\",\"add_pusher\":\"', #{convert_bool('ci_projects.email_add_pusher')}, " \ - "'\",\"recipients\":\"', #{escape_text('ci_projects.email_recipients')}, " \ - "'\"}') " \ - 'FROM ci_services ' \ - 'JOIN ci_projects ON ci_services.project_id = ci_projects.id ' \ - 'JOIN projects ON ci_projects.gitlab_id = projects.id ' \ - "WHERE ci_services.type = 'Ci::MailService' AND ci_services.active" - ) - end - - def down - end - - # This function escapes double-quotes and slash - def escape_text(name) - if Gitlab::Database.postgresql? - "REPLACE(REPLACE(#{name}, '\\', '\\\\'), '\"', '\\\"')" - else - "REPLACE(REPLACE(#{name}, '\\\\', '\\\\\\\\'), '\\\"', '\\\\\\\"')" - end - end - - # This function returns 0 or 1 for column - def convert_bool(name) - if Gitlab::Database.postgresql? - # PostgreSQL uses BOOLEAN type - "CASE WHEN #{name} IS TRUE THEN '1' ELSE '0' END" - else - # MySQL uses TINYINT - "#{name}" - end - end -end diff --git a/db/migrate/20151210030143_add_unlock_token_to_user.rb b/db/migrate/20151210030143_add_unlock_token_to_user.rb deleted file mode 100644 index 28b736adfb5..00000000000 --- a/db/migrate/20151210030143_add_unlock_token_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUnlockTokenToUser < ActiveRecord::Migration[4.2] - def change - add_column :users, :unlock_token, :string - end -end diff --git a/db/migrate/20151210072243_add_runners_registration_token_to_application_settings.rb b/db/migrate/20151210072243_add_runners_registration_token_to_application_settings.rb deleted file mode 100644 index 5da33149b59..00000000000 --- a/db/migrate/20151210072243_add_runners_registration_token_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRunnersRegistrationTokenToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :runners_registration_token, :string - end -end diff --git a/db/migrate/20151210125232_migrate_ci_slack_service.rb b/db/migrate/20151210125232_migrate_ci_slack_service.rb deleted file mode 100644 index 72c90f92377..00000000000 --- a/db/migrate/20151210125232_migrate_ci_slack_service.rb +++ /dev/null @@ -1,33 +0,0 @@ -class MigrateCiSlackService < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def up - properties_query = 'SELECT properties FROM ci_services ' \ - 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \ - "WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::SlackService' AND ci_services.active " \ - 'LIMIT 1' - - active_query = 'SELECT 1 FROM ci_services ' \ - 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \ - "WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::SlackService' AND ci_services.active " \ - 'LIMIT 1' - - # We update the service since services are always generated for project, even if they are inactive - # Activate service and migrate properties if currently the service is not active - execute( - "UPDATE services SET properties=(#{properties_query}), active=#{true_value}, " \ - "push_events=#{false_value}, issues_events=#{false_value}, merge_requests_events=#{false_value}, " \ - "tag_push_events=#{false_value}, note_events=#{false_value}, build_events=#{true_value} " \ - "WHERE NOT services.active AND services.type='SlackService' AND (#{active_query}) IS NOT NULL" - ) - - # Tick only build_events if the service is already active - execute( - "UPDATE services SET build_events=#{true_value} " \ - "WHERE services.active AND services.type='SlackService' AND (#{active_query}) IS NOT NULL" - ) - end - - def down - end -end diff --git a/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb b/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb deleted file mode 100644 index 5ec0798c38f..00000000000 --- a/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb +++ /dev/null @@ -1,34 +0,0 @@ -class MigrateCiHipChatService < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def up - # From properties strip `hipchat_` key - properties_query = "SELECT REPLACE(properties, '\"hipchat_', '\"') FROM ci_services " \ - 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \ - "WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::HipChatService' AND ci_services.active " \ - 'LIMIT 1' - - active_query = 'SELECT 1 FROM ci_services ' \ - 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \ - "WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::HipChatService' AND ci_services.active " \ - 'LIMIT 1' - - # We update the service since services are always generated for project, even if they are inactive - # Activate service and migrate properties if currently the service is not active - execute( - "UPDATE services SET properties=(#{properties_query}), active=#{true_value}, " \ - "push_events=#{false_value}, issues_events=#{false_value}, merge_requests_events=#{false_value}, " \ - "tag_push_events=#{false_value}, note_events=#{false_value}, build_events=#{true_value} " \ - "WHERE NOT services.active AND services.type='HipchatService' AND (#{active_query}) IS NOT NULL" - ) - - # Tick only build_events if the service is already active - execute( - "UPDATE services SET build_events=#{true_value} " \ - "WHERE services.active AND services.type='HipchatService' AND (#{active_query}) IS NOT NULL" - ) - end - - def down - end -end diff --git a/db/migrate/20151210125928_add_ci_to_project.rb b/db/migrate/20151210125928_add_ci_to_project.rb deleted file mode 100644 index 182f1e17b9a..00000000000 --- a/db/migrate/20151210125928_add_ci_to_project.rb +++ /dev/null @@ -1,12 +0,0 @@ -# rubocop:disable all -class AddCiToProject < ActiveRecord::Migration[4.2] - def change - add_column :projects, :ci_id, :integer - add_column :projects, :builds_enabled, :boolean, default: true, null: false - add_column :projects, :shared_runners_enabled, :boolean, default: true, null: false - add_column :projects, :runners_token, :string - add_column :projects, :build_coverage_regex, :string - add_column :projects, :build_allow_git_fetch, :boolean, default: true, null: false - add_column :projects, :build_timeout, :integer, default: 3600, null: false - end -end diff --git a/db/migrate/20151210125929_add_project_id_to_ci.rb b/db/migrate/20151210125929_add_project_id_to_ci.rb deleted file mode 100644 index f5f2c353f4a..00000000000 --- a/db/migrate/20151210125929_add_project_id_to_ci.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddProjectIdToCi < ActiveRecord::Migration[4.2] - def change - add_column :ci_builds, :gl_project_id, :integer - add_column :ci_runner_projects, :gl_project_id, :integer - add_column :ci_triggers, :gl_project_id, :integer - add_column :ci_variables, :gl_project_id, :integer - end -end diff --git a/db/migrate/20151210125930_migrate_ci_to_project.rb b/db/migrate/20151210125930_migrate_ci_to_project.rb deleted file mode 100644 index f7573ad1a8d..00000000000 --- a/db/migrate/20151210125930_migrate_ci_to_project.rb +++ /dev/null @@ -1,42 +0,0 @@ -class MigrateCiToProject < ActiveRecord::Migration[4.2] - def up - migrate_project_id_for_table('ci_runner_projects') - migrate_project_id_for_table('ci_triggers') - migrate_project_id_for_table('ci_variables') - migrate_project_id_for_builds - - migrate_project_column('id', 'ci_id') - migrate_project_column('shared_runners_enabled', 'shared_runners_enabled') - migrate_project_column('token', 'runners_token') - migrate_project_column('coverage_regex', 'build_coverage_regex') - migrate_project_column('allow_git_fetch', 'build_allow_git_fetch') - migrate_project_column('timeout', 'build_timeout') - migrate_ci_service - end - - def down - # We can't reverse the data - end - - def migrate_project_id_for_table(table) - subquery = "SELECT gitlab_id FROM ci_projects WHERE ci_projects.id = #{table}.project_id" - execute("UPDATE #{table} SET gl_project_id=(#{subquery}) WHERE gl_project_id IS NULL") - end - - def migrate_project_id_for_builds - subquery = 'SELECT gl_project_id FROM ci_commits WHERE ci_commits.id = ci_builds.commit_id' - execute("UPDATE ci_builds SET gl_project_id=(#{subquery}) WHERE gl_project_id IS NULL") - end - - def migrate_project_column(column, new_column = nil) - new_column ||= column - subquery = "SELECT ci_projects.#{column} FROM ci_projects WHERE projects.id = ci_projects.gitlab_id " \ - 'ORDER BY ci_projects.updated_at DESC LIMIT 1' - execute("UPDATE projects SET #{new_column}=(#{subquery}) WHERE (#{subquery}) IS NOT NULL") - end - - def migrate_ci_service - subquery = "SELECT active FROM services WHERE projects.id = services.project_id AND type='GitlabCiService' LIMIT 1" - execute("UPDATE projects SET builds_enabled=(#{subquery}) WHERE (#{subquery}) IS NOT NULL") - end -end diff --git a/db/migrate/20151210125931_add_index_to_ci_tables.rb b/db/migrate/20151210125931_add_index_to_ci_tables.rb deleted file mode 100644 index 2cbc5b50538..00000000000 --- a/db/migrate/20151210125931_add_index_to_ci_tables.rb +++ /dev/null @@ -1,13 +0,0 @@ -# rubocop:disable all -class AddIndexToCiTables < ActiveRecord::Migration[4.2] - def change - add_index :ci_builds, :gl_project_id - add_index :ci_runner_projects, :gl_project_id - add_index :ci_triggers, :gl_project_id - add_index :ci_variables, :gl_project_id - add_index :projects, :runners_token - add_index :projects, :builds_enabled - add_index :projects, [:builds_enabled, :shared_runners_enabled] - add_index :projects, [:ci_id] - end -end diff --git a/db/migrate/20151210125932_drop_null_for_ci_tables.rb b/db/migrate/20151210125932_drop_null_for_ci_tables.rb deleted file mode 100644 index b48fef4b749..00000000000 --- a/db/migrate/20151210125932_drop_null_for_ci_tables.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable all -class DropNullForCiTables < ActiveRecord::Migration[4.2] - def change - remove_index :ci_variables, :project_id - remove_index :ci_runner_projects, :project_id - change_column_null :ci_triggers, :project_id, true - change_column_null :ci_variables, :project_id, true - change_column_null :ci_runner_projects, :project_id, true - end -end diff --git a/db/migrate/20151215132013_add_pages_size_to_application_settings.rb b/db/migrate/20151215132013_add_pages_size_to_application_settings.rb deleted file mode 100644 index 7190d476dc7..00000000000 --- a/db/migrate/20151215132013_add_pages_size_to_application_settings.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddPagesSizeToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_column_with_default :application_settings, :max_pages_size, :integer, default: 100, allow_null: false - end - - def down - remove_column(:application_settings, :max_pages_size) - end -end diff --git a/db/migrate/20151218154042_add_tfa_to_application_settings.rb b/db/migrate/20151218154042_add_tfa_to_application_settings.rb deleted file mode 100644 index a981fe2720f..00000000000 --- a/db/migrate/20151218154042_add_tfa_to_application_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddTfaToApplicationSettings < ActiveRecord::Migration[4.2] - def change - change_table :application_settings do |t| - t.boolean :require_two_factor_authentication, default: false - t.integer :two_factor_grace_period, default: 48 - end - end -end diff --git a/db/migrate/20151221234414_add_tfa_additional_fields.rb b/db/migrate/20151221234414_add_tfa_additional_fields.rb deleted file mode 100644 index fed734f77f4..00000000000 --- a/db/migrate/20151221234414_add_tfa_additional_fields.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddTfaAdditionalFields < ActiveRecord::Migration[4.2] - def change - change_table :users do |t| - t.datetime :otp_grace_period_started_at, null: true - end - end -end diff --git a/db/migrate/20151224123230_rename_emojis.rb b/db/migrate/20151224123230_rename_emojis.rb deleted file mode 100644 index f1e4b1fe181..00000000000 --- a/db/migrate/20151224123230_rename_emojis.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Migration type: online without errors (works on previous version and new one) -class RenameEmojis < ActiveRecord::Migration[4.2] - def up - # Renames aliases to main names - execute("UPDATE notes SET note ='thumbsup' WHERE is_award = true AND note = '+1'") - execute("UPDATE notes SET note ='thumbsdown' WHERE is_award = true AND note = '-1'") - execute("UPDATE notes SET note ='poop' WHERE is_award = true AND note = 'shit'") - end - - def down - execute("UPDATE notes SET note ='+1' WHERE is_award = true AND note = 'thumbsup'") - execute("UPDATE notes SET note ='-1' WHERE is_award = true AND note = 'thumbsdown'") - execute("UPDATE notes SET note ='shit' WHERE is_award = true AND note = 'poop'") - end -end diff --git a/db/migrate/20151228111122_remove_public_from_namespace.rb b/db/migrate/20151228111122_remove_public_from_namespace.rb deleted file mode 100644 index ad922e3fc58..00000000000 --- a/db/migrate/20151228111122_remove_public_from_namespace.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -# Migration type: online -class RemovePublicFromNamespace < ActiveRecord::Migration[4.2] - def change - remove_column :namespaces, :public, :boolean - end -end diff --git a/db/migrate/20151228150906_influxdb_settings.rb b/db/migrate/20151228150906_influxdb_settings.rb deleted file mode 100644 index 8266e3c5044..00000000000 --- a/db/migrate/20151228150906_influxdb_settings.rb +++ /dev/null @@ -1,19 +0,0 @@ -# rubocop:disable all -class InfluxdbSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :metrics_enabled, :boolean, default: false - - add_column :application_settings, :metrics_host, :string, - default: 'localhost' - - add_column :application_settings, :metrics_database, :string, - default: 'gitlab' - - add_column :application_settings, :metrics_username, :string - add_column :application_settings, :metrics_password, :string - add_column :application_settings, :metrics_pool_size, :integer, default: 16 - add_column :application_settings, :metrics_timeout, :integer, default: 10 - add_column :application_settings, :metrics_method_call_threshold, - :integer, default: 10 - end -end diff --git a/db/migrate/20151228175719_add_recaptcha_to_application_settings.rb b/db/migrate/20151228175719_add_recaptcha_to_application_settings.rb deleted file mode 100644 index 523f2cae092..00000000000 --- a/db/migrate/20151228175719_add_recaptcha_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddRecaptchaToApplicationSettings < ActiveRecord::Migration[4.2] - def change - change_table :application_settings do |t| - t.boolean :recaptcha_enabled, default: false - t.string :recaptcha_site_key - t.string :recaptcha_private_key - end - end -end diff --git a/db/migrate/20151229102248_influxdb_udp_port_setting.rb b/db/migrate/20151229102248_influxdb_udp_port_setting.rb deleted file mode 100644 index da37e3bc148..00000000000 --- a/db/migrate/20151229102248_influxdb_udp_port_setting.rb +++ /dev/null @@ -1,5 +0,0 @@ -class InfluxdbUdpPortSetting < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :metrics_port, :integer, default: 8089 - end -end diff --git a/db/migrate/20151229112614_influxdb_remote_database_setting.rb b/db/migrate/20151229112614_influxdb_remote_database_setting.rb deleted file mode 100644 index 5fdf4c6d4cb..00000000000 --- a/db/migrate/20151229112614_influxdb_remote_database_setting.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class InfluxdbRemoteDatabaseSetting < ActiveRecord::Migration[4.2] - def change - remove_column :application_settings, :metrics_database - end -end diff --git a/db/migrate/20151230132518_add_artifacts_metadata_to_ci_build.rb b/db/migrate/20151230132518_add_artifacts_metadata_to_ci_build.rb deleted file mode 100644 index 61a3d6486f3..00000000000 --- a/db/migrate/20151230132518_add_artifacts_metadata_to_ci_build.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddArtifactsMetadataToCiBuild < ActiveRecord::Migration[4.2] - def change - add_column :ci_builds, :artifacts_metadata, :text - end -end diff --git a/db/migrate/20151231152326_add_akismet_to_application_settings.rb b/db/migrate/20151231152326_add_akismet_to_application_settings.rb deleted file mode 100644 index ef51ea03a5b..00000000000 --- a/db/migrate/20151231152326_add_akismet_to_application_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddAkismetToApplicationSettings < ActiveRecord::Migration[4.2] - def change - change_table :application_settings do |t| - t.boolean :akismet_enabled, default: false - t.string :akismet_api_key - end - end -end diff --git a/db/migrate/20151231202530_remove_alert_type_from_broadcast_messages.rb b/db/migrate/20151231202530_remove_alert_type_from_broadcast_messages.rb deleted file mode 100644 index 2d8b44840f0..00000000000 --- a/db/migrate/20151231202530_remove_alert_type_from_broadcast_messages.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class RemoveAlertTypeFromBroadcastMessages < ActiveRecord::Migration[4.2] - def change - remove_column :broadcast_messages, :alert_type, :integer - end -end diff --git a/db/migrate/20160106162223_add_index_milestones_title.rb b/db/migrate/20160106162223_add_index_milestones_title.rb deleted file mode 100644 index d42bddefe64..00000000000 --- a/db/migrate/20160106162223_add_index_milestones_title.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddIndexMilestonesTitle < ActiveRecord::Migration[4.2] - def change - add_index :milestones, :title - end -end diff --git a/db/migrate/20160106164438_remove_influxdb_credentials.rb b/db/migrate/20160106164438_remove_influxdb_credentials.rb deleted file mode 100644 index 569d5a0cf36..00000000000 --- a/db/migrate/20160106164438_remove_influxdb_credentials.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class RemoveInfluxdbCredentials < ActiveRecord::Migration[4.2] - def change - remove_column :application_settings, :metrics_username, :string - remove_column :application_settings, :metrics_password, :string - end -end diff --git a/db/migrate/20160109054846_create_spam_logs.rb b/db/migrate/20160109054846_create_spam_logs.rb deleted file mode 100644 index dc97d03f7ff..00000000000 --- a/db/migrate/20160109054846_create_spam_logs.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable all -class CreateSpamLogs < ActiveRecord::Migration[4.2] - def change - create_table :spam_logs do |t| - t.integer :user_id - t.string :source_ip - t.string :user_agent - t.boolean :via_api - t.integer :project_id - t.string :noteable_type - t.string :title - t.text :description - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160113111034_add_metrics_sample_interval.rb b/db/migrate/20160113111034_add_metrics_sample_interval.rb deleted file mode 100644 index 9c3377571aa..00000000000 --- a/db/migrate/20160113111034_add_metrics_sample_interval.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddMetricsSampleInterval < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :metrics_sample_interval, :integer, - default: 15 - end -end diff --git a/db/migrate/20160118155830_add_sentry_to_application_settings.rb b/db/migrate/20160118155830_add_sentry_to_application_settings.rb deleted file mode 100644 index 20f3925b964..00000000000 --- a/db/migrate/20160118155830_add_sentry_to_application_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddSentryToApplicationSettings < ActiveRecord::Migration[4.2] - def change - change_table :application_settings do |t| - t.boolean :sentry_enabled, default: false - t.string :sentry_dsn - end - end -end diff --git a/db/migrate/20160118232755_add_ip_blocking_settings_to_application_settings.rb b/db/migrate/20160118232755_add_ip_blocking_settings_to_application_settings.rb deleted file mode 100644 index 809a6cceef5..00000000000 --- a/db/migrate/20160118232755_add_ip_blocking_settings_to_application_settings.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddIpBlockingSettingsToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :ip_blocking_enabled, :boolean, default: false - add_column :application_settings, :dnsbl_servers_list, :text - end -end diff --git a/db/migrate/20160119111158_add_services_category.rb b/db/migrate/20160119111158_add_services_category.rb deleted file mode 100644 index 979a48584a9..00000000000 --- a/db/migrate/20160119111158_add_services_category.rb +++ /dev/null @@ -1,40 +0,0 @@ -# rubocop:disable all -class AddServicesCategory < ActiveRecord::Migration[4.2] - def up - add_column :services, :category, :string, default: 'common', null: false - - category = quote_column_name('category') - type = quote_column_name('type') - - execute <<-EOF -UPDATE services -SET #{category} = 'issue_tracker' -WHERE #{type} IN ( - 'CustomIssueTrackerService', - 'GitlabIssueTrackerService', - 'IssueTrackerService', - 'JiraService', - 'RedmineService' -); -EOF - - execute <<-EOF -UPDATE services -SET #{category} = 'ci' -WHERE #{type} IN ( - 'BambooService', - 'BuildkiteService', - 'CiService', - 'DroneCiService', - 'GitlabCiService', - 'TeamcityService' -); - EOF - - add_index :services, :category - end - - def down - remove_column :services, :category - end -end diff --git a/db/migrate/20160119112418_add_services_default.rb b/db/migrate/20160119112418_add_services_default.rb deleted file mode 100644 index 41ba5d98afe..00000000000 --- a/db/migrate/20160119112418_add_services_default.rb +++ /dev/null @@ -1,21 +0,0 @@ -# rubocop:disable all -class AddServicesDefault < ActiveRecord::Migration[4.2] - def up - add_column :services, :default, :boolean, default: false - - default = quote_column_name('default') - type = quote_column_name('type') - - execute <<-EOF -UPDATE services -SET #{default} = true -WHERE #{type} = 'GitlabIssueTrackerService' -EOF - - add_index :services, :default - end - - def down - remove_column :services, :default - end -end diff --git a/db/migrate/20160119145451_add_ldap_email_to_users.rb b/db/migrate/20160119145451_add_ldap_email_to_users.rb deleted file mode 100644 index bf8c27900b8..00000000000 --- a/db/migrate/20160119145451_add_ldap_email_to_users.rb +++ /dev/null @@ -1,31 +0,0 @@ -# rubocop:disable all -class AddLdapEmailToUsers < ActiveRecord::Migration[4.2] - def up - add_column :users, :ldap_email, :boolean, default: false, null: false - - if Gitlab::Database.mysql? - execute %{ - UPDATE users, identities - SET users.ldap_email = TRUE - WHERE identities.user_id = users.id - AND users.email LIKE 'temp-email-for-oauth%' - AND identities.provider LIKE 'ldap%' - AND identities.extern_uid IS NOT NULL - } - else - execute %{ - UPDATE users - SET ldap_email = TRUE - FROM identities - WHERE identities.user_id = users.id - AND users.email LIKE 'temp-email-for-oauth%' - AND identities.provider LIKE 'ldap%' - AND identities.extern_uid IS NOT NULL - } - end - end - - def down - remove_column :users, :ldap_email - end -end diff --git a/db/migrate/20160120172143_add_base_commit_sha_to_merge_request_diffs.rb b/db/migrate/20160120172143_add_base_commit_sha_to_merge_request_diffs.rb deleted file mode 100644 index 9c0a91758f5..00000000000 --- a/db/migrate/20160120172143_add_base_commit_sha_to_merge_request_diffs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBaseCommitShaToMergeRequestDiffs < ActiveRecord::Migration[4.2] - def change - add_column :merge_request_diffs, :base_commit_sha, :string - end -end diff --git a/db/migrate/20160121030729_add_email_author_in_body_to_application_settings.rb b/db/migrate/20160121030729_add_email_author_in_body_to_application_settings.rb deleted file mode 100644 index 0cb1fbe8641..00000000000 --- a/db/migrate/20160121030729_add_email_author_in_body_to_application_settings.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddEmailAuthorInBodyToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :email_author_in_body, :boolean, default: false - end -end diff --git a/db/migrate/20160122185421_add_pending_delete_to_project.rb b/db/migrate/20160122185421_add_pending_delete_to_project.rb deleted file mode 100644 index 8db0adc9221..00000000000 --- a/db/migrate/20160122185421_add_pending_delete_to_project.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddPendingDeleteToProject < ActiveRecord::Migration[4.2] - def change - add_column :projects, :pending_delete, :boolean, default: false - end -end diff --git a/db/migrate/20160128212447_remove_ip_blocking_settings_from_application_settings.rb b/db/migrate/20160128212447_remove_ip_blocking_settings_from_application_settings.rb deleted file mode 100644 index e76f0249ae5..00000000000 --- a/db/migrate/20160128212447_remove_ip_blocking_settings_from_application_settings.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class RemoveIpBlockingSettingsFromApplicationSettings < ActiveRecord::Migration[4.2] - def change - remove_column :application_settings, :ip_blocking_enabled, :boolean, default: false - remove_column :application_settings, :dnsbl_servers_list, :text - end -end diff --git a/db/migrate/20160128233227_change_lfs_objects_size_column.rb b/db/migrate/20160128233227_change_lfs_objects_size_column.rb deleted file mode 100644 index 65aaf2d9a0b..00000000000 --- a/db/migrate/20160128233227_change_lfs_objects_size_column.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeLfsObjectsSizeColumn < ActiveRecord::Migration[4.2] - def change - change_column :lfs_objects, :size, :integer, limit: 8 - end -end diff --git a/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb b/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb deleted file mode 100644 index 6254017615b..00000000000 --- a/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb +++ /dev/null @@ -1,80 +0,0 @@ -class RemoveDotAtomPathEndingOfProjects < ActiveRecord::Migration[4.2] - include Gitlab::ShellAdapter - - class ProjectPath - attr_reader :old_path, :id, :namespace_path - - def initialize(old_path, id, namespace_path, namespace_id) - @old_path = old_path - @id = id - @namespace_path = namespace_path - @namespace_id = namespace_id - end - - def clean_path - @_clean_path ||= PathCleaner.clean(@old_path, @namespace_id) - end - end - - class PathCleaner - def initialize(path, namespace_id) - @namespace_id = namespace_id - @path = path - end - - def self.clean(*args) - new(*args).clean - end - - def clean - path = cleaned_path - count = 0 - while path_exists?(path) - path = "#{cleaned_path}#{count}" - count += 1 - end - path - end - - private - - def cleaned_path - @_cleaned_path ||= @path.gsub(/\.atom\z/, '-atom') - end - - def path_exists?(path) - Project.find_by_path_and_namespace_id(path, @namespace_id) - end - end - - def projects_with_dot_atom - select_all("SELECT p.id, p.path, n.path as namespace_path, n.id as namespace_id FROM projects p inner join namespaces n on n.id = p.namespace_id WHERE p.path LIKE '%.atom'") - end - - def up - projects_with_dot_atom.each do |project| - project_path = ProjectPath.new(project['path'], project['id'], project['namespace_path'], project['namespace_id']) - clean_path(project_path) if rename_project_repo(project_path) - end - end - - private - - def clean_path(project_path) - execute "UPDATE projects SET path = #{sanitize(project_path.clean_path)} WHERE id = #{project_path.id}" - end - - def rename_project_repo(project_path) - old_path_with_namespace = File.join(project_path.namespace_path, project_path.old_path) - new_path_with_namespace = File.join(project_path.namespace_path, project_path.clean_path) - - gitlab_shell.mv_repository("#{old_path_with_namespace}.wiki", "#{new_path_with_namespace}.wiki") - gitlab_shell.mv_repository(old_path_with_namespace, new_path_with_namespace) - rescue - false - end - - def sanitize(value) - ActiveRecord::Base.connection.quote(value) - end -end diff --git a/db/migrate/20160129155512_add_merge_commit_sha_to_merge_requests.rb b/db/migrate/20160129155512_add_merge_commit_sha_to_merge_requests.rb deleted file mode 100644 index 8b84705ce7d..00000000000 --- a/db/migrate/20160129155512_add_merge_commit_sha_to_merge_requests.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMergeCommitShaToMergeRequests < ActiveRecord::Migration[4.2] - def change - add_column :merge_requests, :merge_commit_sha, :string - end -end diff --git a/db/migrate/20160202091601_add_erasable_to_ci_build.rb b/db/migrate/20160202091601_add_erasable_to_ci_build.rb deleted file mode 100644 index 214028bd8d3..00000000000 --- a/db/migrate/20160202091601_add_erasable_to_ci_build.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddErasableToCiBuild < ActiveRecord::Migration[4.2] - def change - add_reference :ci_builds, :erased_by, references: :users, index: true - add_column :ci_builds, :erased_at, :datetime - end -end diff --git a/db/migrate/20160202164642_add_allow_guest_to_access_builds_project.rb b/db/migrate/20160202164642_add_allow_guest_to_access_builds_project.rb deleted file mode 100644 index 542f9437911..00000000000 --- a/db/migrate/20160202164642_add_allow_guest_to_access_builds_project.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddAllowGuestToAccessBuildsProject < ActiveRecord::Migration[4.2] - def change - add_column :projects, :public_builds, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20160204144558_add_real_size_to_merge_request_diffs.rb b/db/migrate/20160204144558_add_real_size_to_merge_request_diffs.rb deleted file mode 100644 index c1f1faf0279..00000000000 --- a/db/migrate/20160204144558_add_real_size_to_merge_request_diffs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRealSizeToMergeRequestDiffs < ActiveRecord::Migration[4.2] - def change - add_column :merge_request_diffs, :real_size, :string - end -end diff --git a/db/migrate/20160209130428_add_index_to_snippet.rb b/db/migrate/20160209130428_add_index_to_snippet.rb deleted file mode 100644 index 480ac193d63..00000000000 --- a/db/migrate/20160209130428_add_index_to_snippet.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddIndexToSnippet < ActiveRecord::Migration[4.2] - def change - add_index :snippets, :updated_at - end -end diff --git a/db/migrate/20160210105555_create_pages_domain.rb b/db/migrate/20160210105555_create_pages_domain.rb deleted file mode 100644 index a46906d64ca..00000000000 --- a/db/migrate/20160210105555_create_pages_domain.rb +++ /dev/null @@ -1,16 +0,0 @@ -class CreatePagesDomain < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :pages_domains do |t| - t.integer :project_id - t.text :certificate - t.text :encrypted_key - t.string :encrypted_key_iv - t.string :encrypted_key_salt - t.string :domain - end - - add_index :pages_domains, :domain, unique: true - end -end diff --git a/db/migrate/20160212123307_create_tasks.rb b/db/migrate/20160212123307_create_tasks.rb deleted file mode 100644 index 33acc8af91f..00000000000 --- a/db/migrate/20160212123307_create_tasks.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable all -class CreateTasks < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :tasks do |t| - t.references :user, null: false, index: true - t.references :project, null: false, index: true - t.references :target, polymorphic: true, null: false, index: true - t.integer :author_id, index: true - t.integer :action, null: false - t.string :state, null: false, index: true - - t.timestamps null: true - end - end -end diff --git a/db/migrate/20160217100506_add_description_to_label.rb b/db/migrate/20160217100506_add_description_to_label.rb deleted file mode 100644 index 116de8ddfa9..00000000000 --- a/db/migrate/20160217100506_add_description_to_label.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDescriptionToLabel < ActiveRecord::Migration[4.2] - def change - add_column :labels, :description, :string - end -end diff --git a/db/migrate/20160217174422_add_note_to_tasks.rb b/db/migrate/20160217174422_add_note_to_tasks.rb deleted file mode 100644 index c2a42ce5dd8..00000000000 --- a/db/migrate/20160217174422_add_note_to_tasks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddNoteToTasks < ActiveRecord::Migration[4.2] - def change - add_reference :tasks, :note, index: true - end -end diff --git a/db/migrate/20160220123949_rename_tasks_to_todos.rb b/db/migrate/20160220123949_rename_tasks_to_todos.rb deleted file mode 100644 index 0cc110a0a1a..00000000000 --- a/db/migrate/20160220123949_rename_tasks_to_todos.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RenameTasksToTodos < ActiveRecord::Migration[4.2] - def change - rename_table :tasks, :todos - end -end diff --git a/db/migrate/20160222153918_create_appearances_ce.rb b/db/migrate/20160222153918_create_appearances_ce.rb deleted file mode 100644 index 37bbe62ad3d..00000000000 --- a/db/migrate/20160222153918_create_appearances_ce.rb +++ /dev/null @@ -1,15 +0,0 @@ -# rubocop:disable all -class CreateAppearancesCe < ActiveRecord::Migration[4.2] - def change - unless table_exists?(:appearances) - create_table :appearances do |t| - t.string :title - t.text :description - t.string :header_logo - t.string :logo - - t.timestamps null: false - end - end - end -end diff --git a/db/migrate/20160223192159_add_confidential_to_issues.rb b/db/migrate/20160223192159_add_confidential_to_issues.rb deleted file mode 100644 index ca029f12337..00000000000 --- a/db/migrate/20160223192159_add_confidential_to_issues.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddConfidentialToIssues < ActiveRecord::Migration[4.2] - def change - add_column :issues, :confidential, :boolean, default: false - add_index :issues, :confidential - end -end diff --git a/db/migrate/20160225090018_add_delete_at_to_issues.rb b/db/migrate/20160225090018_add_delete_at_to_issues.rb deleted file mode 100644 index 3ae74f491f6..00000000000 --- a/db/migrate/20160225090018_add_delete_at_to_issues.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddDeleteAtToIssues < ActiveRecord::Migration[4.2] - def change - add_column :issues, :deleted_at, :datetime - add_index :issues, :deleted_at - end -end diff --git a/db/migrate/20160225101956_add_delete_at_to_merge_requests.rb b/db/migrate/20160225101956_add_delete_at_to_merge_requests.rb deleted file mode 100644 index ce8657ba88c..00000000000 --- a/db/migrate/20160225101956_add_delete_at_to_merge_requests.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddDeleteAtToMergeRequests < ActiveRecord::Migration[4.2] - def change - add_column :merge_requests, :deleted_at, :datetime - add_index :merge_requests, :deleted_at - end -end diff --git a/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb b/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb deleted file mode 100644 index af8b08c095a..00000000000 --- a/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb +++ /dev/null @@ -1,65 +0,0 @@ -# rubocop:disable all -class AddTrigramIndexesForSearching < ActiveRecord::Migration[4.2] - disable_ddl_transaction! - - def up - return unless Gitlab::Database.postgresql? - - create_trigrams_extension - - unless trigrams_enabled? - raise 'You must enable the pg_trgm extension. You can do so by running ' \ - '"CREATE EXTENSION pg_trgm;" as a PostgreSQL super user, this must be ' \ - 'done for every GitLab database. For more information see ' \ - 'http://www.postgresql.org/docs/current/static/sql-createextension.html' - end - - # trigram indexes are case-insensitive so we can just index the column - # instead of indexing lower(column) - to_index.each do |table, columns| - columns.each do |column| - execute "CREATE INDEX CONCURRENTLY index_#{table}_on_#{column}_trigram ON #{table} USING gin(#{column} gin_trgm_ops);" - end - end - end - - def down - return unless Gitlab::Database.postgresql? - - to_index.each do |table, columns| - columns.each do |column| - remove_index table, name: "index_#{table}_on_#{column}_trigram" - end - end - end - - def trigrams_enabled? - res = execute("SELECT true AS enabled FROM pg_available_extensions WHERE name = 'pg_trgm' AND installed_version IS NOT NULL;") - row = res.first - - row && row['enabled'] == true - end - - def create_trigrams_extension - # This may not work if the user doesn't have permission. We attempt in - # case we do have permission, particularly for test/dev environments. - begin - enable_extension 'pg_trgm' - rescue - end - end - - def to_index - { - ci_runners: [:token, :description], - issues: [:title, :description], - merge_requests: [:title, :description], - milestones: [:title, :description], - namespaces: [:name, :path], - notes: [:note], - projects: [:name, :path, :description], - snippets: [:title, :file_name], - users: [:username, :name, :email] - } - end -end diff --git a/db/migrate/20160227120001_add_event_field_for_web_hook.rb b/db/migrate/20160227120001_add_event_field_for_web_hook.rb deleted file mode 100644 index 22bbd73114f..00000000000 --- a/db/migrate/20160227120001_add_event_field_for_web_hook.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddEventFieldForWebHook < ActiveRecord::Migration[4.2] - def change - add_column :web_hooks, :wiki_page_events, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20160227120047_add_event_to_services.rb b/db/migrate/20160227120047_add_event_to_services.rb deleted file mode 100644 index a3b94734ec2..00000000000 --- a/db/migrate/20160227120047_add_event_to_services.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddEventToServices < ActiveRecord::Migration[4.2] - def change - add_column :services, :wiki_page_events, :boolean, default: true - end -end diff --git a/db/migrate/20160229193553_add_main_language_to_repository.rb b/db/migrate/20160229193553_add_main_language_to_repository.rb deleted file mode 100644 index 15f9a382802..00000000000 --- a/db/migrate/20160229193553_add_main_language_to_repository.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMainLanguageToRepository < ActiveRecord::Migration[4.2] - def change - add_column :projects, :main_language, :string - end -end diff --git a/db/migrate/20160301124843_add_visibility_level_to_groups.rb b/db/migrate/20160301124843_add_visibility_level_to_groups.rb deleted file mode 100644 index ed4bca4f1ba..00000000000 --- a/db/migrate/20160301124843_add_visibility_level_to_groups.rb +++ /dev/null @@ -1,30 +0,0 @@ -# rubocop:disable all -class AddVisibilityLevelToGroups < ActiveRecord::Migration[4.2] - def up - add_column :namespaces, :visibility_level, :integer, null: false, default: Gitlab::VisibilityLevel::PUBLIC - add_index :namespaces, :visibility_level - - # Unfortunately, this is needed on top of the `default`, since we don't want the configuration specific - # `allowed_visibility_level` to end up in schema.rb - if allowed_visibility_level < Gitlab::VisibilityLevel::PUBLIC - execute("UPDATE namespaces SET visibility_level = #{allowed_visibility_level}") - end - end - - def down - remove_column :namespaces, :visibility_level - end - - private - - def allowed_visibility_level - application_settings = select_one("SELECT restricted_visibility_levels FROM application_settings ORDER BY id DESC LIMIT 1") - if application_settings - restricted_visibility_levels = YAML.safe_load(application_settings["restricted_visibility_levels"]) rescue nil - end - restricted_visibility_levels ||= [] - - allowed_levels = Gitlab::VisibilityLevel.values - restricted_visibility_levels - allowed_levels.max - end -end diff --git a/db/migrate/20160301174731_add_fingerprint_index.rb b/db/migrate/20160301174731_add_fingerprint_index.rb deleted file mode 100644 index b13373a0468..00000000000 --- a/db/migrate/20160301174731_add_fingerprint_index.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable all -class AddFingerprintIndex < ActiveRecord::Migration[4.2] - disable_ddl_transaction! - - DOWNTIME = false - - # https://gitlab.com/gitlab-org/gitlab-ee/issues/764 - def change - args = [:keys, :fingerprint] - - if Gitlab::Database.postgresql? - args << { algorithm: :concurrently } - end - - add_index(*args) unless index_exists?(:keys, :fingerprint) - end -end diff --git a/db/migrate/20160302151724_add_import_credentials_to_project_import_data.rb b/db/migrate/20160302151724_add_import_credentials_to_project_import_data.rb deleted file mode 100644 index b0ea05bd6e1..00000000000 --- a/db/migrate/20160302151724_add_import_credentials_to_project_import_data.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddImportCredentialsToProjectImportData < ActiveRecord::Migration[4.2] - def change - add_column :project_import_data, :encrypted_credentials, :text - add_column :project_import_data, :encrypted_credentials_iv, :string - add_column :project_import_data, :encrypted_credentials_salt, :string - end -end diff --git a/db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb b/db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb deleted file mode 100644 index 8a319554c28..00000000000 --- a/db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb +++ /dev/null @@ -1,138 +0,0 @@ -# rubocop:disable all -# Loops through old importer projects that kept a token/password in the import URL -# and encrypts the credentials into a separate field in project#import_data -# #down method not supported -class RemoveWrongImportUrlFromProjects < ActiveRecord::Migration[4.2] - - class ProjectImportDataFake - extend AttrEncrypted - attr_accessor :credentials - attr_encrypted :credentials, - key: Settings.attr_encrypted_db_key_base, - marshal: true, - encode: true, - :mode => :per_attribute_iv_and_salt, - insecure_mode: true, - algorithm: 'aes-256-cbc' - end - - def up - say("Encrypting and migrating project import credentials...") - - # This should cover GitHub, GitLab, Bitbucket user:password, token@domain, and other similar URLs. - in_transaction(message: "Projects including GitHub and GitLab projects with an unsecured URL.") { process_projects_with_wrong_url } - - in_transaction(message: "Migrating Bitbucket credentials...") { process_project(import_type: 'bitbucket', credentials_keys: ['bb_session']) } - - in_transaction(message: "Migrating FogBugz credentials...") { process_project(import_type: 'fogbugz', credentials_keys: ['fb_session']) } - - end - - def process_projects_with_wrong_url - projects_with_wrong_import_url.each do |project| - begin - import_url = Gitlab::UrlSanitizer.new(project["import_url"]) - - update_import_url(import_url, project) - update_import_data(import_url, project) - rescue Addressable::URI::InvalidURIError - nullify_import_url(project) - end - end - end - - def process_project(import_type:, credentials_keys: []) - unencrypted_import_data(import_type: import_type).each do |data| - replace_data_credentials(data, credentials_keys) - end - end - - def replace_data_credentials(data, credentials_keys) - data_hash = JSON.load(data['data']) if data['data'] - unless data_hash.blank? - encrypted_data_hash = encrypt_data(data_hash, credentials_keys) - unencrypted_data = data_hash.empty? ? ' NULL ' : quote(data_hash.to_json) - update_with_encrypted_data(encrypted_data_hash, data['id'], unencrypted_data) - end - end - - def encrypt_data(data_hash, credentials_keys) - new_data_hash = {} - credentials_keys.each do |key| - new_data_hash[key.to_sym] = data_hash.delete(key) if data_hash[key] - end - new_data_hash.deep_symbolize_keys - end - - def in_transaction(message:) - say_with_time(message) do - ActiveRecord::Base.transaction do - yield - end - end - end - - def update_import_data(import_url, project) - fake_import_data = ProjectImportDataFake.new - fake_import_data.credentials = import_url.credentials - import_data_id = project['import_data_id'] - if import_data_id - execute(update_import_data_sql(import_data_id, fake_import_data)) - else - execute(insert_import_data_sql(project['id'], fake_import_data)) - end - end - - def update_with_encrypted_data(data_hash, import_data_id, unencrypted_data = ' NULL ') - fake_import_data = ProjectImportDataFake.new - fake_import_data.credentials = data_hash - execute(update_import_data_sql(import_data_id, fake_import_data, unencrypted_data)) - end - - def update_import_url(import_url, project) - execute("UPDATE projects SET import_url = #{quote(import_url.sanitized_url)} WHERE id = #{project['id']}") - end - - def nullify_import_url(project) - execute("UPDATE projects SET import_url = NULL WHERE id = #{project['id']}") - end - - def insert_import_data_sql(project_id, fake_import_data) - %( - INSERT INTO project_import_data - (encrypted_credentials, - project_id, - encrypted_credentials_iv, - encrypted_credentials_salt) - VALUES ( #{quote(fake_import_data.encrypted_credentials)}, - '#{project_id}', - #{quote(fake_import_data.encrypted_credentials_iv)}, - #{quote(fake_import_data.encrypted_credentials_salt)}) - ).squish - end - - def update_import_data_sql(id, fake_import_data, data = 'NULL') - %( - UPDATE project_import_data - SET encrypted_credentials = #{quote(fake_import_data.encrypted_credentials)}, - encrypted_credentials_iv = #{quote(fake_import_data.encrypted_credentials_iv)}, - encrypted_credentials_salt = #{quote(fake_import_data.encrypted_credentials_salt)}, - data = #{data} - WHERE id = '#{id}' - ).squish - end - - #GitHub projects with token, and any user:password@ based URL - def projects_with_wrong_import_url - select_all("SELECT p.id, p.import_url, i.id as import_data_id FROM projects p LEFT JOIN project_import_data i on p.id = i.project_id WHERE p.import_url <> '' AND p.import_url LIKE '%//%@%'") - end - - # All imports with data for import_type - def unencrypted_import_data(import_type: ) - select_all("SELECT i.id, p.import_url, i.data FROM projects p INNER JOIN project_import_data i ON p.id = i.project_id WHERE p.import_url <> '' AND p.import_type = '#{import_type}' ") - end - - def quote(value) - ActiveRecord::Base.connection.quote(value) - end -end diff --git a/db/migrate/20160305220806_remove_expires_at_from_snippets.rb b/db/migrate/20160305220806_remove_expires_at_from_snippets.rb deleted file mode 100644 index 6835f534926..00000000000 --- a/db/migrate/20160305220806_remove_expires_at_from_snippets.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class RemoveExpiresAtFromSnippets < ActiveRecord::Migration[4.2] - def change - remove_column :snippets, :expires_at, :datetime - end -end diff --git a/db/migrate/20160307221555_disallow_blank_line_code_on_note.rb b/db/migrate/20160307221555_disallow_blank_line_code_on_note.rb deleted file mode 100644 index 26b65ef7037..00000000000 --- a/db/migrate/20160307221555_disallow_blank_line_code_on_note.rb +++ /dev/null @@ -1,9 +0,0 @@ -class DisallowBlankLineCodeOnNote < ActiveRecord::Migration[4.2] - def up - execute("UPDATE notes SET line_code = NULL WHERE line_code = ''") - end - - def down - # noop - end -end diff --git a/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb b/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb deleted file mode 100644 index 16053408fe0..00000000000 --- a/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb +++ /dev/null @@ -1,32 +0,0 @@ -# rubocop:disable all -# Create visibility level field on DB -# Sets default_visibility_level to value on settings if not restricted -# If value is restricted takes higher visibility level allowed - -class AddDefaultGroupVisibilityToApplicationSettings < ActiveRecord::Migration[4.2] - def up - add_column :application_settings, :default_group_visibility, :integer - # Unfortunately, this can't be a `default`, since we don't want the configuration specific - # `allowed_visibility_level` to end up in schema.rb - - visibility_level = allowed_visibility_level || Gitlab::VisibilityLevel::PRIVATE - execute("UPDATE application_settings SET default_group_visibility = #{visibility_level}") - end - - def down - remove_column :application_settings, :default_group_visibility - end - - private - - def allowed_visibility_level - application_settings = select_one("SELECT restricted_visibility_levels FROM application_settings ORDER BY id DESC LIMIT 1") - if application_settings - restricted_visibility_levels = YAML.safe_load(application_settings["restricted_visibility_levels"]) rescue nil - end - restricted_visibility_levels ||= [] - - allowed_levels = Gitlab::VisibilityLevel.values - restricted_visibility_levels - allowed_levels.max - end -end diff --git a/db/migrate/20160309140734_fix_todos.rb b/db/migrate/20160309140734_fix_todos.rb deleted file mode 100644 index 917055f5036..00000000000 --- a/db/migrate/20160309140734_fix_todos.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable all -class FixTodos < ActiveRecord::Migration[4.2] - def up - execute <<-SQL - DELETE FROM todos - WHERE todos.target_type IN ('Commit', 'ProjectSnippet') - OR NOT EXISTS ( - SELECT * - FROM projects - WHERE projects.id = todos.project_id - ) - SQL - end - - def down - end -end diff --git a/db/migrate/20160310124959_add_due_date_to_issues.rb b/db/migrate/20160310124959_add_due_date_to_issues.rb deleted file mode 100644 index 8da38ea60b1..00000000000 --- a/db/migrate/20160310124959_add_due_date_to_issues.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddDueDateToIssues < ActiveRecord::Migration[4.2] - def change - add_column :issues, :due_date, :date - add_index :issues, :due_date - end -end diff --git a/db/migrate/20160310185910_add_external_flag_to_users.rb b/db/migrate/20160310185910_add_external_flag_to_users.rb deleted file mode 100644 index 768bbe4cd42..00000000000 --- a/db/migrate/20160310185910_add_external_flag_to_users.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddExternalFlagToUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :external, :boolean, default: false - end -end diff --git a/db/migrate/20160314094147_add_priority_to_label.rb b/db/migrate/20160314094147_add_priority_to_label.rb deleted file mode 100644 index 8e2aaf50109..00000000000 --- a/db/migrate/20160314094147_add_priority_to_label.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddPriorityToLabel < ActiveRecord::Migration[4.2] - def change - add_column :labels, :priority, :integer - add_index :labels, :priority - end -end diff --git a/db/migrate/20160314114439_add_requested_at_to_members.rb b/db/migrate/20160314114439_add_requested_at_to_members.rb deleted file mode 100644 index e7e03f96ef8..00000000000 --- a/db/migrate/20160314114439_add_requested_at_to_members.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable Migration/Datetime -class AddRequestedAtToMembers < ActiveRecord::Migration[4.2] - def change - add_column :members, :requested_at, :datetime - end -end diff --git a/db/migrate/20160314143402_projects_add_pushes_since_gc.rb b/db/migrate/20160314143402_projects_add_pushes_since_gc.rb deleted file mode 100644 index e64093d39cf..00000000000 --- a/db/migrate/20160314143402_projects_add_pushes_since_gc.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class ProjectsAddPushesSinceGc < ActiveRecord::Migration[4.2] - def change - add_column :projects, :pushes_since_gc, :integer, default: 0 - end -end diff --git a/db/migrate/20160315135439_project_add_repository_check.rb b/db/migrate/20160315135439_project_add_repository_check.rb deleted file mode 100644 index c03d8bb041c..00000000000 --- a/db/migrate/20160315135439_project_add_repository_check.rb +++ /dev/null @@ -1,9 +0,0 @@ -# rubocop:disable all -class ProjectAddRepositoryCheck < ActiveRecord::Migration[4.2] - def change - add_column :projects, :last_repository_check_failed, :boolean - add_index :projects, :last_repository_check_failed - - add_column :projects, :last_repository_check_at, :datetime - end -end diff --git a/db/migrate/20160316123110_ci_runners_token_index.rb b/db/migrate/20160316123110_ci_runners_token_index.rb deleted file mode 100644 index 026846e6464..00000000000 --- a/db/migrate/20160316123110_ci_runners_token_index.rb +++ /dev/null @@ -1,14 +0,0 @@ -# rubocop:disable all -class CiRunnersTokenIndex < ActiveRecord::Migration[4.2] - disable_ddl_transaction! - - def change - args = [:ci_runners, :token] - - if Gitlab::Database.postgresql? - args << { algorithm: :concurrently } - end - - add_index(*args) - end -end diff --git a/db/migrate/20160316192622_change_target_id_to_null_on_todos.rb b/db/migrate/20160316192622_change_target_id_to_null_on_todos.rb deleted file mode 100644 index 488c3d4945c..00000000000 --- a/db/migrate/20160316192622_change_target_id_to_null_on_todos.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeTargetIdToNullOnTodos < ActiveRecord::Migration[4.2] - def change - change_column_null :todos, :target_id, true - end -end diff --git a/db/migrate/20160316204731_add_commit_id_to_todos.rb b/db/migrate/20160316204731_add_commit_id_to_todos.rb deleted file mode 100644 index d1c004b2ced..00000000000 --- a/db/migrate/20160316204731_add_commit_id_to_todos.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddCommitIdToTodos < ActiveRecord::Migration[4.2] - def change - add_column :todos, :commit_id, :string - add_index :todos, :commit_id - end -end diff --git a/db/migrate/20160317092222_add_moved_to_to_issue.rb b/db/migrate/20160317092222_add_moved_to_to_issue.rb deleted file mode 100644 index 8d81d84fd20..00000000000 --- a/db/migrate/20160317092222_add_moved_to_to_issue.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMovedToToIssue < ActiveRecord::Migration[4.2] - def change - add_reference :issues, :moved_to, references: :issues # rubocop:disable Migration/AddReference - end -end diff --git a/db/migrate/20160320204112_index_namespaces_on_visibility_level.rb b/db/migrate/20160320204112_index_namespaces_on_visibility_level.rb deleted file mode 100644 index 9692def430c..00000000000 --- a/db/migrate/20160320204112_index_namespaces_on_visibility_level.rb +++ /dev/null @@ -1,8 +0,0 @@ -# rubocop:disable all -class IndexNamespacesOnVisibilityLevel < ActiveRecord::Migration[4.2] - def change - unless index_exists?(:namespaces, :visibility_level) - add_index :namespaces, :visibility_level - end - end -end diff --git a/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb b/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb deleted file mode 100644 index a25d15a81ef..00000000000 --- a/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb +++ /dev/null @@ -1,17 +0,0 @@ -class RemoveTodosForDeletedIssues < ActiveRecord::Migration[4.2] - def up - execute <<-SQL - DELETE FROM todos - WHERE todos.target_type = 'Issue' - AND NOT EXISTS ( - SELECT * - FROM issues - WHERE issues.id = todos.target_id - AND issues.deleted_at IS NULL - ) - SQL - end - - def down - end -end diff --git a/db/migrate/20160328112808_create_notification_settings.rb b/db/migrate/20160328112808_create_notification_settings.rb deleted file mode 100644 index db19d2e370c..00000000000 --- a/db/migrate/20160328112808_create_notification_settings.rb +++ /dev/null @@ -1,12 +0,0 @@ -# rubocop:disable all -class CreateNotificationSettings < ActiveRecord::Migration[4.2] - def change - create_table :notification_settings do |t| - t.references :user, null: false - t.references :source, polymorphic: true, null: false - t.integer :level, default: 0, null: false - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160328115649_migrate_new_notification_setting.rb b/db/migrate/20160328115649_migrate_new_notification_setting.rb deleted file mode 100644 index 5ba09e75145..00000000000 --- a/db/migrate/20160328115649_migrate_new_notification_setting.rb +++ /dev/null @@ -1,17 +0,0 @@ -# This migration will create one row of NotificationSetting for each Member row -# It can take long time on big instances. -# -# This migration can be done online but with following effects: -# - during migration some users will receive notifications based on their global settings (project/group settings will be ignored) -# - its possible to get duplicate records for notification settings since we don't create uniq index yet -# -class MigrateNewNotificationSetting < ActiveRecord::Migration[4.2] - def up - timestamp = Time.now.strftime('%F %T') - execute "INSERT INTO notification_settings ( user_id, source_id, source_type, level, created_at, updated_at ) SELECT user_id, source_id, source_type, notification_level, '#{timestamp}', '#{timestamp}' FROM members WHERE user_id IS NOT NULL" - end - - def down - execute "DELETE FROM notification_settings" - end -end diff --git a/db/migrate/20160328121138_add_notification_setting_index.rb b/db/migrate/20160328121138_add_notification_setting_index.rb deleted file mode 100644 index ed82b172296..00000000000 --- a/db/migrate/20160328121138_add_notification_setting_index.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddNotificationSettingIndex < ActiveRecord::Migration[4.2] - def change - add_index :notification_settings, :user_id - add_index :notification_settings, [:source_id, :source_type] - end -end diff --git a/db/migrate/20160329144452_add_index_on_pending_delete_projects.rb b/db/migrate/20160329144452_add_index_on_pending_delete_projects.rb deleted file mode 100644 index 15c44f74451..00000000000 --- a/db/migrate/20160329144452_add_index_on_pending_delete_projects.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable all -class AddIndexOnPendingDeleteProjects < ActiveRecord::Migration[4.2] - def change - add_index :projects, :pending_delete - end -end - diff --git a/db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb b/db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb deleted file mode 100644 index 634a696377c..00000000000 --- a/db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb +++ /dev/null @@ -1,17 +0,0 @@ -class RemoveTodosForDeletedMergeRequests < ActiveRecord::Migration[4.2] - def up - execute <<-SQL - DELETE FROM todos - WHERE todos.target_type = 'MergeRequest' - AND NOT EXISTS ( - SELECT * - FROM merge_requests - WHERE merge_requests.id = todos.target_id - AND merge_requests.deleted_at IS NULL - ) - SQL - end - - def down - end -end diff --git a/db/migrate/20160331223143_remove_twitter_sharing_enabled_from_application_settings.rb b/db/migrate/20160331223143_remove_twitter_sharing_enabled_from_application_settings.rb deleted file mode 100644 index 6e5a748d096..00000000000 --- a/db/migrate/20160331223143_remove_twitter_sharing_enabled_from_application_settings.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class RemoveTwitterSharingEnabledFromApplicationSettings < ActiveRecord::Migration[4.2] - def change - remove_column :application_settings, :twitter_sharing_enabled, :boolean - end -end diff --git a/db/migrate/20160407120251_add_images_enabled_for_project.rb b/db/migrate/20160407120251_add_images_enabled_for_project.rb deleted file mode 100644 index 2c42d89ccdf..00000000000 --- a/db/migrate/20160407120251_add_images_enabled_for_project.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddImagesEnabledForProject < ActiveRecord::Migration[4.2] - def change - add_column :projects, :container_registry_enabled, :boolean - end -end diff --git a/db/migrate/20160412140240_add_repository_checks_enabled_setting.rb b/db/migrate/20160412140240_add_repository_checks_enabled_setting.rb deleted file mode 100644 index a59563b835e..00000000000 --- a/db/migrate/20160412140240_add_repository_checks_enabled_setting.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class AddRepositoryChecksEnabledSetting < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :repository_checks_enabled, :boolean, default: true - end -end diff --git a/db/migrate/20160412173416_add_fields_to_ci_commit.rb b/db/migrate/20160412173416_add_fields_to_ci_commit.rb deleted file mode 100644 index 4b3d4e8bd30..00000000000 --- a/db/migrate/20160412173416_add_fields_to_ci_commit.rb +++ /dev/null @@ -1,9 +0,0 @@ -# rubocop:disable all -class AddFieldsToCiCommit < ActiveRecord::Migration[4.2] - def change - add_column :ci_commits, :status, :string - add_column :ci_commits, :started_at, :timestamp - add_column :ci_commits, :finished_at, :timestamp - add_column :ci_commits, :duration, :integer - end -end diff --git a/db/migrate/20160412173417_update_ci_commit.rb b/db/migrate/20160412173417_update_ci_commit.rb deleted file mode 100644 index 91dd4582f7a..00000000000 --- a/db/migrate/20160412173417_update_ci_commit.rb +++ /dev/null @@ -1,36 +0,0 @@ -# rubocop:disable all -class UpdateCiCommit < ActiveRecord::Migration[4.2] - # This migration can be run online, but needs to be executed for the second time after restarting Unicorn workers - # Otherwise Offline migration should be used. - def change - execute("UPDATE ci_commits SET status=#{status}, ref=#{ref}, tag=#{tag} WHERE status IS NULL") - end - - private - - def status - builds = '(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id)' - success = "(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='success')" - ignored = "(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND (status='failed' OR status='canceled') AND allow_failure)" - pending = "(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='pending')" - running = "(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='running')" - canceled = "(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='canceled')" - - "(CASE - WHEN #{builds}=0 THEN 'skipped' - WHEN #{builds}=#{success}+#{ignored} THEN 'success' - WHEN #{builds}=#{pending} THEN 'pending' - WHEN #{builds}=#{canceled} THEN 'canceled' - WHEN #{running}+#{pending}>0 THEN 'running' - ELSE 'failed' - END)" - end - - def ref - '(SELECT ref FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id ORDER BY id DESC LIMIT 1)' - end - - def tag - '(SELECT tag FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id ORDER BY id DESC LIMIT 1)' - end -end diff --git a/db/migrate/20160412173418_add_ci_commit_indexes.rb b/db/migrate/20160412173418_add_ci_commit_indexes.rb deleted file mode 100644 index 709e6b84d57..00000000000 --- a/db/migrate/20160412173418_add_ci_commit_indexes.rb +++ /dev/null @@ -1,20 +0,0 @@ -# rubocop:disable all -class AddCiCommitIndexes < ActiveRecord::Migration[4.2] - disable_ddl_transaction! - - def change - add_index :ci_commits, [:gl_project_id, :sha], index_options - add_index :ci_commits, [:gl_project_id, :status], index_options - add_index :ci_commits, [:status], index_options - end - - private - - def index_options - if Gitlab::Database.postgresql? - { algorithm: :concurrently } - else - { } - end - end -end diff --git a/db/migrate/20160413115152_add_token_to_web_hooks.rb b/db/migrate/20160413115152_add_token_to_web_hooks.rb deleted file mode 100644 index 43fe46dfe5d..00000000000 --- a/db/migrate/20160413115152_add_token_to_web_hooks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTokenToWebHooks < ActiveRecord::Migration[4.2] - def change - add_column :web_hooks, :token, :string - end -end diff --git a/db/migrate/20160415062917_create_personal_access_tokens.rb b/db/migrate/20160415062917_create_personal_access_tokens.rb deleted file mode 100644 index 43599db799e..00000000000 --- a/db/migrate/20160415062917_create_personal_access_tokens.rb +++ /dev/null @@ -1,14 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreatePersonalAccessTokens < ActiveRecord::Migration[4.2] - def change - create_table :personal_access_tokens do |t| - t.references :user, index: true, foreign_key: true, null: false - t.string :token, index: { unique: true }, null: false - t.string :name, null: false - t.boolean :revoked, default: false - t.datetime :expires_at - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160415133440_add_shared_runners_text_to_application_settings.rb b/db/migrate/20160415133440_add_shared_runners_text_to_application_settings.rb deleted file mode 100644 index e96c0591a07..00000000000 --- a/db/migrate/20160415133440_add_shared_runners_text_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddSharedRunnersTextToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :shared_runners_text, :text - end -end diff --git a/db/migrate/20160416180807_add_award_emoji.rb b/db/migrate/20160416180807_add_award_emoji.rb deleted file mode 100644 index 99c984fd116..00000000000 --- a/db/migrate/20160416180807_add_award_emoji.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable all -class AddAwardEmoji < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :award_emoji do |t| - t.string :name - t.references :user - t.references :awardable, polymorphic: true - - t.timestamps null: true - end - - add_index :award_emoji, :user_id - add_index :award_emoji, [:awardable_type, :awardable_id] - end -end diff --git a/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb b/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb deleted file mode 100644 index af2820986f0..00000000000 --- a/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb +++ /dev/null @@ -1,36 +0,0 @@ -class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration[4.2] - disable_ddl_transaction! - - def up - if Gitlab::Database.postgresql? - migrate_postgresql - else - migrate_mysql - end - end - - def down - add_column :notes, :is_award, :boolean - - # This migration does NOT move the awards on notes, if the table is dropped in another migration, these notes will be lost. - execute "INSERT INTO notes (noteable_type, noteable_id, author_id, note, created_at, updated_at, is_award) (SELECT awardable_type, awardable_id, user_id, name, created_at, updated_at, TRUE FROM award_emoji)" - end - - def migrate_postgresql - connection.transaction do - execute 'LOCK notes IN EXCLUSIVE MODE' - execute "INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true)" - execute "DELETE FROM notes WHERE is_award = true" - remove_column :notes, :is_award, :boolean - end - end - - def migrate_mysql - execute 'LOCK TABLES notes WRITE, award_emoji WRITE;' - execute 'INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true);' - execute "DELETE FROM notes WHERE is_award = true" - remove_column :notes, :is_award, :boolean - ensure - execute 'UNLOCK TABLES' - end -end diff --git a/db/migrate/20160419120017_add_metrics_packet_size.rb b/db/migrate/20160419120017_add_metrics_packet_size.rb deleted file mode 100644 index 16c3ebfe22b..00000000000 --- a/db/migrate/20160419120017_add_metrics_packet_size.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMetricsPacketSize < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :metrics_packet_size, :integer, default: 1 - end -end diff --git a/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb b/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb deleted file mode 100644 index cf842a684a6..00000000000 --- a/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb +++ /dev/null @@ -1,16 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class AddOnlyAllowMergeIfBuildSucceedsToProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - add_column_with_default(:projects, - :only_allow_merge_if_build_succeeds, - :boolean, - default: false) - end - - def down - remove_column(:projects, :only_allow_merge_if_build_succeeds) - end -end diff --git a/db/migrate/20160421130527_disable_repository_checks.rb b/db/migrate/20160421130527_disable_repository_checks.rb deleted file mode 100644 index 8b3ce73c5e8..00000000000 --- a/db/migrate/20160421130527_disable_repository_checks.rb +++ /dev/null @@ -1,12 +0,0 @@ -# rubocop:disable all -class DisableRepositoryChecks < ActiveRecord::Migration[4.2] - def up - change_column_default :application_settings, :repository_checks_enabled, false - execute 'UPDATE application_settings SET repository_checks_enabled = false' - end - - def down - change_column_default :application_settings, :repository_checks_enabled, true - execute 'UPDATE application_settings SET repository_checks_enabled = true' - end -end diff --git a/db/migrate/20160425045124_create_u2f_registrations.rb b/db/migrate/20160425045124_create_u2f_registrations.rb deleted file mode 100644 index 9b48fc822b6..00000000000 --- a/db/migrate/20160425045124_create_u2f_registrations.rb +++ /dev/null @@ -1,14 +0,0 @@ -# rubocop:disable all -class CreateU2fRegistrations < ActiveRecord::Migration[4.2] - def change - create_table :u2f_registrations do |t| - t.text :certificate - t.string :key_handle, index: true - t.string :public_key - t.integer :counter - t.references :user, index: true, foreign_key: true - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160504091942_add_disabled_oauth_sign_in_sources_to_application_settings.rb b/db/migrate/20160504091942_add_disabled_oauth_sign_in_sources_to_application_settings.rb deleted file mode 100644 index 9a0d1a2d316..00000000000 --- a/db/migrate/20160504091942_add_disabled_oauth_sign_in_sources_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDisabledOauthSignInSourcesToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :disabled_oauth_sign_in_sources, :text - end -end diff --git a/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb b/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb deleted file mode 100644 index 03ec29b9951..00000000000 --- a/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddRunUntaggedToCiRunner < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - add_column_with_default(:ci_runners, :run_untagged, :boolean, - default: true, allow_null: false) - end - - def down - remove_column(:ci_runners, :run_untagged) - end -end diff --git a/db/migrate/20160508194200_remove_wall_enabled_from_projects.rb b/db/migrate/20160508194200_remove_wall_enabled_from_projects.rb deleted file mode 100644 index 4edbeb09f74..00000000000 --- a/db/migrate/20160508194200_remove_wall_enabled_from_projects.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class RemoveWallEnabledFromProjects < ActiveRecord::Migration[4.2] - def change - remove_column :projects, :wall_enabled, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20160508202603_add_head_commit_id_to_merge_request_diffs.rb b/db/migrate/20160508202603_add_head_commit_id_to_merge_request_diffs.rb deleted file mode 100644 index ee7c9326bfe..00000000000 --- a/db/migrate/20160508202603_add_head_commit_id_to_merge_request_diffs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddHeadCommitIdToMergeRequestDiffs < ActiveRecord::Migration[4.2] - def change - add_column :merge_request_diffs, :head_commit_sha, :string - end -end diff --git a/db/migrate/20160508215820_add_type_to_notes.rb b/db/migrate/20160508215820_add_type_to_notes.rb deleted file mode 100644 index 343743a589c..00000000000 --- a/db/migrate/20160508215820_add_type_to_notes.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTypeToNotes < ActiveRecord::Migration[4.2] - def change - add_column :notes, :type, :string - end -end diff --git a/db/migrate/20160508215920_add_positions_to_diff_notes.rb b/db/migrate/20160508215920_add_positions_to_diff_notes.rb deleted file mode 100644 index e0ee03d0fb5..00000000000 --- a/db/migrate/20160508215920_add_positions_to_diff_notes.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddPositionsToDiffNotes < ActiveRecord::Migration[4.2] - def change - add_column :notes, :position, :text - add_column :notes, :original_position, :text - end -end diff --git a/db/migrate/20160508221410_set_type_on_legacy_diff_notes.rb b/db/migrate/20160508221410_set_type_on_legacy_diff_notes.rb deleted file mode 100644 index 567754d4f4e..00000000000 --- a/db/migrate/20160508221410_set_type_on_legacy_diff_notes.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable all -class SetTypeOnLegacyDiffNotes < ActiveRecord::Migration[4.2] - def change - execute "UPDATE notes SET type = 'LegacyDiffNote' WHERE line_code IS NOT NULL" - end -end diff --git a/db/migrate/20160509091049_add_locked_to_ci_runner.rb b/db/migrate/20160509091049_add_locked_to_ci_runner.rb deleted file mode 100644 index e19db5a4504..00000000000 --- a/db/migrate/20160509091049_add_locked_to_ci_runner.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddLockedToCiRunner < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - add_column_with_default(:ci_runners, :locked, :boolean, - default: false, allow_null: false) - end - - def down - remove_column(:ci_runners, :locked) - end -end diff --git a/db/migrate/20160509201028_add_health_check_access_token_to_application_settings.rb b/db/migrate/20160509201028_add_health_check_access_token_to_application_settings.rb deleted file mode 100644 index 54d615f7e21..00000000000 --- a/db/migrate/20160509201028_add_health_check_access_token_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddHealthCheckAccessTokenToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :health_check_access_token, :string - end -end diff --git a/db/migrate/20160516174813_add_send_user_confirmation_email_to_application_settings.rb b/db/migrate/20160516174813_add_send_user_confirmation_email_to_application_settings.rb deleted file mode 100644 index 9e203b97a43..00000000000 --- a/db/migrate/20160516174813_add_send_user_confirmation_email_to_application_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# rubocop:disable all -class AddSendUserConfirmationEmailToApplicationSettings < ActiveRecord::Migration[4.2] - def up - add_column :application_settings, :send_user_confirmation_email, :boolean, default: false - - #Sets confirmation email to true by default on existing installations. - execute "UPDATE application_settings SET send_user_confirmation_email=true" - end - - def down - remove_column :application_settings, :send_user_confirmation_email - end -end diff --git a/db/migrate/20160516224534_add_start_commit_id_to_merge_request_diffs.rb b/db/migrate/20160516224534_add_start_commit_id_to_merge_request_diffs.rb deleted file mode 100644 index a84bfd64bda..00000000000 --- a/db/migrate/20160516224534_add_start_commit_id_to_merge_request_diffs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddStartCommitIdToMergeRequestDiffs < ActiveRecord::Migration[4.2] - def change - add_column :merge_request_diffs, :start_commit_sha, :string - end -end diff --git a/db/migrate/20160518200441_add_artifacts_expire_date_to_ci_builds.rb b/db/migrate/20160518200441_add_artifacts_expire_date_to_ci_builds.rb deleted file mode 100644 index 143b84a1662..00000000000 --- a/db/migrate/20160518200441_add_artifacts_expire_date_to_ci_builds.rb +++ /dev/null @@ -1,6 +0,0 @@ -# rubocop:disable Migration/Datetime -class AddArtifactsExpireDateToCiBuilds < ActiveRecord::Migration[4.2] - def change - add_column :ci_builds, :artifacts_expire_at, :timestamp - end -end diff --git a/db/migrate/20160519203051_add_developers_can_merge_to_protected_branches.rb b/db/migrate/20160519203051_add_developers_can_merge_to_protected_branches.rb deleted file mode 100644 index ba0e1654379..00000000000 --- a/db/migrate/20160519203051_add_developers_can_merge_to_protected_branches.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddDevelopersCanMergeToProtectedBranches < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :protected_branches, :developers_can_merge, :boolean, default: false, allow_null: false - end - - def down - remove_column :protected_branches, :developers_can_merge - end -end diff --git a/db/migrate/20160522215720_add_note_type_and_position_to_sent_notification.rb b/db/migrate/20160522215720_add_note_type_and_position_to_sent_notification.rb deleted file mode 100644 index f569fc7c73f..00000000000 --- a/db/migrate/20160522215720_add_note_type_and_position_to_sent_notification.rb +++ /dev/null @@ -1,22 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddNoteTypeAndPositionToSentNotification < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # When using the methods "add_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" make sure that this - # method 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 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 :sent_notifications, :note_type, :string - add_column :sent_notifications, :position, :text - end -end diff --git a/db/migrate/20160525205328_remove_main_language_from_projects.rb b/db/migrate/20160525205328_remove_main_language_from_projects.rb deleted file mode 100644 index 81d0fb5b080..00000000000 --- a/db/migrate/20160525205328_remove_main_language_from_projects.rb +++ /dev/null @@ -1,22 +0,0 @@ -# rubocop:disable all -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveMainLanguageFromProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - remove_column :projects, :main_language - end -end diff --git a/db/migrate/20160527020117_remove_notification_settings_for_deleted_projects.rb b/db/migrate/20160527020117_remove_notification_settings_for_deleted_projects.rb deleted file mode 100644 index c530c09859d..00000000000 --- a/db/migrate/20160527020117_remove_notification_settings_for_deleted_projects.rb +++ /dev/null @@ -1,13 +0,0 @@ -class RemoveNotificationSettingsForDeletedProjects < ActiveRecord::Migration[4.2] - def up - execute <<-SQL - DELETE FROM notification_settings - WHERE notification_settings.source_type = 'Project' - AND NOT EXISTS ( - SELECT * - FROM projects - WHERE projects.id = notification_settings.source_id - ) - SQL - end -end diff --git a/db/migrate/20160528043124_add_users_state_index.rb b/db/migrate/20160528043124_add_users_state_index.rb deleted file mode 100644 index 3437b35a0c0..00000000000 --- a/db/migrate/20160528043124_add_users_state_index.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable all -class AddUsersStateIndex < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def change - add_concurrent_index :users, :state - end -end diff --git a/db/migrate/20160530150109_add_container_registry_token_expire_delay_to_application_settings.rb b/db/migrate/20160530150109_add_container_registry_token_expire_delay_to_application_settings.rb deleted file mode 100644 index 7b20146e21c..00000000000 --- a/db/migrate/20160530150109_add_container_registry_token_expire_delay_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# This is ONLINE migration - -class AddContainerRegistryTokenExpireDelayToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - add_column :application_settings, :container_registry_token_expire_delay, :integer, default: 5 - end -end diff --git a/db/migrate/20160603075128_add_has_external_issue_tracker_to_projects.rb b/db/migrate/20160603075128_add_has_external_issue_tracker_to_projects.rb deleted file mode 100644 index a7d2d7f9952..00000000000 --- a/db/migrate/20160603075128_add_has_external_issue_tracker_to_projects.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 AddHasExternalIssueTrackerToProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - add_column(:projects, :has_external_issue_tracker, :boolean) - end -end diff --git a/db/migrate/20160603180330_remove_duplicated_notification_settings.rb b/db/migrate/20160603180330_remove_duplicated_notification_settings.rb deleted file mode 100644 index 0d8c4bf011c..00000000000 --- a/db/migrate/20160603180330_remove_duplicated_notification_settings.rb +++ /dev/null @@ -1,32 +0,0 @@ -class RemoveDuplicatedNotificationSettings < ActiveRecord::Migration[4.2] - def up - duplicates = exec_query(%Q{ - SELECT user_id, source_type, source_id - FROM notification_settings - GROUP BY user_id, source_type, source_id - HAVING COUNT(*) > 1 - }) - - duplicates.each do |row| - uid = row['user_id'] - stype = connection.quote(row['source_type']) - sid = row['source_id'] - - execute(%Q{ - DELETE FROM notification_settings - WHERE user_id = #{uid} - AND source_type = #{stype} - AND source_id = #{sid} - AND id != ( - SELECT id FROM ( - SELECT min(id) AS id - FROM notification_settings - WHERE user_id = #{uid} - AND source_type = #{stype} - AND source_id = #{sid} - ) min_ids - ) - }) - end - end -end diff --git a/db/migrate/20160603182247_add_index_to_notification_settings.rb b/db/migrate/20160603182247_add_index_to_notification_settings.rb deleted file mode 100644 index cea178d555c..00000000000 --- a/db/migrate/20160603182247_add_index_to_notification_settings.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable all -class AddIndexToNotificationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def change - add_concurrent_index :notification_settings, [:user_id, :source_id, :source_type], { unique: true, name: "index_notifications_on_user_id_and_source_id_and_source_type" } - end -end diff --git a/db/migrate/20160608155312_add_after_sign_up_text_to_application_settings.rb b/db/migrate/20160608155312_add_after_sign_up_text_to_application_settings.rb deleted file mode 100644 index 3b3f68529a5..00000000000 --- a/db/migrate/20160608155312_add_after_sign_up_text_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAfterSignUpTextToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :after_sign_up_text, :text - end -end diff --git a/db/migrate/20160608195742_add_repository_storage_to_projects.rb b/db/migrate/20160608195742_add_repository_storage_to_projects.rb deleted file mode 100644 index 2b20c9fbd5f..00000000000 --- a/db/migrate/20160608195742_add_repository_storage_to_projects.rb +++ /dev/null @@ -1,13 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class AddRepositoryStorageToProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - add_column_with_default(:projects, :repository_storage, :string, default: 'default') - end - - def down - remove_column(:projects, :repository_storage) - end -end diff --git a/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb b/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb deleted file mode 100644 index 9b5cfc67d5a..00000000000 --- a/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddUserDefaultExternalToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - add_column_with_default(:application_settings, :user_default_external, :boolean, - default: false, allow_null: false) - end - - def down - remove_column(:application_settings, :user_default_external) - end -end diff --git a/db/migrate/20160610140403_remove_notification_setting_not_null_constraints.rb b/db/migrate/20160610140403_remove_notification_setting_not_null_constraints.rb deleted file mode 100644 index d5301672dc5..00000000000 --- a/db/migrate/20160610140403_remove_notification_setting_not_null_constraints.rb +++ /dev/null @@ -1,11 +0,0 @@ -class RemoveNotificationSettingNotNullConstraints < ActiveRecord::Migration[4.2] - def up - change_column :notification_settings, :source_type, :string, null: true - change_column :notification_settings, :source_id, :integer, null: true - end - - def down - change_column :notification_settings, :source_type, :string, null: false - change_column :notification_settings, :source_id, :integer, null: false - end -end diff --git a/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb b/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb deleted file mode 100644 index 1ac65997403..00000000000 --- a/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -class RemoveDeprecatedIssuesTrackerColumnsFromProjects < ActiveRecord::Migration[4.2] - def change - remove_column :projects, :issues_tracker, :string, default: 'gitlab', null: false - remove_column :projects, :issues_tracker_id, :string - end -end diff --git a/db/migrate/20160610201627_migrate_users_notification_level.rb b/db/migrate/20160610201627_migrate_users_notification_level.rb deleted file mode 100644 index 553b7f074f2..00000000000 --- a/db/migrate/20160610201627_migrate_users_notification_level.rb +++ /dev/null @@ -1,25 +0,0 @@ -class MigrateUsersNotificationLevel < ActiveRecord::Migration[4.2] - DOWNTIME = false - - # Migrates only users who changed their default notification level :participating - # creating a new record on notification settings table - - DOWNTIME = false - - def up - execute(%Q{ - INSERT INTO notification_settings - (user_id, level, created_at, updated_at) - (SELECT id, notification_level, created_at, updated_at FROM users WHERE notification_level != 1) - }) - end - - # Migrates from notification settings back to user notification_level - # If no value is found the default level of 1 will be used - def down - execute(%Q{ - UPDATE users u SET - notification_level = COALESCE((SELECT level FROM notification_settings WHERE user_id = u.id AND source_type IS NULL), 1) - }) - end -end diff --git a/db/migrate/20160610204157_add_deployments.rb b/db/migrate/20160610204157_add_deployments.rb deleted file mode 100644 index 91b619e7d3d..00000000000 --- a/db/migrate/20160610204157_add_deployments.rb +++ /dev/null @@ -1,26 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. -class AddDeployments < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - create_table :deployments, force: true do |t| - t.integer :iid, null: false - t.integer :project_id, null: false - t.integer :environment_id, null: false - t.string :ref, null: false - t.boolean :tag, null: false - t.string :sha, null: false - t.integer :user_id - t.integer :deployable_id - t.string :deployable_type - t.datetime :created_at - t.datetime :updated_at - end - - add_index :deployments, :project_id - add_index :deployments, [:project_id, :iid], unique: true - add_index :deployments, [:project_id, :environment_id] - add_index :deployments, [:project_id, :environment_id, :iid] - end -end diff --git a/db/migrate/20160610204158_add_environments.rb b/db/migrate/20160610204158_add_environments.rb deleted file mode 100644 index 55fb8b1227b..00000000000 --- a/db/migrate/20160610204158_add_environments.rb +++ /dev/null @@ -1,16 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. -class AddEnvironments < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - create_table :environments, force: true do |t| - t.integer :project_id, null: false - t.string :name, null: false - t.datetime :created_at - t.datetime :updated_at - end - - add_index :environments, [:project_id, :name] - end -end diff --git a/db/migrate/20160610211845_add_environment_to_builds.rb b/db/migrate/20160610211845_add_environment_to_builds.rb deleted file mode 100644 index 16d5465cafa..00000000000 --- a/db/migrate/20160610211845_add_environment_to_builds.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 AddEnvironmentToBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - add_column :ci_builds, :environment, :string - end -end diff --git a/db/migrate/20160610301627_remove_notification_level_from_users.rb b/db/migrate/20160610301627_remove_notification_level_from_users.rb deleted file mode 100644 index 93f70c476d2..00000000000 --- a/db/migrate/20160610301627_remove_notification_level_from_users.rb +++ /dev/null @@ -1,8 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -class RemoveNotificationLevelFromUsers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - remove_column :users, :notification_level, :integer - end -end diff --git a/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb b/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb deleted file mode 100644 index a1bc0e5cd86..00000000000 --- a/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRepositoryStorageToApplicationSettings < ActiveRecord::Migration[4.2] - def change - add_column :application_settings, :repository_storage, :string, default: 'default' - end -end diff --git a/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb b/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb deleted file mode 100644 index 1b1dab141f8..00000000000 --- a/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb +++ /dev/null @@ -1,16 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexOnRequestedAtToMembers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :members, :requested_at - end - - def down - remove_index :members, :requested_at if index_exists? :members, :requested_at - end -end diff --git a/db/migrate/20160615173316_add_enabled_git_access_protocols_to_application_settings.rb b/db/migrate/20160615173316_add_enabled_git_access_protocols_to_application_settings.rb deleted file mode 100644 index deb4b86a2fd..00000000000 --- a/db/migrate/20160615173316_add_enabled_git_access_protocols_to_application_settings.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 AddEnabledGitAccessProtocolsToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - add_column :application_settings, :enabled_git_access_protocol, :string - end -end diff --git a/db/migrate/20160615191922_set_missing_stage_on_ci_builds.rb b/db/migrate/20160615191922_set_missing_stage_on_ci_builds.rb deleted file mode 100644 index 11d15e7c15f..00000000000 --- a/db/migrate/20160615191922_set_missing_stage_on_ci_builds.rb +++ /dev/null @@ -1,13 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -# rubocop:disable Migration/UpdateColumnInBatches -class SetMissingStageOnCiBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - update_column_in_batches(:ci_builds, :stage, :test) do |table, query| - query.where(table[:stage].eq(nil)) - end - end -end diff --git a/db/migrate/20160616084004_change_project_of_environment.rb b/db/migrate/20160616084004_change_project_of_environment.rb deleted file mode 100644 index 23914a0325a..00000000000 --- a/db/migrate/20160616084004_change_project_of_environment.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class ChangeProjectOfEnvironment < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - change_column_null :environments, :project_id, true - end -end diff --git a/db/migrate/20160616102642_remove_duplicated_keys.rb b/db/migrate/20160616102642_remove_duplicated_keys.rb deleted file mode 100644 index 0b896108292..00000000000 --- a/db/migrate/20160616102642_remove_duplicated_keys.rb +++ /dev/null @@ -1,18 +0,0 @@ -class RemoveDuplicatedKeys < ActiveRecord::Migration[4.2] - def up - select_all("SELECT fingerprint FROM #{quote_table_name(:keys)} GROUP BY fingerprint HAVING COUNT(*) > 1").each do |row| - fingerprint = connection.quote(row['fingerprint']) - execute(%Q{ - DELETE FROM #{quote_table_name(:keys)} - WHERE fingerprint = #{fingerprint} - AND id != ( - SELECT id FROM ( - SELECT max(id) AS id - FROM #{quote_table_name(:keys)} - WHERE fingerprint = #{fingerprint} - ) max_ids - ) - }) - end - end -end diff --git a/db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb b/db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb deleted file mode 100644 index afccc40cc67..00000000000 --- a/db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb +++ /dev/null @@ -1,22 +0,0 @@ -# rubocop:disable RemoveIndex -class RemoveKeysFingerprintIndexIfExists < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - # https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/250 - # That MR was added on gitlab-ee so we need to check if the index - # already exists because we want to do is create an unique index instead. - - def up - if index_exists?(:keys, :fingerprint) - remove_index :keys, :fingerprint - end - end - - def down - unless index_exists?(:keys, :fingerprint) - add_concurrent_index :keys, :fingerprint - end - end -end diff --git a/db/migrate/20160616103948_add_unique_index_to_keys_fingerprint.rb b/db/migrate/20160616103948_add_unique_index_to_keys_fingerprint.rb deleted file mode 100644 index d619acad3d0..00000000000 --- a/db/migrate/20160616103948_add_unique_index_to_keys_fingerprint.rb +++ /dev/null @@ -1,14 +0,0 @@ -# rubocop:disable RemoveIndex -class AddUniqueIndexToKeysFingerprint < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_index :keys, :fingerprint, unique: true - end - - def down - remove_index :keys, :fingerprint - end -end diff --git a/db/migrate/20160617301627_add_events_to_notification_settings.rb b/db/migrate/20160617301627_add_events_to_notification_settings.rb deleted file mode 100644 index 109817e3d8a..00000000000 --- a/db/migrate/20160617301627_add_events_to_notification_settings.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddEventsToNotificationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - add_column :notification_settings, :events, :text - end -end diff --git a/db/migrate/20160620115026_add_index_on_runners_locked.rb b/db/migrate/20160620115026_add_index_on_runners_locked.rb deleted file mode 100644 index c619dc07a91..00000000000 --- a/db/migrate/20160620115026_add_index_on_runners_locked.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddIndexOnRunnersLocked < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_runners, :locked - end - - def down - remove_index :ci_runners, :locked if index_exists? :ci_runners, :locked - end -end diff --git a/db/migrate/20160621123729_add_rebase_commit_sha_to_merge_requests.rb b/db/migrate/20160621123729_add_rebase_commit_sha_to_merge_requests.rb deleted file mode 100644 index 2d3ab4e2583..00000000000 --- a/db/migrate/20160621123729_add_rebase_commit_sha_to_merge_requests.rb +++ /dev/null @@ -1,22 +0,0 @@ -# This migration is a duplicate of 20171230123729_add_rebase_commit_sha_to_merge_requests_ce.rb -# -# We backported this feature from EE using the same migration, but with a new -# timestamp, which caused an error when the backport was then to be merged back -# into EE. -# -# See discussion at https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/3932 -class AddRebaseCommitShaToMergeRequests < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - unless column_exists?(:merge_requests, :rebase_commit_sha) - add_column :merge_requests, :rebase_commit_sha, :string - end - end - - def down - if column_exists?(:merge_requests, :rebase_commit_sha) - remove_column :merge_requests, :rebase_commit_sha - end - end -end diff --git a/db/migrate/20160628085157_add_artifacts_size_to_ci_builds.rb b/db/migrate/20160628085157_add_artifacts_size_to_ci_builds.rb deleted file mode 100644 index 60bd4c36eb6..00000000000 --- a/db/migrate/20160628085157_add_artifacts_size_to_ci_builds.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddArtifactsSizeToCiBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - add_column(:ci_builds, :artifacts_size, :integer) - end -end diff --git a/db/migrate/20160629025435_add_column_in_progress_merge_commit_sha_to_merge_requests.rb b/db/migrate/20160629025435_add_column_in_progress_merge_commit_sha_to_merge_requests.rb deleted file mode 100644 index 13e1280b71a..00000000000 --- a/db/migrate/20160629025435_add_column_in_progress_merge_commit_sha_to_merge_requests.rb +++ /dev/null @@ -1,8 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddColumnInProgressMergeCommitShaToMergeRequests < ActiveRecord::Migration[4.2] - def change - add_column :merge_requests, :in_progress_merge_commit_sha, :string - end -end diff --git a/db/migrate/20160703180340_add_index_on_award_emoji_user_and_name.rb b/db/migrate/20160703180340_add_index_on_award_emoji_user_and_name.rb deleted file mode 100644 index 8a576b99de0..00000000000 --- a/db/migrate/20160703180340_add_index_on_award_emoji_user_and_name.rb +++ /dev/null @@ -1,11 +0,0 @@ -# rubocop:disable all -# Migration type: online without errors - -class AddIndexOnAwardEmojiUserAndName < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def change - add_concurrent_index(:award_emoji, [:user_id, :name]) - end -end diff --git a/db/migrate/20160705054938_add_protected_branches_push_access.rb b/db/migrate/20160705054938_add_protected_branches_push_access.rb deleted file mode 100644 index 314d90efa90..00000000000 --- a/db/migrate/20160705054938_add_protected_branches_push_access.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/Timestamps -class AddProtectedBranchesPushAccess < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :protected_branch_push_access_levels do |t| - t.references :protected_branch, index: { name: "index_protected_branch_push_access" }, foreign_key: true, null: false - - # Gitlab::Access::MAINTAINER == 40 - t.integer :access_level, default: 40, null: false - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160705054952_add_protected_branches_merge_access.rb b/db/migrate/20160705054952_add_protected_branches_merge_access.rb deleted file mode 100644 index 672e0e291db..00000000000 --- a/db/migrate/20160705054952_add_protected_branches_merge_access.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/Timestamps -class AddProtectedBranchesMergeAccess < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :protected_branch_merge_access_levels do |t| - t.references :protected_branch, index: { name: "index_protected_branch_merge_access" }, foreign_key: true, null: false - - # Gitlab::Access::MAINTAINER == 40 - t.integer :access_level, default: 40, null: false - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb b/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb deleted file mode 100644 index 1bd462cab06..00000000000 --- a/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MoveFromDevelopersCanMergeToProtectedBranchesMergeAccess < ActiveRecord::Migration[4.2] - DOWNTIME = true - DOWNTIME_REASON = <<-HEREDOC - We're creating a `merge_access_level` for each `protected_branch`. If a user creates a `protected_branch` while this - is running, we might be left with a `protected_branch` _without_ an associated `merge_access_level`. The `protected_branches` - table must not change while this is running, so downtime is required. - - https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5081#note_13247410 - HEREDOC - - def up - execute <<-HEREDOC - INSERT into protected_branch_merge_access_levels (protected_branch_id, access_level, created_at, updated_at) - SELECT id, (CASE WHEN developers_can_merge THEN 30 ELSE 40 END), now(), now() - FROM protected_branches - HEREDOC - end - - def down - execute <<-HEREDOC - UPDATE protected_branches SET developers_can_merge = TRUE - WHERE id IN (SELECT protected_branch_id FROM protected_branch_merge_access_levels - WHERE access_level = 30); - HEREDOC - end -end diff --git a/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb b/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb deleted file mode 100644 index d480dac777a..00000000000 --- a/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MoveFromDevelopersCanPushToProtectedBranchesPushAccess < ActiveRecord::Migration[4.2] - DOWNTIME = true - DOWNTIME_REASON = <<-HEREDOC - We're creating a `push_access_level` for each `protected_branch`. If a user creates a `protected_branch` while this - is running, we might be left with a `protected_branch` _without_ an associated `push_access_level`. The `protected_branches` - table must not change while this is running, so downtime is required. - - https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5081#note_13247410 - HEREDOC - - def up - execute <<-HEREDOC - INSERT into protected_branch_push_access_levels (protected_branch_id, access_level, created_at, updated_at) - SELECT id, (CASE WHEN developers_can_push THEN 30 ELSE 40 END), now(), now() - FROM protected_branches - HEREDOC - end - - def down - execute <<-HEREDOC - UPDATE protected_branches SET developers_can_push = TRUE - WHERE id IN (SELECT protected_branch_id FROM protected_branch_push_access_levels - WHERE access_level = 30); - HEREDOC - end -end diff --git a/db/migrate/20160705055809_remove_developers_can_push_from_protected_branches.rb b/db/migrate/20160705055809_remove_developers_can_push_from_protected_branches.rb deleted file mode 100644 index e5c9da072cf..00000000000 --- a/db/migrate/20160705055809_remove_developers_can_push_from_protected_branches.rb +++ /dev/null @@ -1,20 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveDevelopersCanPushFromProtectedBranches < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # This is only required for `#down` - disable_ddl_transaction! - - DOWNTIME = false - - def up - remove_column :protected_branches, :developers_can_push, :boolean - end - - def down - add_column_with_default(:protected_branches, :developers_can_push, :boolean, default: false, allow_null: false) - end -end diff --git a/db/migrate/20160705055813_remove_developers_can_merge_from_protected_branches.rb b/db/migrate/20160705055813_remove_developers_can_merge_from_protected_branches.rb deleted file mode 100644 index 2a623b55839..00000000000 --- a/db/migrate/20160705055813_remove_developers_can_merge_from_protected_branches.rb +++ /dev/null @@ -1,20 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveDevelopersCanMergeFromProtectedBranches < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # This is only required for `#down` - disable_ddl_transaction! - - DOWNTIME = false - - def up - remove_column :protected_branches, :developers_can_merge, :boolean - end - - def down - add_column_with_default(:protected_branches, :developers_can_merge, :boolean, default: false, allow_null: false) - end -end diff --git a/db/migrate/20160705163108_remove_requesters_that_are_owners.rb b/db/migrate/20160705163108_remove_requesters_that_are_owners.rb deleted file mode 100644 index 449c67e1b6a..00000000000 --- a/db/migrate/20160705163108_remove_requesters_that_are_owners.rb +++ /dev/null @@ -1,40 +0,0 @@ -class RemoveRequestersThatAreOwners < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def up - # Delete requesters that are owner of their projects and actually requested - # access to it - execute <<-SQL - DELETE FROM members - WHERE members.source_type = 'Project' - AND members.type = 'ProjectMember' - AND members.requested_at IS NOT NULL - AND members.user_id = ( - SELECT namespaces.owner_id - FROM namespaces - JOIN projects ON namespaces.id = projects.namespace_id - WHERE namespaces.type IS NULL - AND projects.id = members.source_id - AND namespaces.owner_id = members.user_id); - SQL - - # Delete requesters that are owner of their project's group and actually requested - # access to it - execute <<-SQL - DELETE FROM members - WHERE members.source_type = 'Project' - AND members.type = 'ProjectMember' - AND members.requested_at IS NOT NULL - AND members.user_id = ( - SELECT namespaces.owner_id - FROM namespaces - JOIN projects ON namespaces.id = projects.namespace_id - WHERE namespaces.type = 'Group' - AND projects.id = members.source_id - AND namespaces.owner_id = members.user_id); - SQL - end - - def down - end -end diff --git a/db/migrate/20160707104333_add_lock_to_issuables.rb b/db/migrate/20160707104333_add_lock_to_issuables.rb deleted file mode 100644 index fdc3abf46cc..00000000000 --- a/db/migrate/20160707104333_add_lock_to_issuables.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddLockToIssuables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - add_column :issues, :lock_version, :integer - add_column :merge_requests, :lock_version, :integer - end - - def down - remove_column :issues, :lock_version - remove_column :merge_requests, :lock_version - end -end diff --git a/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb b/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb deleted file mode 100644 index 0b553182a81..00000000000 --- a/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveAwardEmojisWithNoUser < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def up - AwardEmoji.joins('LEFT JOIN users ON users.id = user_id').where('users.id IS NULL').destroy_all # rubocop: disable DestroyAll - end -end diff --git a/db/migrate/20160713200638_add_repository_read_only_to_projects.rb b/db/migrate/20160713200638_add_repository_read_only_to_projects.rb deleted file mode 100644 index ba61bc8cbb0..00000000000 --- a/db/migrate/20160713200638_add_repository_read_only_to_projects.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddRepositoryReadOnlyToProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :projects, :repository_read_only, :boolean - end -end diff --git a/db/migrate/20160713205315_add_domain_blacklist_to_application_settings.rb b/db/migrate/20160713205315_add_domain_blacklist_to_application_settings.rb deleted file mode 100644 index 4b9ac12253e..00000000000 --- a/db/migrate/20160713205315_add_domain_blacklist_to_application_settings.rb +++ /dev/null @@ -1,23 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/SaferBooleanColumn -class AddDomainBlacklistToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # When using the methods "add_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" make sure that this - # method 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 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 :application_settings, :domain_blacklist_enabled, :boolean, default: false - add_column :application_settings, :domain_blacklist, :text - end -end diff --git a/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb b/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb deleted file mode 100644 index 7ef02316338..00000000000 --- a/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddUsagePingToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, :usage_ping_enabled, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20160715132507_add_user_id_to_pipeline.rb b/db/migrate/20160715132507_add_user_id_to_pipeline.rb deleted file mode 100644 index b1e22b1c2bb..00000000000 --- a/db/migrate/20160715132507_add_user_id_to_pipeline.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddUserIdToPipeline < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - add_column :ci_commits, :user_id, :integer - end -end diff --git a/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb b/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb deleted file mode 100644 index 8e7ac86a8b7..00000000000 --- a/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb +++ /dev/null @@ -1,16 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexForPipelineUserId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_commits, :user_id - end - - def down - remove_index :ci_commits, :user_id if index_exists? :ci_commits, :user_id - end -end diff --git a/db/migrate/20160715154212_add_request_access_enabled_to_projects.rb b/db/migrate/20160715154212_add_request_access_enabled_to_projects.rb deleted file mode 100644 index 96260f5fd55..00000000000 --- a/db/migrate/20160715154212_add_request_access_enabled_to_projects.rb +++ /dev/null @@ -1,13 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class AddRequestAccessEnabledToProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - add_column_with_default :projects, :request_access_enabled, :boolean, default: true - end - - def down - remove_column :projects, :request_access_enabled - end -end diff --git a/db/migrate/20160715204316_add_request_access_enabled_to_groups.rb b/db/migrate/20160715204316_add_request_access_enabled_to_groups.rb deleted file mode 100644 index 14065434523..00000000000 --- a/db/migrate/20160715204316_add_request_access_enabled_to_groups.rb +++ /dev/null @@ -1,13 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class AddRequestAccessEnabledToGroups < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - add_column_with_default :namespaces, :request_access_enabled, :boolean, default: true - end - - def down - remove_column :namespaces, :request_access_enabled - end -end diff --git a/db/migrate/20160715230841_rename_application_settings_restricted_signup_domains.rb b/db/migrate/20160715230841_rename_application_settings_restricted_signup_domains.rb deleted file mode 100644 index 6a2674fb604..00000000000 --- a/db/migrate/20160715230841_rename_application_settings_restricted_signup_domains.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameApplicationSettingsRestrictedSignupDomains < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - rename_column :application_settings, :restricted_signup_domains, :domain_whitelist - end -end diff --git a/db/migrate/20160716115710_add_when_and_yaml_variables_to_ci_builds.rb b/db/migrate/20160716115710_add_when_and_yaml_variables_to_ci_builds.rb deleted file mode 100644 index d403b0a3cc9..00000000000 --- a/db/migrate/20160716115710_add_when_and_yaml_variables_to_ci_builds.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddWhenAndYamlVariablesToCiBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - add_column :ci_builds, :when, :string - add_column :ci_builds, :yaml_variables, :text - end -end diff --git a/db/migrate/20160716115711_add_queued_at_to_ci_builds.rb b/db/migrate/20160716115711_add_queued_at_to_ci_builds.rb deleted file mode 100644 index 2bb9a30e3a3..00000000000 --- a/db/migrate/20160716115711_add_queued_at_to_ci_builds.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable Migration/Datetime -class AddQueuedAtToCiBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_builds, :queued_at, :timestamp - end -end diff --git a/db/migrate/20160718153603_add_has_external_wiki_to_projects.rb b/db/migrate/20160718153603_add_has_external_wiki_to_projects.rb deleted file mode 100644 index e3e4afaf512..00000000000 --- a/db/migrate/20160718153603_add_has_external_wiki_to_projects.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddHasExternalWikiToProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - def change - add_column :projects, :has_external_wiki, :boolean - end -end diff --git a/db/migrate/20160721081015_drop_and_readd_has_external_wiki_in_projects.rb b/db/migrate/20160721081015_drop_and_readd_has_external_wiki_in_projects.rb deleted file mode 100644 index d31bbb22392..00000000000 --- a/db/migrate/20160721081015_drop_and_readd_has_external_wiki_in_projects.rb +++ /dev/null @@ -1,19 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -# rubocop:disable Migration/UpdateColumnInBatches -class DropAndReaddHasExternalWikiInProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - update_column_in_batches(:projects, :has_external_wiki, nil) do |table, query| - query.where(table[:has_external_wiki].not_eq(nil)) - end - end - - def down - end -end diff --git a/db/migrate/20160722221922_nullify_blank_type_on_notes.rb b/db/migrate/20160722221922_nullify_blank_type_on_notes.rb deleted file mode 100644 index 83ca5c1e6ec..00000000000 --- a/db/migrate/20160722221922_nullify_blank_type_on_notes.rb +++ /dev/null @@ -1,9 +0,0 @@ -class NullifyBlankTypeOnNotes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - execute "UPDATE notes SET type = NULL WHERE type = ''" - end -end diff --git a/db/migrate/20160724205507_add_resolved_to_notes.rb b/db/migrate/20160724205507_add_resolved_to_notes.rb deleted file mode 100644 index fc56d3b1452..00000000000 --- a/db/migrate/20160724205507_add_resolved_to_notes.rb +++ /dev/null @@ -1,11 +0,0 @@ -# rubocop:disable Migration/Datetime -class AddResolvedToNotes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :notes, :resolved_at, :datetime - add_column :notes, :resolved_by_id, :integer - end -end diff --git a/db/migrate/20160725083350_add_external_url_to_enviroments.rb b/db/migrate/20160725083350_add_external_url_to_enviroments.rb deleted file mode 100644 index e060c6a8499..00000000000 --- a/db/migrate/20160725083350_add_external_url_to_enviroments.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddExternalUrlToEnviroments < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column(:environments, :external_url, :string) - end -end diff --git a/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb b/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb deleted file mode 100644 index d8b4696a246..00000000000 --- a/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb +++ /dev/null @@ -1,36 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class MergeRequestDiffRemoveUniq < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - constraint_name = 'merge_request_diffs_merge_request_id_key' - - transaction do - if index_exists?(:merge_request_diffs, :merge_request_id) - remove_index(:merge_request_diffs, :merge_request_id) - end - - # In some bizarre cases PostgreSQL might have a separate unique constraint - # that we'll need to drop. - if constraint_exists?(constraint_name) && Gitlab::Database.postgresql? - execute("ALTER TABLE merge_request_diffs DROP CONSTRAINT IF EXISTS #{constraint_name};") - end - end - end - - def down - unless index_exists?(:merge_request_diffs, :merge_request_id) - add_concurrent_index(:merge_request_diffs, :merge_request_id, unique: true) - end - end - - def constraint_exists?(name) - indexes(:merge_request_diffs).map(&:name).include?(name) - end -end diff --git a/db/migrate/20160725104452_merge_request_diff_add_index.rb b/db/migrate/20160725104452_merge_request_diff_add_index.rb deleted file mode 100644 index d3369b3f961..00000000000 --- a/db/migrate/20160725104452_merge_request_diff_add_index.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable RemoveIndex -class MergeRequestDiffAddIndex < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def up - add_concurrent_index :merge_request_diffs, :merge_request_id - end - - def down - if index_exists?(:merge_request_diffs, :merge_request_id) - remove_index :merge_request_diffs, :merge_request_id - end - end -end diff --git a/db/migrate/20160727163552_create_user_agent_details.rb b/db/migrate/20160727163552_create_user_agent_details.rb deleted file mode 100644 index 6ef54deca90..00000000000 --- a/db/migrate/20160727163552_create_user_agent_details.rb +++ /dev/null @@ -1,19 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateUserAgentDetails < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - create_table :user_agent_details do |t| - t.string :user_agent, null: false - t.string :ip_address, null: false - t.integer :subject_id, null: false - t.string :subject_type, null: false - t.boolean :submitted, default: false, null: false - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160727191041_create_boards.rb b/db/migrate/20160727191041_create_boards.rb deleted file mode 100644 index 60ed5508b10..00000000000 --- a/db/migrate/20160727191041_create_boards.rb +++ /dev/null @@ -1,14 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateBoards < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :boards do |t| - t.references :project, index: true, foreign_key: true, null: false - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160727193336_create_lists.rb b/db/migrate/20160727193336_create_lists.rb deleted file mode 100644 index 4591c9a120f..00000000000 --- a/db/migrate/20160727193336_create_lists.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateLists < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :lists do |t| - t.references :board, index: true, foreign_key: true, null: false - t.references :label, index: true, foreign_key: true - t.integer :list_type, null: false, default: 1 - t.integer :position - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb b/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb deleted file mode 100644 index fc3e9f03c74..00000000000 --- a/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddPipelineEventsToWebHooks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:web_hooks, :pipeline_events, :boolean, - default: false, allow_null: false) - end - - def down - remove_column(:web_hooks, :pipeline_events) - end -end diff --git a/db/migrate/20160728103734_add_pipeline_events_to_services.rb b/db/migrate/20160728103734_add_pipeline_events_to_services.rb deleted file mode 100644 index 421859ff5fd..00000000000 --- a/db/migrate/20160728103734_add_pipeline_events_to_services.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddPipelineEventsToServices < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:services, :pipeline_events, :boolean, - default: false, allow_null: false) - end - - def down - remove_column(:services, :pipeline_events) - end -end diff --git a/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb b/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb deleted file mode 100644 index 02e417e376f..00000000000 --- a/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb +++ /dev/null @@ -1,30 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveProjectIdFromSpamLogs < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - - # 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 = 'Removing a column that contains data that is not used anywhere.' - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - remove_column :spam_logs, :project_id, :integer - end -end diff --git a/db/migrate/20160801163421_add_expires_at_to_member.rb b/db/migrate/20160801163421_add_expires_at_to_member.rb deleted file mode 100644 index 13ca1d04658..00000000000 --- a/db/migrate/20160801163421_add_expires_at_to_member.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddExpiresAtToMember < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 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 :members, :expires_at, :date - end -end diff --git a/db/migrate/20160801163709_add_submitted_as_ham_to_spam_logs.rb b/db/migrate/20160801163709_add_submitted_as_ham_to_spam_logs.rb deleted file mode 100644 index fde9dee980e..00000000000 --- a/db/migrate/20160801163709_add_submitted_as_ham_to_spam_logs.rb +++ /dev/null @@ -1,24 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddSubmittedAsHamToSpamLogs < ActiveRecord::Migration[4.2] - 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_column_with_default :spam_logs, :submitted_as_ham, :boolean, default: false - end - - def down - remove_column :spam_logs, :submitted_as_ham - end -end diff --git a/db/migrate/20160802010328_remove_builds_enable_index_on_projects.rb b/db/migrate/20160802010328_remove_builds_enable_index_on_projects.rb deleted file mode 100644 index 4ad740e0812..00000000000 --- a/db/migrate/20160802010328_remove_builds_enable_index_on_projects.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable RemoveIndex -class RemoveBuildsEnableIndexOnProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - remove_index :projects, column: :builds_enabled if index_exists?(:projects, :builds_enabled) - end -end diff --git a/db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb b/db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb deleted file mode 100644 index f866fe15ec1..00000000000 --- a/db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb +++ /dev/null @@ -1,16 +0,0 @@ -# rubocop:disable RemoveIndex -class AddUniqueIndexToListsLabelId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :lists, [:board_id, :label_id], unique: true - end - - def down - remove_index :lists, column: [:board_id, :label_id] if index_exists?(:lists, [:board_id, :label_id], unique: true) - end -end diff --git a/db/migrate/20160804142904_add_ci_config_file_to_project.rb b/db/migrate/20160804142904_add_ci_config_file_to_project.rb deleted file mode 100644 index abd94e63db3..00000000000 --- a/db/migrate/20160804142904_add_ci_config_file_to_project.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddCiConfigFileToProject < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column :projects, :ci_config_path, :string - end - - def down - remove_column :projects, :ci_config_path - end -end diff --git a/db/migrate/20160804150737_add_timestamps_to_members_again.rb b/db/migrate/20160804150737_add_timestamps_to_members_again.rb deleted file mode 100644 index 4e71197b8e7..00000000000 --- a/db/migrate/20160804150737_add_timestamps_to_members_again.rb +++ /dev/null @@ -1,21 +0,0 @@ -# rubocop:disable all -# 20141121133009_add_timestamps_to_members.rb was meant to ensure that all -# rows in the members table had created_at and updated_at set, following an -# error in a previous migration. This failed to set all rows in at least one -# case: https://gitlab.com/gitlab-org/gitlab-ce/issues/20568 -# -# Why this happened is lost in the mists of time, so repeat the SQL query -# without speculation, just in case more than one person was affected. -class AddTimestampsToMembersAgain < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - execute "UPDATE members SET created_at = NOW() WHERE created_at IS NULL" - execute "UPDATE members SET updated_at = NOW() WHERE updated_at IS NULL" - end - - def down - # no change - end - -end diff --git a/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb b/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb deleted file mode 100644 index a0dfa3259ec..00000000000 --- a/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb +++ /dev/null @@ -1,21 +0,0 @@ -# rubocop:disable Migration/Datetime -# rubocop:disable RemoveIndex -class AddDeletedAtToNamespaces < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column :namespaces, :deleted_at, :datetime - - add_concurrent_index :namespaces, :deleted_at - end - - def down - remove_index :namespaces, :deleted_at if index_exists? :namespaces, :deleted_at - - remove_column :namespaces, :deleted_at - end -end diff --git a/db/migrate/20160808085531_add_token_to_build.rb b/db/migrate/20160808085531_add_token_to_build.rb deleted file mode 100644 index a1d8945a538..00000000000 --- a/db/migrate/20160808085531_add_token_to_build.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddTokenToBuild < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - add_column :ci_builds, :token, :string - end -end diff --git a/db/migrate/20160808085602_add_index_for_build_token.rb b/db/migrate/20160808085602_add_index_for_build_token.rb deleted file mode 100644 index 22d50e4165a..00000000000 --- a/db/migrate/20160808085602_add_index_for_build_token.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexForBuildToken < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_builds, :token, unique: true - end - - def down - remove_index :ci_builds, :token, unique: true if index_exists? :ci_builds, :token, unique: true - end -end diff --git a/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb b/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb deleted file mode 100644 index 738b93912b6..00000000000 --- a/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb +++ /dev/null @@ -1,27 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveCiRunnerTrigramIndexes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - # Disabled for the "down" method so the indexes can be re-created concurrently. - disable_ddl_transaction! - - def up - return unless Gitlab::Database.postgresql? - - transaction do - execute 'DROP INDEX IF EXISTS index_ci_runners_on_token_trigram;' - execute 'DROP INDEX IF EXISTS index_ci_runners_on_description_trigram;' - end - end - - def down - return unless Gitlab::Database.postgresql? - - execute 'CREATE INDEX CONCURRENTLY index_ci_runners_on_token_trigram ON ci_runners USING gin(token gin_trgm_ops);' - execute 'CREATE INDEX CONCURRENTLY index_ci_runners_on_description_trigram ON ci_runners USING gin(description gin_trgm_ops);' - end -end diff --git a/db/migrate/20160810142633_remove_redundant_indexes.rb b/db/migrate/20160810142633_remove_redundant_indexes.rb deleted file mode 100644 index 91f82cf9afa..00000000000 --- a/db/migrate/20160810142633_remove_redundant_indexes.rb +++ /dev/null @@ -1,113 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class RemoveRedundantIndexes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - indexes = [ - [:ci_taggings, 'ci_taggings_idx'], - [:audit_events, 'index_audit_events_on_author_id'], - [:audit_events, 'index_audit_events_on_type'], - [:ci_builds, 'index_ci_builds_on_erased_by_id'], - [:ci_builds, 'index_ci_builds_on_project_id_and_commit_id'], - [:ci_builds, 'index_ci_builds_on_type'], - [:ci_commits, 'index_ci_commits_on_project_id'], - [:ci_commits, 'index_ci_commits_on_project_id_and_committed_at'], - [:ci_commits, 'index_ci_commits_on_project_id_and_committed_at_and_id'], - [:ci_commits, 'index_ci_commits_on_project_id_and_sha'], - [:ci_commits, 'index_ci_commits_on_sha'], - [:ci_events, 'index_ci_events_on_created_at'], - [:ci_events, 'index_ci_events_on_is_admin'], - [:ci_events, 'index_ci_events_on_project_id'], - [:ci_jobs, 'index_ci_jobs_on_deleted_at'], - [:ci_jobs, 'index_ci_jobs_on_project_id'], - [:ci_projects, 'index_ci_projects_on_gitlab_id'], - [:ci_projects, 'index_ci_projects_on_shared_runners_enabled'], - [:ci_services, 'index_ci_services_on_project_id'], - [:ci_sessions, 'index_ci_sessions_on_session_id'], - [:ci_sessions, 'index_ci_sessions_on_updated_at'], - [:ci_tags, 'index_ci_tags_on_name'], - [:ci_triggers, 'index_ci_triggers_on_deleted_at'], - [:identities, 'index_identities_on_created_at_and_id'], - [:issues, 'index_issues_on_title'], - [:keys, 'index_keys_on_created_at_and_id'], - [:members, 'index_members_on_created_at_and_id'], - [:members, 'index_members_on_type'], - [:milestones, 'index_milestones_on_created_at_and_id'], - [:namespaces, 'index_namespaces_on_visibility_level'], - [:projects, 'index_projects_on_builds_enabled_and_shared_runners_enabled'], - [:services, 'index_services_on_category'], - [:services, 'index_services_on_created_at_and_id'], - [:services, 'index_services_on_default'], - [:snippets, 'index_snippets_on_created_at'], - [:snippets, 'index_snippets_on_created_at_and_id'], - [:todos, 'index_todos_on_state'], - [:web_hooks, 'index_web_hooks_on_created_at_and_id'], - - # These indexes _may_ be used but they can be replaced by other existing - # indexes. - - # There's already a composite index on (project_id, iid) which means that - # a separate index for _just_ project_id is not needed. - [:issues, 'index_issues_on_project_id'], - - # These are all composite indexes for the columns (created_at, id). In all - # these cases there's already a standalone index for "created_at" which - # can be used instead. - # - # Because the "id" column of these composite indexes is never needed (due - # to "id" already being indexed as its a primary key) these composite - # indexes are useless. - [:issues, 'index_issues_on_created_at_and_id'], - [:merge_requests, 'index_merge_requests_on_created_at_and_id'], - [:namespaces, 'index_namespaces_on_created_at_and_id'], - [:notes, 'index_notes_on_created_at_and_id'], - [:projects, 'index_projects_on_created_at_and_id'], - [:users, 'index_users_on_created_at_and_id'] - ] - - transaction do - indexes.each do |(table, index)| - remove_index(table, name: index) if index_exists_by_name?(table, index) - end - end - - add_concurrent_index(:users, :created_at) - add_concurrent_index(:projects, :created_at) - add_concurrent_index(:namespaces, :created_at) - end - - def down - # We're only restoring the composite indexes that could be replaced with - # individual ones, just in case somebody would ever want to revert. - transaction do - remove_index(:users, :created_at) - remove_index(:projects, :created_at) - remove_index(:namespaces, :created_at) - end - - [:issues, :merge_requests, :namespaces, :notes, :projects, :users].each do |table| - add_concurrent_index(table, [:created_at, :id], - name: "index_#{table}_on_created_at_and_id") - end - end - - # Rails' index_exists? doesn't work when you only give it a table and index - # name. As such we have to use some extra code to check if an index exists for - # a given name. - def index_exists_by_name?(table, index) - indexes_for_table[table].include?(index) - end - - def indexes_for_table - @indexes_for_table ||= Hash.new do |hash, table_name| - hash[table_name] = indexes(table_name).map(&:name) - end - end -end diff --git a/db/migrate/20160811172945_add_can_push_to_keys.rb b/db/migrate/20160811172945_add_can_push_to_keys.rb deleted file mode 100644 index 2e78ab0249e..00000000000 --- a/db/migrate/20160811172945_add_can_push_to_keys.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddCanPushToKeys < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_column_with_default(:keys, :can_push, :boolean, default: false, allow_null: false) - end - - def down - remove_column(:keys, :can_push) - end -end diff --git a/db/migrate/20160816161312_add_column_name_to_u2f_registrations.rb b/db/migrate/20160816161312_add_column_name_to_u2f_registrations.rb deleted file mode 100644 index 76b60787323..00000000000 --- a/db/migrate/20160816161312_add_column_name_to_u2f_registrations.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddColumnNameToU2fRegistrations < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 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 :u2f_registrations, :name, :string - end -end diff --git a/db/migrate/20160817133006_add_koding_to_application_settings.rb b/db/migrate/20160817133006_add_koding_to_application_settings.rb deleted file mode 100644 index 04f9d7be29b..00000000000 --- a/db/migrate/20160817133006_add_koding_to_application_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -# rubocop:disable Migration/SaferBooleanColumn -class AddKodingToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, :koding_enabled, :boolean - add_column :application_settings, :koding_url, :string - end -end diff --git a/db/migrate/20160817154936_add_discussion_ids_to_notes.rb b/db/migrate/20160817154936_add_discussion_ids_to_notes.rb deleted file mode 100644 index e735eeadac5..00000000000 --- a/db/migrate/20160817154936_add_discussion_ids_to_notes.rb +++ /dev/null @@ -1,13 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddDiscussionIdsToNotes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :notes, :discussion_id, :string - add_column :notes, :original_discussion_id, :string - end -end diff --git a/db/migrate/20160818205718_add_expires_at_to_project_group_links.rb b/db/migrate/20160818205718_add_expires_at_to_project_group_links.rb deleted file mode 100644 index 06f621c6c2e..00000000000 --- a/db/migrate/20160818205718_add_expires_at_to_project_group_links.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddExpiresAtToProjectGroupLinks < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 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 :project_group_links, :expires_at, :date - end -end diff --git a/db/migrate/20160819221631_add_index_to_note_discussion_id.rb b/db/migrate/20160819221631_add_index_to_note_discussion_id.rb deleted file mode 100644 index 1dbc0474fd2..00000000000 --- a/db/migrate/20160819221631_add_index_to_note_discussion_id.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddIndexToNoteDiscussionId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :notes, :discussion_id - end - - def down - remove_index :notes, :discussion_id if index_exists? :notes, :discussion_id - end -end diff --git a/db/migrate/20160819221833_reset_diff_note_discussion_id_because_it_was_calculated_wrongly.rb b/db/migrate/20160819221833_reset_diff_note_discussion_id_because_it_was_calculated_wrongly.rb deleted file mode 100644 index 61f593a52c5..00000000000 --- a/db/migrate/20160819221833_reset_diff_note_discussion_id_because_it_was_calculated_wrongly.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class ResetDiffNoteDiscussionIdBecauseItWasCalculatedWrongly < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - execute "UPDATE notes SET discussion_id = NULL WHERE discussion_id IS NOT NULL AND type = 'DiffNote'" - end -end diff --git a/db/migrate/20160819232256_add_incoming_email_token_to_users.rb b/db/migrate/20160819232256_add_incoming_email_token_to_users.rb deleted file mode 100644 index 0a7190f632d..00000000000 --- a/db/migrate/20160819232256_add_incoming_email_token_to_users.rb +++ /dev/null @@ -1,24 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddIncomingEmailTokenToUsers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column :users, :incoming_email_token, :string - - add_concurrent_index :users, :incoming_email_token - end - - def down - remove_index :users, :incoming_email_token if index_exists? :users, :incoming_email_token - - remove_column :users, :incoming_email_token - end -end diff --git a/db/migrate/20160823081327_change_merge_error_to_text.rb b/db/migrate/20160823081327_change_merge_error_to_text.rb deleted file mode 100644 index 23b4f35a776..00000000000 --- a/db/migrate/20160823081327_change_merge_error_to_text.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ChangeMergeErrorToText < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because it alters a column from varchar(255) to text.' - - def change - change_column :merge_requests, :merge_error, :text, limit: 65535 - end -end diff --git a/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb b/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb deleted file mode 100644 index 4c320123088..00000000000 --- a/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb +++ /dev/null @@ -1,19 +0,0 @@ -# The default needs to be `[]`, but all existing access tokens need to have `scopes` set to `['api']`. -# It's easier to achieve this by adding the column with the `['api']` default, and then changing the default to -# `[]`. - -class AddColumnScopesToPersonalAccessTokens < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :personal_access_tokens, :scopes, :string, default: ['api'].to_yaml - end - - def down - remove_column :personal_access_tokens, :scopes - end -end diff --git a/db/migrate/20160823213309_add_lfs_enabled_to_projects.rb b/db/migrate/20160823213309_add_lfs_enabled_to_projects.rb deleted file mode 100644 index 87e6e8b6945..00000000000 --- a/db/migrate/20160823213309_add_lfs_enabled_to_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddLfsEnabledToProjects < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 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 :projects, :lfs_enabled, :boolean - end -end diff --git a/db/migrate/20160824103857_drop_unused_ci_tables.rb b/db/migrate/20160824103857_drop_unused_ci_tables.rb deleted file mode 100644 index 8a207683848..00000000000 --- a/db/migrate/20160824103857_drop_unused_ci_tables.rb +++ /dev/null @@ -1,11 +0,0 @@ -class DropUnusedCiTables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - drop_table(:ci_services) - drop_table(:ci_web_hooks) - end -end diff --git a/db/migrate/20160824124900_add_table_issue_metrics.rb b/db/migrate/20160824124900_add_table_issue_metrics.rb deleted file mode 100644 index 4f34f377e22..00000000000 --- a/db/migrate/20160824124900_add_table_issue_metrics.rb +++ /dev/null @@ -1,37 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. -# rubocop:disable Migration/Timestamps -class AddTableIssueMetrics < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - - # 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 = 'Adding foreign key' - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - create_table :issue_metrics do |t| - t.references :issue, index: { name: "index_issue_metrics" }, foreign_key: { on_delete: :cascade }, null: false - - t.datetime 'first_mentioned_in_commit_at' - t.datetime 'first_associated_with_milestone_at' - t.datetime 'first_added_to_board_at' - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160825052008_add_table_merge_request_metrics.rb b/db/migrate/20160825052008_add_table_merge_request_metrics.rb deleted file mode 100644 index 150f698869d..00000000000 --- a/db/migrate/20160825052008_add_table_merge_request_metrics.rb +++ /dev/null @@ -1,38 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. -# rubocop:disable Migration/Timestamps -class AddTableMergeRequestMetrics < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - - # 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 = 'Adding foreign key' - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - create_table :merge_request_metrics do |t| - t.references :merge_request, index: { name: "index_merge_request_metrics" }, foreign_key: { on_delete: :cascade }, null: false - - t.datetime 'latest_build_started_at' - t.datetime 'latest_build_finished_at' - t.datetime 'first_deployed_to_production_at', index: true - t.datetime 'merged_at' - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb b/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb deleted file mode 100644 index 18c0f0be3eb..00000000000 --- a/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb +++ /dev/null @@ -1,16 +0,0 @@ -class EnsureLockVersionHasNoDefault < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - change_column_default :issues, :lock_version, nil - change_column_default :merge_requests, :lock_version, nil - - execute('UPDATE issues SET lock_version = 1 WHERE lock_version = 0') - execute('UPDATE merge_requests SET lock_version = 1 WHERE lock_version = 0') - end - - def down - end -end diff --git a/db/migrate/20160829114652_add_markdown_cache_columns.rb b/db/migrate/20160829114652_add_markdown_cache_columns.rb deleted file mode 100644 index b1c5e38c3c4..00000000000 --- a/db/migrate/20160829114652_add_markdown_cache_columns.rb +++ /dev/null @@ -1,38 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddMarkdownCacheColumns < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - COLUMNS = { - abuse_reports: [:message], - appearances: [:description], - application_settings: [ - :sign_in_text, - :help_page_text, - :shared_runners_text, - :after_sign_up_text - ], - broadcast_messages: [:message], - issues: [:title, :description], - labels: [:description], - merge_requests: [:title, :description], - milestones: [:title, :description], - namespaces: [:description], - notes: [:note], - projects: [:description], - releases: [:description], - snippets: [:title, :content] - }.freeze - - def change - COLUMNS.each do |table, columns| - columns.each do |column| - add_column table, "#{column}_html", :text - end - end - end -end diff --git a/db/migrate/20160830203109_add_confidential_issues_events_to_web_hooks.rb b/db/migrate/20160830203109_add_confidential_issues_events_to_web_hooks.rb deleted file mode 100644 index 771a6b84648..00000000000 --- a/db/migrate/20160830203109_add_confidential_issues_events_to_web_hooks.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddConfidentialIssuesEventsToWebHooks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :web_hooks, :confidential_issues_events, :boolean, default: false, allow_null: false - end - - def down - remove_column :web_hooks, :confidential_issues_events - end -end diff --git a/db/migrate/20160830211132_add_confidential_issues_events_to_services.rb b/db/migrate/20160830211132_add_confidential_issues_events_to_services.rb deleted file mode 100644 index a1807264341..00000000000 --- a/db/migrate/20160830211132_add_confidential_issues_events_to_services.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddConfidentialIssuesEventsToServices < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :services, :confidential_issues_events, :boolean, default: true, allow_null: false - end - - def down - remove_column :services, :confidential_issues_events - end -end diff --git a/db/migrate/20160830232601_change_lock_version_not_null.rb b/db/migrate/20160830232601_change_lock_version_not_null.rb deleted file mode 100644 index 1e34b57e53f..00000000000 --- a/db/migrate/20160830232601_change_lock_version_not_null.rb +++ /dev/null @@ -1,13 +0,0 @@ -class ChangeLockVersionNotNull < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - change_column_null :issues, :lock_version, true - change_column_null :merge_requests, :lock_version, true - end - - def down - end -end diff --git a/db/migrate/20160831214002_create_project_features.rb b/db/migrate/20160831214002_create_project_features.rb deleted file mode 100644 index e1e61c3a4a2..00000000000 --- a/db/migrate/20160831214002_create_project_features.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateProjectFeatures < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :project_features do |t| - t.belongs_to :project, index: true - t.integer :merge_requests_access_level - t.integer :issues_access_level - t.integer :wiki_access_level - t.integer :snippets_access_level - t.integer :builds_access_level - - t.timestamps null: true - end - end -end diff --git a/db/migrate/20160831214543_migrate_project_features.rb b/db/migrate/20160831214543_migrate_project_features.rb deleted file mode 100644 index ba7ffd7c9f2..00000000000 --- a/db/migrate/20160831214543_migrate_project_features.rb +++ /dev/null @@ -1,44 +0,0 @@ -class MigrateProjectFeatures < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = - <<-EOT.freeze - Migrating issues_enabled, merge_requests_enabled, wiki_enabled, builds_enabled, snippets_enabled fields from projects to - a new table called project_features. - EOT - - def up - sql = - %Q{ - INSERT INTO project_features(project_id, issues_access_level, merge_requests_access_level, wiki_access_level, - builds_access_level, snippets_access_level, created_at, updated_at) - SELECT - id AS project_id, - CASE WHEN issues_enabled IS true THEN 20 ELSE 0 END AS issues_access_level, - CASE WHEN merge_requests_enabled IS true THEN 20 ELSE 0 END AS merge_requests_access_level, - CASE WHEN wiki_enabled IS true THEN 20 ELSE 0 END AS wiki_access_level, - CASE WHEN builds_enabled IS true THEN 20 ELSE 0 END AS builds_access_level, - CASE WHEN snippets_enabled IS true THEN 20 ELSE 0 END AS snippets_access_level, - created_at, - updated_at - FROM projects - } - - execute(sql) - end - - def down - sql = %Q{ - UPDATE projects - SET - issues_enabled = COALESCE((SELECT CASE WHEN issues_access_level = 20 THEN true ELSE false END AS issues_enabled FROM project_features WHERE project_features.project_id = projects.id), true), - merge_requests_enabled = COALESCE((SELECT CASE WHEN merge_requests_access_level = 20 THEN true ELSE false END AS merge_requests_enabled FROM project_features WHERE project_features.project_id = projects.id),true), - wiki_enabled = COALESCE((SELECT CASE WHEN wiki_access_level = 20 THEN true ELSE false END AS wiki_enabled FROM project_features WHERE project_features.project_id = projects.id), true), - builds_enabled = COALESCE((SELECT CASE WHEN builds_access_level = 20 THEN true ELSE false END AS builds_enabled FROM project_features WHERE project_features.project_id = projects.id), true), - snippets_enabled = COALESCE((SELECT CASE WHEN snippets_access_level = 20 THEN true ELSE false END AS snippets_enabled FROM project_features WHERE project_features.project_id = projects.id),true) - } - - execute(sql) - end -end diff --git a/db/migrate/20160831223750_remove_features_enabled_from_projects.rb b/db/migrate/20160831223750_remove_features_enabled_from_projects.rb deleted file mode 100644 index 6d39d42882b..00000000000 --- a/db/migrate/20160831223750_remove_features_enabled_from_projects.rb +++ /dev/null @@ -1,31 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/UpdateLargeTable -class RemoveFeaturesEnabledFromProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - DOWNTIME_REASON = "Removing fields from database requires downtine." - - def up - remove_column :projects, :issues_enabled - remove_column :projects, :merge_requests_enabled - remove_column :projects, :builds_enabled - remove_column :projects, :wiki_enabled - remove_column :projects, :snippets_enabled - end - - # Ugly SQL but the only way i found to make it work on both Postgres and Mysql - # It will be slow but it is ok since it is a revert method - def down - add_column_with_default(:projects, :issues_enabled, :boolean, default: true, allow_null: false) - add_column_with_default(:projects, :merge_requests_enabled, :boolean, default: true, allow_null: false) - add_column_with_default(:projects, :builds_enabled, :boolean, default: true, allow_null: false) - add_column_with_default(:projects, :wiki_enabled, :boolean, default: true, allow_null: false) - add_column_with_default(:projects, :snippets_enabled, :boolean, default: true, allow_null: false) - end -end diff --git a/db/migrate/20160901141443_set_confidential_issues_events_on_webhooks.rb b/db/migrate/20160901141443_set_confidential_issues_events_on_webhooks.rb deleted file mode 100644 index 2921bb566c9..00000000000 --- a/db/migrate/20160901141443_set_confidential_issues_events_on_webhooks.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable Migration/UpdateColumnInBatches -class SetConfidentialIssuesEventsOnWebhooks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - update_column_in_batches(:web_hooks, :confidential_issues_events, true) do |table, query| - query.where(table[:issues_events].eq(true)) - end - end - - def down - # noop - end -end diff --git a/db/migrate/20160901213340_add_lfs_enabled_to_namespaces.rb b/db/migrate/20160901213340_add_lfs_enabled_to_namespaces.rb deleted file mode 100644 index 1be5f3f6ab0..00000000000 --- a/db/migrate/20160901213340_add_lfs_enabled_to_namespaces.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddLfsEnabledToNamespaces < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :namespaces, :lfs_enabled, :boolean - end -end diff --git a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb deleted file mode 100644 index 6c2dc58876e..00000000000 --- a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb +++ /dev/null @@ -1,39 +0,0 @@ -class DropGitoriousFieldFromApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # After the deploy the caches will be cold anyway - DOWNTIME = false - - def up - require 'yaml' - - import_sources = connection.execute('SELECT import_sources FROM application_settings;') - return unless import_sources.first # support empty databases - - yaml = if Gitlab::Database.postgresql? - import_sources.values[0][0] - else - import_sources.first[0] - end - - yaml = YAML.safe_load(yaml) - yaml.delete 'gitorious' - - # No need for a WHERE clause as there is only one - connection.execute("UPDATE application_settings SET import_sources = #{update_yaml(yaml)}") - end - - def down - # noop, gitorious still yields a 404 anyway - end - - private - - def connection - ActiveRecord::Base.connection - end - - def update_yaml(yaml) - connection.quote(YAML.dump(yaml)) - end -end diff --git a/db/migrate/20160907131111_add_environment_type_to_environments.rb b/db/migrate/20160907131111_add_environment_type_to_environments.rb deleted file mode 100644 index 34463178fca..00000000000 --- a/db/migrate/20160907131111_add_environment_type_to_environments.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddEnvironmentTypeToEnvironments < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :environments, :environment_type, :string - end -end diff --git a/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb b/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb deleted file mode 100644 index 51650c68170..00000000000 --- a/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb +++ /dev/null @@ -1,21 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/UpdateLargeTable -class RemoveProjectsPushesSinceGc < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'This migration removes an existing column' - - disable_ddl_transaction! - - def up - remove_column :projects, :pushes_since_gc - end - - def down - add_column_with_default :projects, :pushes_since_gc, :integer, default: 0 - end -end diff --git a/db/migrate/20160913212128_change_artifacts_size_column.rb b/db/migrate/20160913212128_change_artifacts_size_column.rb deleted file mode 100644 index f2c2aaff9a8..00000000000 --- a/db/migrate/20160913212128_change_artifacts_size_column.rb +++ /dev/null @@ -1,15 +0,0 @@ -class ChangeArtifactsSizeColumn < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - - DOWNTIME_REASON = 'Changing an integer column size requires a full table rewrite.' - - def up - change_column :ci_builds, :artifacts_size, :integer, limit: 8 - end - - def down - # do nothing - end -end diff --git a/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb b/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb deleted file mode 100644 index 81511f9861b..00000000000 --- a/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb +++ /dev/null @@ -1,14 +0,0 @@ -class OnlyAllowMergeIfAllDiscussionsAreResolved < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - disable_ddl_transaction! - - def up - add_column :projects, :only_allow_merge_if_all_discussions_are_resolved, :boolean - end - - def down - remove_column(:projects, :only_allow_merge_if_all_discussions_are_resolved) - end -end diff --git a/db/migrate/20160915042921_create_merge_requests_closing_issues.rb b/db/migrate/20160915042921_create_merge_requests_closing_issues.rb deleted file mode 100644 index 3efe8c8901b..00000000000 --- a/db/migrate/20160915042921_create_merge_requests_closing_issues.rb +++ /dev/null @@ -1,35 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/Timestamps -class CreateMergeRequestsClosingIssues < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - - # 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 = 'Adding foreign keys' - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - create_table :merge_requests_closing_issues do |t| - t.references :merge_request, foreign_key: { on_delete: :cascade }, index: true, null: false - t.references :issue, foreign_key: { on_delete: :cascade }, index: true, null: false - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160919144305_add_type_to_labels.rb b/db/migrate/20160919144305_add_type_to_labels.rb deleted file mode 100644 index f897646d264..00000000000 --- a/db/migrate/20160919144305_add_type_to_labels.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable Migration/UpdateColumnInBatches -class AddTypeToLabels < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'Labels will not work as expected until this migration is complete.' - - disable_ddl_transaction! - - def change - add_column :labels, :type, :string - - update_column_in_batches(:labels, :type, 'ProjectLabel') do |table, query| - query.where(table[:project_id].not_eq(nil)) - end - end -end diff --git a/db/migrate/20160919145149_add_group_id_to_labels.rb b/db/migrate/20160919145149_add_group_id_to_labels.rb deleted file mode 100644 index df11a2fc4c8..00000000000 --- a/db/migrate/20160919145149_add_group_id_to_labels.rb +++ /dev/null @@ -1,20 +0,0 @@ -# rubocop:disable RemoveIndex -class AddGroupIdToLabels < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column :labels, :group_id, :integer - add_foreign_key :labels, :namespaces, column: :group_id, on_delete: :cascade # rubocop: disable Migration/AddConcurrentForeignKey - add_concurrent_index :labels, :group_id - end - - def down - remove_foreign_key :labels, column: :group_id - remove_index :labels, :group_id if index_exists? :labels, :group_id - remove_column :labels, :group_id - end -end diff --git a/db/migrate/20160920160832_add_index_to_labels_title.rb b/db/migrate/20160920160832_add_index_to_labels_title.rb deleted file mode 100644 index e6c87836d4e..00000000000 --- a/db/migrate/20160920160832_add_index_to_labels_title.rb +++ /dev/null @@ -1,16 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexToLabelsTitle < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :labels, :title - end - - def down - remove_index :labels, :title if index_exists? :labels, :title - end -end diff --git a/db/migrate/20160926145521_add_organization_to_user.rb b/db/migrate/20160926145521_add_organization_to_user.rb deleted file mode 100644 index 2d8d907591d..00000000000 --- a/db/migrate/20160926145521_add_organization_to_user.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddOrganizationToUser < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :users, :organization, :string - end -end diff --git a/db/migrate/20161006104309_add_state_to_environment.rb b/db/migrate/20161006104309_add_state_to_environment.rb deleted file mode 100644 index c51dada9bca..00000000000 --- a/db/migrate/20161006104309_add_state_to_environment.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddStateToEnvironment < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_column_with_default(:environments, :state, :string, default: :available) - end - - def down - remove_column(:environments, :state) - end -end diff --git a/db/migrate/20161007073613_create_user_activities.rb b/db/migrate/20161007073613_create_user_activities.rb deleted file mode 100644 index dc972bf4664..00000000000 --- a/db/migrate/20161007073613_create_user_activities.rb +++ /dev/null @@ -1,28 +0,0 @@ - -class CreateUserActivities < ActiveRecord::Migration[4.2] - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - - # 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 = 'Adding foreign key'.freeze - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - create_table :user_activities do |t| - t.belongs_to :user, index: { unique: true }, foreign_key: { on_delete: :cascade } - t.datetime :last_activity_at, null: false - end - end -end diff --git a/db/migrate/20161007133303_precalculate_trending_projects.rb b/db/migrate/20161007133303_precalculate_trending_projects.rb deleted file mode 100644 index c7a678c9d8f..00000000000 --- a/db/migrate/20161007133303_precalculate_trending_projects.rb +++ /dev/null @@ -1,38 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class PrecalculateTrendingProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - create_table :trending_projects do |t| - t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false - end - - timestamp = connection.quote(1.month.ago) - - # We're hardcoding the visibility level (public) here so that if it ever - # changes this query doesn't suddenly use the new value (which may break - # later migrations). - visibility = 20 - - execute <<-EOF.strip_heredoc - INSERT INTO trending_projects (project_id) - SELECT project_id - FROM notes - INNER JOIN projects ON projects.id = notes.project_id - WHERE notes.created_at >= #{timestamp} - AND notes.system IS FALSE - AND projects.visibility_level = #{visibility} - GROUP BY project_id - ORDER BY count(*) DESC - LIMIT 100; - EOF - end - - def down - drop_table :trending_projects - end -end diff --git a/db/migrate/20161010142410_create_project_authorizations.rb b/db/migrate/20161010142410_create_project_authorizations.rb deleted file mode 100644 index b340a4ece19..00000000000 --- a/db/migrate/20161010142410_create_project_authorizations.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateProjectAuthorizations < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :project_authorizations do |t| - t.references :user, foreign_key: { on_delete: :cascade } - t.references :project, foreign_key: { on_delete: :cascade } - t.integer :access_level - - t.index [:user_id, :project_id, :access_level], unique: true, name: 'index_project_authorizations_on_user_id_project_id_access_level' - end - end -end diff --git a/db/migrate/20161012180455_add_repository_access_level_to_project_feature.rb b/db/migrate/20161012180455_add_repository_access_level_to_project_feature.rb deleted file mode 100644 index 3024ea81ed8..00000000000 --- a/db/migrate/20161012180455_add_repository_access_level_to_project_feature.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddRepositoryAccessLevelToProjectFeature < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_column_with_default(:project_features, :repository_access_level, :integer, default: ProjectFeature::ENABLED) - end - - def down - remove_column :project_features, :repository_access_level - end -end diff --git a/db/migrate/20161014173530_create_label_priorities.rb b/db/migrate/20161014173530_create_label_priorities.rb deleted file mode 100644 index c7d60caa7d1..00000000000 --- a/db/migrate/20161014173530_create_label_priorities.rb +++ /dev/null @@ -1,26 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateLabelPriorities < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'This migration adds foreign keys' - - disable_ddl_transaction! - - def up - create_table :label_priorities do |t| - t.references :project, foreign_key: { on_delete: :cascade }, null: false - t.references :label, foreign_key: { on_delete: :cascade }, null: false - t.integer :priority, null: false - - t.timestamps null: false - end - - add_concurrent_index :label_priorities, [:project_id, :label_id], unique: true - add_concurrent_index :label_priorities, :priority - end - - def down - drop_table :label_priorities - end -end diff --git a/db/migrate/20161017091941_add_authorized_projects_populated_to_users.rb b/db/migrate/20161017091941_add_authorized_projects_populated_to_users.rb deleted file mode 100644 index 11f4fa1a1f7..00000000000 --- a/db/migrate/20161017091941_add_authorized_projects_populated_to_users.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddAuthorizedProjectsPopulatedToUsers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :users, :authorized_projects_populated, :boolean - end -end diff --git a/db/migrate/20161017095000_add_properties_to_deployment.rb b/db/migrate/20161017095000_add_properties_to_deployment.rb deleted file mode 100644 index 31bd4cd24ad..00000000000 --- a/db/migrate/20161017095000_add_properties_to_deployment.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddPropertiesToDeployment < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :deployments, :on_stop, :string - end -end diff --git a/db/migrate/20161017125927_add_unique_index_to_labels.rb b/db/migrate/20161017125927_add_unique_index_to_labels.rb deleted file mode 100644 index b5326789f52..00000000000 --- a/db/migrate/20161017125927_add_unique_index_to_labels.rb +++ /dev/null @@ -1,33 +0,0 @@ -# rubocop:disable RemoveIndex -class AddUniqueIndexToLabels < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'This migration removes duplicated labels.' - - disable_ddl_transaction! - - def up - select_all('SELECT title, project_id, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1').each do |label| - label_title = quote_string(label['title']) - duplicated_ids = select_all("SELECT id FROM labels WHERE project_id = #{label['project_id']} AND title = '#{label_title}' ORDER BY id ASC").map { |label| label['id'] } - label_id = duplicated_ids.first - duplicated_ids.delete(label_id) - - execute("UPDATE label_links SET label_id = #{label_id} WHERE label_id IN(#{duplicated_ids.join(",")})") - execute("DELETE FROM labels WHERE id IN(#{duplicated_ids.join(",")})") - end - - remove_index :labels, column: :project_id if index_exists?(:labels, :project_id) - remove_index :labels, column: :title if index_exists?(:labels, :title) - - add_concurrent_index :labels, [:group_id, :project_id, :title], unique: true - end - - def down - remove_index :labels, column: [:group_id, :project_id, :title] if index_exists?(:labels, [:group_id, :project_id, :title], unique: true) - - add_concurrent_index :labels, :project_id - add_concurrent_index :labels, :title - end -end diff --git a/db/migrate/20161018024215_migrate_labels_priority.rb b/db/migrate/20161018024215_migrate_labels_priority.rb deleted file mode 100644 index 3e2540c134c..00000000000 --- a/db/migrate/20161018024215_migrate_labels_priority.rb +++ /dev/null @@ -1,36 +0,0 @@ -class MigrateLabelsPriority < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'Prioritized labels will not work as expected until this migration is complete.' - - disable_ddl_transaction! - - def up - execute <<-EOF.strip_heredoc - INSERT INTO label_priorities (project_id, label_id, priority, created_at, updated_at) - SELECT labels.project_id, labels.id, labels.priority, NOW(), NOW() - FROM labels - WHERE labels.project_id IS NOT NULL - AND labels.priority IS NOT NULL; - EOF - end - - def down - if Gitlab::Database.mysql? - execute <<-EOF.strip_heredoc - UPDATE labels - INNER JOIN label_priorities ON labels.id = label_priorities.label_id AND labels.project_id = label_priorities.project_id - SET labels.priority = label_priorities.priority; - EOF - else - execute <<-EOF.strip_heredoc - UPDATE labels - SET priority = label_priorities.priority - FROM label_priorities - WHERE labels.id = label_priorities.label_id - AND labels.project_id = label_priorities.project_id; - EOF - end - end -end diff --git a/db/migrate/20161018024550_remove_priority_from_labels.rb b/db/migrate/20161018024550_remove_priority_from_labels.rb deleted file mode 100644 index e164d959bdf..00000000000 --- a/db/migrate/20161018024550_remove_priority_from_labels.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -class RemovePriorityFromLabels < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'This migration removes an existing column' - - disable_ddl_transaction! - - def up - remove_column :labels, :priority, :integer, index: true - end - - def down - add_column :labels, :priority, :integer - add_concurrent_index :labels, :priority - end -end diff --git a/db/migrate/20161018124658_make_project_owners_masters.rb b/db/migrate/20161018124658_make_project_owners_masters.rb deleted file mode 100644 index 132c17388dc..00000000000 --- a/db/migrate/20161018124658_make_project_owners_masters.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable Migration/UpdateColumnInBatches -class MakeProjectOwnersMasters < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - update_column_in_batches(:members, :access_level, 40) do |table, query| - query.where(table[:access_level].eq(50).and(table[:source_type].eq('Project'))) - end - end - - def down - # do nothing - end -end diff --git a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb deleted file mode 100644 index fc6d9784638..00000000000 --- a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb +++ /dev/null @@ -1,109 +0,0 @@ -require 'json' - -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MigrateSidekiqQueuesFromDefault < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - - DOWNTIME_REASON = <<-EOF - Moving Sidekiq jobs from queues requires Sidekiq to be stopped. Not stopping - Sidekiq will result in the loss of jobs that are scheduled after this - migration completes. - EOF - - disable_ddl_transaction! - - # Jobs for which the queue names have been changed (e.g. multiple workers - # using the same non-default queue). - # - # The keys are the old queue names, the values the jobs to move and their new - # queue names. - RENAMED_QUEUES = { - gitlab_shell: { - 'GitGarbageCollectorWorker' => :git_garbage_collector, - 'ProjectExportWorker' => :project_export, - 'RepositoryForkWorker' => :repository_fork, - 'RepositoryImportWorker' => :repository_import - }, - project_web_hook: { - 'ProjectServiceWorker' => :project_service - }, - incoming_email: { - 'EmailReceiverWorker' => :email_receiver - }, - mailers: { - 'EmailsOnPushWorker' => :emails_on_push - }, - default: { - 'AdminEmailWorker' => :cronjob, - 'BuildCoverageWorker' => :build, - 'BuildEmailWorker' => :build, - 'BuildFinishedWorker' => :build, - 'BuildHooksWorker' => :build, - 'BuildSuccessWorker' => :build, - 'ClearDatabaseCacheWorker' => :clear_database_cache, - 'DeleteUserWorker' => :delete_user, - 'ExpireBuildArtifactsWorker' => :cronjob, - 'ExpireBuildInstanceArtifactsWorker' => :expire_build_instance_artifacts, - 'GroupDestroyWorker' => :group_destroy, - 'ImportExportProjectCleanupWorker' => :cronjob, - 'IrkerWorker' => :irker, - 'MergeWorker' => :merge, - 'NewNoteWorker' => :new_note, - 'PipelineHooksWorker' => :pipeline, - 'PipelineMetricsWorker' => :pipeline, - 'PipelineProcessWorker' => :pipeline, - 'PipelineSuccessWorker' => :pipeline, - 'PipelineUpdateWorker' => :pipeline, - 'ProjectCacheWorker' => :project_cache, - 'ProjectDestroyWorker' => :project_destroy, - 'PruneOldEventsWorker' => :cronjob, - 'RemoveExpiredGroupLinksWorker' => :cronjob, - 'RemoveExpiredMembersWorker' => :cronjob, - 'RepositoryArchiveCacheWorker' => :cronjob, - 'RepositoryCheck::BatchWorker' => :cronjob, - 'RepositoryCheck::ClearWorker' => :repository_check, - 'RepositoryCheck::SingleRepositoryWorker' => :repository_check, - 'RequestsProfilesWorker' => :cronjob, - 'StuckCiBuildsWorker' => :cronjob, - 'UpdateMergeRequestsWorker' => :update_merge_requests - } - }.freeze - - def up - Sidekiq.redis do |redis| - RENAMED_QUEUES.each do |queue, jobs| - migrate_from_queue(redis, queue, jobs) - end - end - end - - def down - Sidekiq.redis do |redis| - RENAMED_QUEUES.each do |dest_queue, jobs| - jobs.each do |worker, from_queue| - migrate_from_queue(redis, from_queue, worker => dest_queue) - end - end - end - end - - def migrate_from_queue(redis, queue, job_mapping) - while job = redis.lpop("queue:#{queue}") - payload = JSON.parse(job) - new_queue = job_mapping[payload['class']] - - # If we have no target queue to migrate to we're probably dealing with - # some ancient job for which the worker no longer exists. In that case - # there's no sane option we can take, other than just dropping the job. - next unless new_queue - - payload['queue'] = new_queue - - redis.lpush("queue:#{new_queue}", JSON.dump(payload)) - end - end -end diff --git a/db/migrate/20161019213545_generate_project_feature_for_projects.rb b/db/migrate/20161019213545_generate_project_feature_for_projects.rb deleted file mode 100644 index 587bdf60f70..00000000000 --- a/db/migrate/20161019213545_generate_project_feature_for_projects.rb +++ /dev/null @@ -1,28 +0,0 @@ -class GenerateProjectFeatureForProjects < ActiveRecord::Migration[4.2] - DOWNTIME = true - - DOWNTIME_REASON = <<-HEREDOC - Application was eager loading project_feature for all projects generating an extra query - everytime a project was fetched. We removed that behavior to avoid the extra query, this migration - makes sure all projects have a project_feature record associated. - HEREDOC - - def up - # Generate enabled values for each project feature 20, 20, 20, 20, 20 - # All features are enabled by default - enabled_values = [ProjectFeature::ENABLED] * 5 - - execute <<-EOF.strip_heredoc - INSERT INTO project_features - (project_id, merge_requests_access_level, builds_access_level, - issues_access_level, snippets_access_level, wiki_access_level) - (SELECT projects.id, #{enabled_values.join(',')} FROM projects LEFT OUTER JOIN project_features - ON project_features.project_id = projects.id - WHERE project_features.id IS NULL) - EOF - end - - def down - "Not needed" - end -end diff --git a/db/migrate/20161020075734_default_request_access_groups.rb b/db/migrate/20161020075734_default_request_access_groups.rb deleted file mode 100644 index 72aec86167e..00000000000 --- a/db/migrate/20161020075734_default_request_access_groups.rb +++ /dev/null @@ -1,12 +0,0 @@ -class DefaultRequestAccessGroups < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - def up - change_column_default :namespaces, :request_access_enabled, false - end - - def down - change_column_default :namespaces, :request_access_enabled, true - end -end diff --git a/db/migrate/20161020075830_default_request_access_projects.rb b/db/migrate/20161020075830_default_request_access_projects.rb deleted file mode 100644 index b457e39f838..00000000000 --- a/db/migrate/20161020075830_default_request_access_projects.rb +++ /dev/null @@ -1,12 +0,0 @@ -class DefaultRequestAccessProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - def up - change_column_default :projects, :request_access_enabled, false - end - - def down - change_column_default :projects, :request_access_enabled, true - 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 deleted file mode 100644 index 60352363e42..00000000000 --- a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb +++ /dev/null @@ -1,40 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - - # 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 = 'Adding a foreign key' - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def up - add_column :merge_request_metrics, :pipeline_id, :integer - add_foreign_key :merge_request_metrics, :ci_commits, column: :pipeline_id, on_delete: :cascade # rubocop: disable Migration/AddConcurrentForeignKey - add_concurrent_index :merge_request_metrics, :pipeline_id - 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_column :merge_request_metrics, :pipeline_id - end -end diff --git a/db/migrate/20161020180657_add_minimum_key_length_to_application_settings.rb b/db/migrate/20161020180657_add_minimum_key_length_to_application_settings.rb deleted file mode 100644 index 7839bee6a5b..00000000000 --- a/db/migrate/20161020180657_add_minimum_key_length_to_application_settings.rb +++ /dev/null @@ -1,29 +0,0 @@ -class AddMinimumKeyLengthToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - # A key restriction has these possible states: - # - # * -1 means "this key type is completely disabled" - # * 0 means "all keys of this type are valid" - # * > 0 means "keys must have at least this many bits to be valid" - # - # The default is 0, for backward compatibility - add_column_with_default :application_settings, :rsa_key_restriction, :integer, default: 0 - add_column_with_default :application_settings, :dsa_key_restriction, :integer, default: 0 - add_column_with_default :application_settings, :ecdsa_key_restriction, :integer, default: 0 - add_column_with_default :application_settings, :ed25519_key_restriction, :integer, default: 0 - end - - def down - remove_column :application_settings, :rsa_key_restriction - remove_column :application_settings, :dsa_key_restriction - remove_column :application_settings, :ecdsa_key_restriction - remove_column :application_settings, :ed25519_key_restriction - end -end diff --git a/db/migrate/20161021114307_add_lock_version_to_build_and_pipelines.rb b/db/migrate/20161021114307_add_lock_version_to_build_and_pipelines.rb deleted file mode 100644 index e172dc3adf2..00000000000 --- a/db/migrate/20161021114307_add_lock_version_to_build_and_pipelines.rb +++ /dev/null @@ -1,14 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddLockVersionToBuildAndPipelines < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - add_column :ci_builds, :lock_version, :integer - add_column :ci_commits, :lock_version, :integer - end -end diff --git a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb deleted file mode 100644 index d27f8fc38c8..00000000000 --- a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'json' - -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MigrateMailroomQueueFromDefault < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - - DOWNTIME_REASON = <<-EOF - Moving Sidekiq jobs from queues requires Sidekiq to be stopped. Not stopping - Sidekiq will result in the loss of jobs that are scheduled after this - migration completes. - EOF - - disable_ddl_transaction! - - # Jobs for which the queue names have been changed (e.g. multiple workers - # using the same non-default queue). - # - # The keys are the old queue names, the values the jobs to move and their new - # queue names. - RENAMED_QUEUES = { - incoming_email: { - 'EmailReceiverWorker' => :email_receiver - } - }.freeze - - def up - Sidekiq.redis do |redis| - RENAMED_QUEUES.each do |queue, jobs| - migrate_from_queue(redis, queue, jobs) - end - end - end - - def down - Sidekiq.redis do |redis| - RENAMED_QUEUES.each do |dest_queue, jobs| - jobs.each do |worker, from_queue| - migrate_from_queue(redis, from_queue, worker => dest_queue) - end - end - end - end - - def migrate_from_queue(redis, queue, job_mapping) - while job = redis.lpop("queue:#{queue}") - payload = JSON.parse(job) - new_queue = job_mapping[payload['class']] - - # If we have no target queue to migrate to we're probably dealing with - # some ancient job for which the worker no longer exists. In that case - # there's no sane option we can take, other than just dropping the job. - next unless new_queue - - payload['queue'] = new_queue - - redis.lpush("queue:#{new_queue}", JSON.dump(payload)) - end - end -end diff --git a/db/migrate/20161025231710_migrate_jira_to_gem.rb b/db/migrate/20161025231710_migrate_jira_to_gem.rb deleted file mode 100644 index aa1c59ec9e6..00000000000 --- a/db/migrate/20161025231710_migrate_jira_to_gem.rb +++ /dev/null @@ -1,73 +0,0 @@ -class MigrateJiraToGem < ActiveRecord::Migration[4.2] - DOWNTIME = true - - DOWNTIME_REASON = <<-HEREDOC - Refactor all Jira services properties(serialized field) to use new jira-ruby gem. - There were properties on old Jira service that are not needed anymore after the - service refactoring: api_url, project_url, new_issue_url, issues_url. - We extract the new necessary some properties from old keys and delete them: - taking project_key from project_url and url from api_url - HEREDOC - - def up - active_services_query = "SELECT id, properties FROM services WHERE services.type IN ('JiraService') AND services.active = true" - - select_all(active_services_query).each do |service| - id = service['id'] - properties = JSON.parse(service['properties']) - properties_was = properties.clone - - # Migrate `project_url` to `project_key` - # Ignore if `project_url` doesn't have jql project query with project key - if properties['project_url'].present? - jql = properties['project_url'].match('project=([A-Za-z]*)') - properties['project_key'] = jql.captures.first if jql - end - - # Migrate `api_url` to `url` - if properties['api_url'].present? - url = properties['api_url'].match('(.*)\/rest\/api') - properties['url'] = url.captures.first if url - end - - # Delete now unnecessary properties - properties.delete('api_url') - properties.delete('project_url') - properties.delete('new_issue_url') - properties.delete('issues_url') - - # Update changes properties - if properties != properties_was - execute("UPDATE services SET properties = '#{quote_string(properties.to_json)}' WHERE id = #{id}") - end - end - end - - def down - active_services_query = "SELECT id, properties FROM services WHERE services.type IN ('JiraService') AND services.active = true" - - select_all(active_services_query).each do |service| - id = service['id'] - properties = JSON.parse(service['properties']) - properties_was = properties.clone - - # Rebuild old properties based on sane defaults - if properties['url'].present? - properties['api_url'] = "#{properties['url']}/rest/api/2" - properties['project_url'] = - "#{properties['url']}/issues/?jql=project=#{properties['project_key']}" - properties['issues_url'] = "#{properties['url']}/browse/:id" - properties['new_issue_url'] = "#{properties['url']}/secure/CreateIssue.jspa" - end - - # Delete the new properties - properties.delete('url') - properties.delete('project_key') - - # Update changes properties - if properties != properties_was - execute("UPDATE services SET properties = '#{quote_string(properties.to_json)}' WHERE id = #{id}") - end - end - end -end diff --git a/db/migrate/20161031155516_add_housekeeping_to_application_settings.rb b/db/migrate/20161031155516_add_housekeeping_to_application_settings.rb deleted file mode 100644 index 963358fe3e5..00000000000 --- a/db/migrate/20161031155516_add_housekeeping_to_application_settings.rb +++ /dev/null @@ -1,32 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddHousekeepingToApplicationSettings < ActiveRecord::Migration[4.2] - 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_column_with_default(:application_settings, :housekeeping_enabled, :boolean, default: true, allow_null: false) - add_column_with_default(:application_settings, :housekeeping_bitmaps_enabled, :boolean, default: true, allow_null: false) - add_column_with_default(:application_settings, :housekeeping_incremental_repack_period, :integer, default: 10, allow_null: false) - add_column_with_default(:application_settings, :housekeeping_full_repack_period, :integer, default: 50, allow_null: false) - add_column_with_default(:application_settings, :housekeeping_gc_period, :integer, default: 200, allow_null: false) - end - - def down - remove_column(:application_settings, :housekeeping_enabled, :boolean, default: true, allow_null: false) - remove_column(:application_settings, :housekeeping_bitmaps_enabled, :boolean, default: true, allow_null: false) - remove_column(:application_settings, :housekeeping_incremental_repack_period, :integer, default: 10, allow_null: false) - remove_column(:application_settings, :housekeeping_full_repack_period, :integer, default: 50, allow_null: false) - remove_column(:application_settings, :housekeeping_gc_period, :integer, default: 200, allow_null: false) - end -end diff --git a/db/migrate/20161031171301_add_project_id_to_subscriptions.rb b/db/migrate/20161031171301_add_project_id_to_subscriptions.rb deleted file mode 100644 index 5fd10d9b359..00000000000 --- a/db/migrate/20161031171301_add_project_id_to_subscriptions.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddProjectIdToSubscriptions < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - add_column :subscriptions, :project_id, :integer - add_foreign_key :subscriptions, :projects, column: :project_id, on_delete: :cascade # rubocop: disable Migration/AddConcurrentForeignKey - end - - def down - remove_foreign_key :subscriptions, column: :project_id - remove_column :subscriptions, :project_id - end -end diff --git a/db/migrate/20161031174110_migrate_subscriptions_project_id.rb b/db/migrate/20161031174110_migrate_subscriptions_project_id.rb deleted file mode 100644 index 7f4087fdcd3..00000000000 --- a/db/migrate/20161031174110_migrate_subscriptions_project_id.rb +++ /dev/null @@ -1,44 +0,0 @@ -class MigrateSubscriptionsProjectId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'Subscriptions will not work as expected until this migration is complete.' - - def up - execute <<-EOF.strip_heredoc - UPDATE subscriptions - SET project_id = ( - SELECT issues.project_id - FROM issues - WHERE issues.id = subscriptions.subscribable_id - ) - WHERE subscriptions.subscribable_type = 'Issue'; - EOF - - execute <<-EOF.strip_heredoc - UPDATE subscriptions - SET project_id = ( - SELECT merge_requests.target_project_id - FROM merge_requests - WHERE merge_requests.id = subscriptions.subscribable_id - ) - WHERE subscriptions.subscribable_type = 'MergeRequest'; - EOF - - execute <<-EOF.strip_heredoc - UPDATE subscriptions - SET project_id = ( - SELECT projects.id - FROM labels INNER JOIN projects ON projects.id = labels.project_id - WHERE labels.id = subscriptions.subscribable_id - ) - WHERE subscriptions.subscribable_type = 'Label'; - EOF - end - - def down - execute <<-EOF.strip_heredoc - UPDATE subscriptions SET project_id = NULL; - EOF - end -end diff --git a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb deleted file mode 100644 index 9005b42b41f..00000000000 --- a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb +++ /dev/null @@ -1,19 +0,0 @@ -# rubocop:disable RemoveIndex -class AddUniqueIndexToSubscriptions < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because it changes a column to not accept null values.' - - disable_ddl_transaction! - - def up - add_concurrent_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id, :project_id], { unique: true, name: 'index_subscriptions_on_subscribable_and_user_id_and_project_id' } - remove_index :subscriptions, name: 'subscriptions_user_id_and_ref_fields' if index_name_exists?(:subscriptions, 'subscriptions_user_id_and_ref_fields') - end - - def down - add_concurrent_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id], { unique: true, name: 'subscriptions_user_id_and_ref_fields' } - remove_index :subscriptions, name: 'index_subscriptions_on_subscribable_and_user_id_and_project_id' if index_name_exists?(:subscriptions, 'index_subscriptions_on_subscribable_and_user_id_and_project_id') - end -end diff --git a/db/migrate/20161103171205_rename_repository_storage_column.rb b/db/migrate/20161103171205_rename_repository_storage_column.rb deleted file mode 100644 index d6050500e47..00000000000 --- a/db/migrate/20161103171205_rename_repository_storage_column.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameRepositoryStorageColumn < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - - # 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 = 'Renaming the application_settings.repository_storage column' - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - rename_column :application_settings, :repository_storage, :repository_storages - end -end diff --git a/db/migrate/20161103191444_add_sidekiq_throttling_to_application_settings.rb b/db/migrate/20161103191444_add_sidekiq_throttling_to_application_settings.rb deleted file mode 100644 index 83c51c83509..00000000000 --- a/db/migrate/20161103191444_add_sidekiq_throttling_to_application_settings.rb +++ /dev/null @@ -1,32 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/SaferBooleanColumn -class AddSidekiqThrottlingToApplicationSettings < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 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 :application_settings, :sidekiq_throttling_enabled, :boolean, default: false - add_column :application_settings, :sidekiq_throttling_queues, :string - add_column :application_settings, :sidekiq_throttling_factor, :decimal - end -end diff --git a/db/migrate/20161106185620_add_project_import_data_project_index.rb b/db/migrate/20161106185620_add_project_import_data_project_index.rb deleted file mode 100644 index 46809ca1707..00000000000 --- a/db/migrate/20161106185620_add_project_import_data_project_index.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable RemoveIndex -class AddProjectImportDataProjectIndex < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :project_import_data, :project_id - end - - def down - remove_index :project_import_data, :project_id if index_exists? :project_import_data, :project_id - end -end diff --git a/db/migrate/20161113184239_create_user_chat_names_table.rb b/db/migrate/20161113184239_create_user_chat_names_table.rb deleted file mode 100644 index 0031ca66afe..00000000000 --- a/db/migrate/20161113184239_create_user_chat_names_table.rb +++ /dev/null @@ -1,22 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateUserChatNamesTable < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :chat_names do |t| - t.integer :user_id, null: false - t.integer :service_id, null: false - t.string :team_id, null: false - t.string :team_domain - t.string :chat_id, null: false - t.string :chat_name - t.datetime :last_used_at - t.timestamps null: false - end - - add_index :chat_names, [:user_id, :service_id], unique: true - add_index :chat_names, [:service_id, :team_id, :chat_id], unique: true - end -end diff --git a/db/migrate/20161114024742_add_coverage_regex_to_builds.rb b/db/migrate/20161114024742_add_coverage_regex_to_builds.rb deleted file mode 100644 index 631968b4aee..00000000000 --- a/db/migrate/20161114024742_add_coverage_regex_to_builds.rb +++ /dev/null @@ -1,13 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddCoverageRegexToBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - add_column :ci_builds, :coverage_regex, :string - end -end diff --git a/db/migrate/20161115173905_add_start_date_to_milestones.rb b/db/migrate/20161115173905_add_start_date_to_milestones.rb deleted file mode 100644 index 847c4f0bebb..00000000000 --- a/db/migrate/20161115173905_add_start_date_to_milestones.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddStartDateToMilestones < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :milestones, :start_date, :date - end -end diff --git a/db/migrate/20161118183841_add_commit_events_to_services.rb b/db/migrate/20161118183841_add_commit_events_to_services.rb deleted file mode 100644 index 0eb08915118..00000000000 --- a/db/migrate/20161118183841_add_commit_events_to_services.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddCommitEventsToServices < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:services, :commit_events, :boolean, default: true, allow_null: false) - end - - def down - remove_column(:services, :commit_events) - end -end diff --git a/db/migrate/20161124111390_add_parent_id_to_namespace.rb b/db/migrate/20161124111390_add_parent_id_to_namespace.rb deleted file mode 100644 index 67f6aee2b9c..00000000000 --- a/db/migrate/20161124111390_add_parent_id_to_namespace.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddParentIdToNamespace < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column(:namespaces, :parent_id, :integer) - end -end diff --git a/db/migrate/20161124111395_add_index_to_parent_id.rb b/db/migrate/20161124111395_add_index_to_parent_id.rb deleted file mode 100644 index d7a51ec905a..00000000000 --- a/db/migrate/20161124111395_add_index_to_parent_id.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddIndexToParentId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index(:namespaces, [:parent_id, :id], unique: true) - end - - def down - remove_index :namespaces, [:parent_id, :id] if index_exists? :namespaces, [:parent_id, :id] - end -end diff --git a/db/migrate/20161124111402_add_routes_table.rb b/db/migrate/20161124111402_add_routes_table.rb deleted file mode 100644 index 36f49ef8c97..00000000000 --- a/db/migrate/20161124111402_add_routes_table.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/Timestamps -class AddRoutesTable < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :routes do |t| - t.integer :source_id, null: false - t.string :source_type, null: false - t.string :path, null: false - - t.timestamps - end - end -end diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb deleted file mode 100644 index 0772821210c..00000000000 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ /dev/null @@ -1,105 +0,0 @@ -class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - class Repository - attr_reader :storage - - def initialize(storage, relative_path) - @storage = storage - @relative_path = relative_path - end - - def gitaly_repository - Gitaly::Repository.new(storage_name: @storage, relative_path: @relative_path) - end - end - - class Project < ActiveRecord::Base - def self.find_including_path(id) - select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace") - .joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id') - .find_by(id: id) - end - - def commit(rev) - Gitlab::GitalyClient::CommitService.new(repository).find_commit(rev) - end - - def repository - @repository ||= Repository.new(repository_storage, read_attribute(:path_with_namespace) + '.git') - end - end - - DOWNTIME = true - DOWNTIME_REASON = 'Existing workers will error until they are using a newer version of the code' - - disable_ddl_transaction! - - def up - Sidekiq.redis do |redis| - new_jobs = [] - - while job = redis.lpop('queue:process_commit') - payload = JSON.parse(job) - project = Project.find_including_path(payload['args'][0]) - - next unless project - - commit = project.commit(payload['args'][2]) - next unless commit - - hash = { - id: commit.id, - message: encode(commit.body), - parent_ids: commit.parent_ids.to_a, - authored_date: Time.at(commit.author.date.seconds).utc, - author_name: encode(commit.author.name), - author_email: encode(commit.author.email), - committed_date: Time.at(commit.committer.date.seconds).utc, - committer_email: encode(commit.committer.email), - committer_name: encode(commit.committer.name) - } - - payload['args'][2] = hash - - new_jobs << JSON.dump(payload) - end - - redis.multi do |multi| - new_jobs.each do |j| - multi.lpush('queue:process_commit', j) - end - end - end - end - - def down - Sidekiq.redis do |redis| - new_jobs = [] - - while job = redis.lpop('queue:process_commit') - payload = JSON.parse(job) - - payload['args'][2] = payload['args'][2]['id'] - - new_jobs << JSON.dump(payload) - end - - redis.multi do |multi| - new_jobs.each do |j| - multi.lpush('queue:process_commit', j) - end - end - end - end - - def encode(data) - encoding = Encoding::UTF_8 - - if data.encoding == encoding - data - else - data.encode(encoding, invalid: :replace, undef: :replace) - end - end -end diff --git a/db/migrate/20161128095517_add_in_reply_to_discussion_id_to_sent_notifications.rb b/db/migrate/20161128095517_add_in_reply_to_discussion_id_to_sent_notifications.rb deleted file mode 100644 index a2971486014..00000000000 --- a/db/migrate/20161128095517_add_in_reply_to_discussion_id_to_sent_notifications.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddInReplyToDiscussionIdToSentNotifications < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 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 :sent_notifications, :in_reply_to_discussion_id, :string - end -end diff --git a/db/migrate/20161128142110_remove_unnecessary_indexes.rb b/db/migrate/20161128142110_remove_unnecessary_indexes.rb deleted file mode 100644 index b6c6e303ec7..00000000000 --- a/db/migrate/20161128142110_remove_unnecessary_indexes.rb +++ /dev/null @@ -1,34 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class RemoveUnnecessaryIndexes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - remove_index :labels, column: :group_id if index_exists?(:labels, :group_id) - remove_index :award_emoji, column: :user_id if index_exists?(:award_emoji, :user_id) - remove_index :ci_builds, column: :commit_id if index_exists?(:ci_builds, :commit_id) - remove_index :deployments, column: :project_id if index_exists?(:deployments, :project_id) - remove_index :deployments, column: %w(project_id environment_id) if index_exists?(:deployments, %w(project_id environment_id)) - remove_index :lists, column: :board_id if index_exists?(:lists, :board_id) - remove_index :milestones, column: :project_id if index_exists?(:milestones, :project_id) - remove_index :notes, column: :project_id if index_exists?(:notes, :project_id) - remove_index :users_star_projects, column: :user_id if index_exists?(:users_star_projects, :user_id) - end - - def down - add_concurrent_index :labels, :group_id - add_concurrent_index :award_emoji, :user_id - add_concurrent_index :ci_builds, :commit_id - add_concurrent_index :deployments, :project_id - add_concurrent_index :deployments, %w(project_id environment_id) - add_concurrent_index :lists, :board_id - add_concurrent_index :milestones, :project_id - add_concurrent_index :notes, :project_id - add_concurrent_index :users_star_projects, :user_id - end -end diff --git a/db/migrate/20161128161412_add_html_emails_enabled_to_application_settings.rb b/db/migrate/20161128161412_add_html_emails_enabled_to_application_settings.rb deleted file mode 100644 index 63139eb97bd..00000000000 --- a/db/migrate/20161128161412_add_html_emails_enabled_to_application_settings.rb +++ /dev/null @@ -1,30 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/SaferBooleanColumn -class AddHtmlEmailsEnabledToApplicationSettings < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 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 :application_settings, :html_emails_enabled, :boolean, default: true - end -end diff --git a/db/migrate/20161130095245_fill_routes_table.rb b/db/migrate/20161130095245_fill_routes_table.rb deleted file mode 100644 index 712be187c7c..00000000000 --- a/db/migrate/20161130095245_fill_routes_table.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class FillRoutesTable < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'No new namespaces should be created during data copy' - - def up - execute <<-EOF - INSERT INTO routes - (source_id, source_type, path) - (SELECT id, 'Namespace', path FROM namespaces) - EOF - end - - def down - execute("DELETE FROM routes WHERE source_type = 'Namespace'") - end -end diff --git a/db/migrate/20161130101252_fill_projects_routes_table.rb b/db/migrate/20161130101252_fill_projects_routes_table.rb deleted file mode 100644 index 1900d6c8013..00000000000 --- a/db/migrate/20161130101252_fill_projects_routes_table.rb +++ /dev/null @@ -1,30 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class FillProjectsRoutesTable < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'No new projects should be created during data copy' - - def up - if Gitlab::Database.postgresql? - execute <<-EOF - INSERT INTO routes (source_id, source_type, path) - (SELECT DISTINCT ON (namespaces.path, projects.path) projects.id, 'Project', concat(namespaces.path, '/', projects.path) - FROM projects INNER JOIN namespaces ON projects.namespace_id = namespaces.id - ORDER BY namespaces.path, projects.path, projects.id DESC) - EOF - else - execute <<-EOF - INSERT INTO routes (source_id, source_type, path) - (SELECT projects.id, 'Project', concat(namespaces.path, '/', projects.path) - FROM projects INNER JOIN namespaces ON projects.namespace_id = namespaces.id) - EOF - end - end - - def down - execute("DELETE FROM routes WHERE source_type = 'Project'") - end -end diff --git a/db/migrate/20161201001911_add_plant_uml_url_to_application_settings.rb b/db/migrate/20161201001911_add_plant_uml_url_to_application_settings.rb deleted file mode 100644 index 79558a6b3b9..00000000000 --- a/db/migrate/20161201001911_add_plant_uml_url_to_application_settings.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddPlantUmlUrlToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, :plantuml_url, :string - end -end diff --git a/db/migrate/20161201155511_create_project_statistics.rb b/db/migrate/20161201155511_create_project_statistics.rb deleted file mode 100644 index 6dcb5adb82b..00000000000 --- a/db/migrate/20161201155511_create_project_statistics.rb +++ /dev/null @@ -1,20 +0,0 @@ -class CreateProjectStatistics < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - # use bigint columns to support values >2GB - counter_column = { limit: 8, null: false, default: 0 } - - create_table :project_statistics do |t| - t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } - t.references :namespace, null: false, index: true - t.integer :commit_count, counter_column - t.integer :storage_size, counter_column - t.integer :repository_size, counter_column - t.integer :lfs_objects_size, counter_column - t.integer :build_artifacts_size, counter_column - end - end -end diff --git a/db/migrate/20161201160452_migrate_project_statistics.rb b/db/migrate/20161201160452_migrate_project_statistics.rb deleted file mode 100644 index 42c5be07e83..00000000000 --- a/db/migrate/20161201160452_migrate_project_statistics.rb +++ /dev/null @@ -1,25 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -class MigrateProjectStatistics < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'Removes two columns from the projects table' - - def up - # convert repository_size in float (megabytes) to integer (bytes), - # initialize total storage_size with repository_size - execute <<-EOF - INSERT INTO project_statistics (project_id, namespace_id, commit_count, storage_size, repository_size) - SELECT id, namespace_id, commit_count, (repository_size * 1024 * 1024), (repository_size * 1024 * 1024) FROM projects - EOF - - remove_column :projects, :repository_size - remove_column :projects, :commit_count - end - - # rubocop: disable Migration/AddColumn - def down - add_column :projects, :repository_size, :float, default: 0.0 - add_column :projects, :commit_count, :integer, default: 0 - end -end diff --git a/db/migrate/20161202152031_remove_duplicates_from_routes.rb b/db/migrate/20161202152031_remove_duplicates_from_routes.rb deleted file mode 100644 index 0615f683859..00000000000 --- a/db/migrate/20161202152031_remove_duplicates_from_routes.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveDuplicatesFromRoutes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - # We can skip this migration when running a PostgreSQL database because - # we use an optimized query in the "FillProjectsRoutesTable" migration - # to fill these values that avoid duplicate entries in the routes table. - return unless Gitlab::Database.mysql? - - execute <<-EOF - DELETE duplicated_rows.* - FROM routes AS duplicated_rows - INNER JOIN ( - SELECT path, MAX(id) as max_id - FROM routes - GROUP BY path - HAVING COUNT(*) > 1 - ) AS good_rows ON good_rows.path = duplicated_rows.path AND good_rows.max_id <> duplicated_rows.id; - EOF - end - - def down - end -end diff --git a/db/migrate/20161202152035_add_index_to_routes.rb b/db/migrate/20161202152035_add_index_to_routes.rb deleted file mode 100644 index ad2e0cd13c9..00000000000 --- a/db/migrate/20161202152035_add_index_to_routes.rb +++ /dev/null @@ -1,22 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddIndexToRoutes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index(:routes, :path, unique: true) - add_concurrent_index(:routes, [:source_type, :source_id], unique: true) - end - - def down - remove_index(:routes, :path) if index_exists? :routes, :path - remove_index(:routes, [:source_type, :source_id]) if index_exists? :routes, [:source_type, :source_id] - end -end diff --git a/db/migrate/20161206003819_add_plant_uml_enabled_to_application_settings.rb b/db/migrate/20161206003819_add_plant_uml_enabled_to_application_settings.rb deleted file mode 100644 index bb44d56ee56..00000000000 --- a/db/migrate/20161206003819_add_plant_uml_enabled_to_application_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/SaferBooleanColumn -class AddPlantUmlEnabledToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, :plantuml_enabled, :boolean - end -end diff --git a/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb b/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb deleted file mode 100644 index c301d76646e..00000000000 --- a/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb +++ /dev/null @@ -1,37 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class RemoveUniqPathIndexFromNamespace < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - - def up - constraint_name = 'namespaces_path_key' - - transaction do - if index_exists?(:namespaces, :path) - remove_index(:namespaces, :path) - end - - # In some bizarre cases PostgreSQL might have a separate unique constraint - # that we'll need to drop. - if constraint_exists?(constraint_name) && Gitlab::Database.postgresql? - execute("ALTER TABLE namespaces DROP CONSTRAINT IF EXISTS #{constraint_name};") - end - end - end - - def down - unless index_exists?(:namespaces, :path) - add_concurrent_index(:namespaces, :path, unique: true) - end - end - - def constraint_exists?(name) - indexes(:namespaces).map(&:name).include?(name) - end -end diff --git a/db/migrate/20161206153751_add_path_index_to_namespace.rb b/db/migrate/20161206153751_add_path_index_to_namespace.rb deleted file mode 100644 index f0848cc59a5..00000000000 --- a/db/migrate/20161206153751_add_path_index_to_namespace.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddPathIndexToNamespace < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_concurrent_index :namespaces, :path - end - - def down - if index_exists?(:namespaces, :path) - remove_index :namespaces, :path - end - end -end diff --git a/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb b/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb deleted file mode 100644 index 13660cec7aa..00000000000 --- a/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb +++ /dev/null @@ -1,37 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class RemoveUniqNameIndexFromNamespace < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - - def up - constraint_name = 'namespaces_name_key' - - transaction do - if index_exists?(:namespaces, :name) - remove_index(:namespaces, :name) - end - - # In some bizarre cases PostgreSQL might have a separate unique constraint - # that we'll need to drop. - if constraint_exists?(constraint_name) && Gitlab::Database.postgresql? - execute("ALTER TABLE namespaces DROP CONSTRAINT IF EXISTS #{constraint_name};") - end - end - end - - def down - unless index_exists?(:namespaces, :name) - add_concurrent_index(:namespaces, :name, unique: true) - end - end - - def constraint_exists?(name) - indexes(:namespaces).map(&:name).include?(name) - end -end diff --git a/db/migrate/20161206153754_add_name_index_to_namespace.rb b/db/migrate/20161206153754_add_name_index_to_namespace.rb deleted file mode 100644 index 14152a6dc07..00000000000 --- a/db/migrate/20161206153754_add_name_index_to_namespace.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddNameIndexToNamespace < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_concurrent_index(:namespaces, [:name, :parent_id], unique: true) - end - - def down - if index_exists?(:namespaces, [:name, :parent_id]) - remove_index :namespaces, [:name, :parent_id] - end - end -end diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb deleted file mode 100644 index 420f0ccb45c..00000000000 --- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb +++ /dev/null @@ -1,53 +0,0 @@ -class FixupEnvironmentNameUniqueness < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'Renaming non-unique environments' - - def up - environments = Arel::Table.new(:environments) - - # Get all [project_id, name] pairs that occur more than once - finder_sql = environments - .group(environments[:project_id], environments[:name]) - .having(Arel.sql("COUNT(1)").gt(1)) - .project(environments[:project_id], environments[:name]) - .to_sql - - conflicting = connection.exec_query(finder_sql) - - conflicting.rows.each do |project_id, name| - fix_duplicates(project_id, name) - end - end - - def down - # Nothing to do - end - - # Rename conflicting environments by appending "-#{id}" to all but the first - def fix_duplicates(project_id, name) - environments = Arel::Table.new(:environments) - finder_sql = environments - .where(environments[:project_id].eq(project_id)) - .where(environments[:name].eq(name)) - .order(environments[:id].asc) - .project(environments[:id], environments[:name]) - .to_sql - - # Now we have the data for all the conflicting rows - conflicts = connection.exec_query(finder_sql).rows - conflicts.shift # Leave the first row alone - - conflicts.each do |id, name| - update_sql = - Arel::UpdateManager.new - .table(environments) - .set(environments[:name] => name + "-" + id.to_s) - .where(environments[:id].eq(id)) - .to_sql - - connection.exec_update(update_sql, self.class.name, []) - end - end -end diff --git a/db/migrate/20161207231621_create_environment_name_unique_index.rb b/db/migrate/20161207231621_create_environment_name_unique_index.rb deleted file mode 100644 index 28d22664405..00000000000 --- a/db/migrate/20161207231621_create_environment_name_unique_index.rb +++ /dev/null @@ -1,19 +0,0 @@ -# rubocop:disable RemoveIndex -class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = true - DOWNTIME_REASON = 'Making a non-unique index into a unique index' - - def up - remove_index :environments, [:project_id, :name] - add_concurrent_index :environments, [:project_id, :name], unique: true - end - - def down - remove_index :environments, [:project_id, :name] - add_concurrent_index :environments, [:project_id, :name], unique: true - end -end diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb deleted file mode 100644 index 993b9bd3330..00000000000 --- a/db/migrate/20161207231626_add_environment_slug.rb +++ /dev/null @@ -1,68 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddEnvironmentSlug < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'Adding NOT NULL column environments.slug with dependent data' - - # Used to generate random suffixes for the slug - LETTERS = 'a'..'z' - NUMBERS = '0'..'9' - SUFFIX_CHARS = LETTERS.to_a + NUMBERS.to_a - - def up - environments = Arel::Table.new(:environments) - - add_column :environments, :slug, :string - finder = environments.project(:id, :name) - - connection.exec_query(finder.to_sql).rows.each do |id, name| - updater = Arel::UpdateManager.new - .table(environments) - .set(environments[:slug] => generate_slug(name)) - .where(environments[:id].eq(id)) - - connection.exec_update(updater.to_sql, self.class.name, []) - end - - change_column_null :environments, :slug, false - end - - def down - remove_column :environments, :slug - end - - # Copy of the Environment#generate_slug implementation - def generate_slug(name) - # Lowercase letters and numbers only - slugified = name.to_s.downcase.gsub(/[^a-z0-9]/, '-') - - # Must start with a letter - slugified = 'env-' + slugified unless LETTERS.cover?(slugified[0]) - - # Repeated dashes are invalid (OpenShift limitation) - slugified.gsub!(/\-+/, '-') - - # Maximum length: 24 characters (OpenShift limitation) - slugified = slugified[0..23] - - # Cannot end with a dash (Kubernetes label limitation) - slugified.chop! if slugified.end_with?('-') - - # Add a random suffix, shortening the current string if necessary, if it - # has been slugified. This ensures uniqueness. - if slugified != name - slugified = slugified[0..16] - slugified << '-' unless slugified.end_with?('-') - slugified << random_suffix - end - - slugified - end - - def random_suffix - (0..5).map { SUFFIX_CHARS.sample }.join - 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 deleted file mode 100644 index 57606a33cb9..00000000000 --- a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb +++ /dev/null @@ -1,20 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = 'Adding a *unique* index to environments.slug' - - disable_ddl_transaction! - - def up - add_concurrent_index :environments, [:project_id, :slug], unique: true - end - - def down - remove_index :environments, [:project_id, :slug] if index_exists? :environments, [:project_id, :slug] - end -end diff --git a/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb b/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb deleted file mode 100644 index e8ea9cf8fda..00000000000 --- a/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb +++ /dev/null @@ -1,37 +0,0 @@ -class CreateDoorkeeperOpenidConnectTables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - create_table :oauth_openid_requests do |t| - t.integer :access_grant_id, null: false - t.string :nonce, null: false - end - - if Gitlab::Database.postgresql? - # add foreign key without validation to avoid downtime on PostgreSQL, - # also see db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb - execute %q{ - ALTER TABLE "oauth_openid_requests" - ADD CONSTRAINT "fk_oauth_openid_requests_oauth_access_grants_access_grant_id" - FOREIGN KEY ("access_grant_id") - REFERENCES "oauth_access_grants" ("id") - NOT VALID; - } - else - execute %q{ - ALTER TABLE oauth_openid_requests - ADD CONSTRAINT fk_oauth_openid_requests_oauth_access_grants_access_grant_id - FOREIGN KEY (access_grant_id) - REFERENCES oauth_access_grants (id); - } - end - end - - def down - drop_table :oauth_openid_requests - 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 deleted file mode 100644 index 92a12dbc699..00000000000 --- a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb +++ /dev/null @@ -1,23 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddLowerPathIndexToRoutes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - return unless Gitlab::Database.postgresql? - - execute 'CREATE INDEX CONCURRENTLY index_on_routes_lower_path ON routes (LOWER(path));' - end - - def down - return unless Gitlab::Database.postgresql? - - 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/20161213172958_change_slack_service_to_slack_notification_service.rb b/db/migrate/20161213172958_change_slack_service_to_slack_notification_service.rb deleted file mode 100644 index babac6bfc4f..00000000000 --- a/db/migrate/20161213172958_change_slack_service_to_slack_notification_service.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ChangeSlackServiceToSlackNotificationService < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - # This migration is a no-op, as it existed in an RC but we renamed - # SlackNotificationService back to SlackService: - # https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8191#note_20310845 - def change - end -end diff --git a/db/migrate/20161220141214_remove_dot_git_from_group_names.rb b/db/migrate/20161220141214_remove_dot_git_from_group_names.rb deleted file mode 100644 index 5c0b083325e..00000000000 --- a/db/migrate/20161220141214_remove_dot_git_from_group_names.rb +++ /dev/null @@ -1,82 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveDotGitFromGroupNames < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - include Gitlab::ShellAdapter - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def up - invalid_groups.each do |group| - path_was = group['path'] - path_was_wildcard = quote_string("#{path_was}/%") - path = quote_string(rename_path(path_was)) - - move_namespace(group['id'], path_was, path) - - execute "UPDATE routes SET path = '#{path}' WHERE source_type = 'Namespace' AND source_id = #{group['id']}" - execute "UPDATE namespaces SET path = '#{path}' WHERE id = #{group['id']}" - - select_all("SELECT id, path FROM routes WHERE path LIKE '#{path_was_wildcard}'").each do |route| - new_path = "#{path}/#{route['path'].split('/').last}" - execute "UPDATE routes SET path = '#{new_path}' WHERE id = #{route['id']}" - end - end - end - - def down - # nothing to do here - end - - private - - def invalid_groups - select_all("SELECT id, path FROM namespaces WHERE type = 'Group' AND path LIKE '%.git'") - end - - def route_exists?(path) - select_all("SELECT id, path FROM routes WHERE path = '#{quote_string(path)}'").present? - end - - # Accepts invalid path like test.git and returns test_git or - # test_git1 if test_git already taken - def rename_path(path) - # To stay closer with original name and reduce risk of duplicates - # we rename suffix instead of removing it - path = path.sub(/\.git\z/, '_git') - - counter = 0 - base = path - - while route_exists?(path) - counter += 1 - path = "#{base}#{counter}" - end - - path - end - - def move_namespace(group_id, path_was, path) - repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{group_id}").map do |row| - row['repository_storage'] - end.compact - - # Move the namespace directory in all storages paths used by member projects - repository_storages.each do |repository_storage| - # Ensure old directory exists before moving it - gitlab_shell.add_namespace(repository_storage, path_was) - - unless gitlab_shell.mv_namespace(repository_storage, path_was, path) - Rails.logger.error "Exception moving on shard #{repository_storage} from #{path_was} to #{path}" - - # if we cannot move namespace directory we should rollback - # db changes in order to prevent out of sync between db and fs - raise Exception.new('namespace directory cannot be moved') - end - end - - Gitlab::UploadsTransfer.new.rename_namespace(path_was, path) - end -end diff --git a/db/migrate/20161221152132_add_last_used_at_to_key.rb b/db/migrate/20161221152132_add_last_used_at_to_key.rb deleted file mode 100644 index a5b3f2b6f4b..00000000000 --- a/db/migrate/20161221152132_add_last_used_at_to_key.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable Migration/Datetime -class AddLastUsedAtToKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :keys, :last_used_at, :datetime - end -end diff --git a/db/migrate/20161223034433_add_estimate_to_issuables_ce.rb b/db/migrate/20161223034433_add_estimate_to_issuables_ce.rb deleted file mode 100644 index 75bea41387c..00000000000 --- a/db/migrate/20161223034433_add_estimate_to_issuables_ce.rb +++ /dev/null @@ -1,25 +0,0 @@ -class AddEstimateToIssuablesCe < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - unless column_exists?(:issues, :time_estimate) - add_column :issues, :time_estimate, :integer - end - - unless column_exists?(:merge_requests, :time_estimate) - add_column :merge_requests, :time_estimate, :integer - end - end - - def down - if column_exists?(:issues, :time_estimate) - remove_column :issues, :time_estimate - end - - if column_exists?(:merge_requests, :time_estimate) - remove_column :merge_requests, :time_estimate - end - end -end diff --git a/db/migrate/20161223034646_create_timelogs_ce.rb b/db/migrate/20161223034646_create_timelogs_ce.rb deleted file mode 100644 index 489a2b35dfd..00000000000 --- a/db/migrate/20161223034646_create_timelogs_ce.rb +++ /dev/null @@ -1,25 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateTimelogsCe < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - unless table_exists?(:timelogs) - create_table :timelogs do |t| - t.integer :time_spent, null: false - t.references :trackable, polymorphic: true - t.references :user - - t.timestamps null: false - end - - add_index :timelogs, [:trackable_type, :trackable_id] - add_index :timelogs, :user_id - end - end - - def down - drop_table :timelogs if table_exists?(:timelogs) - end -end diff --git a/db/migrate/20161226122833_remove_dot_git_from_usernames.rb b/db/migrate/20161226122833_remove_dot_git_from_usernames.rb deleted file mode 100644 index e3318780151..00000000000 --- a/db/migrate/20161226122833_remove_dot_git_from_usernames.rb +++ /dev/null @@ -1,110 +0,0 @@ -class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - include Gitlab::ShellAdapter - - DOWNTIME = false - - def up - invalid_users.each do |user| - id = user['id'] - namespace_id = user['namespace_id'] - path_was = user['username'] - path_was_wildcard = quote_string("#{path_was}/%") - path = quote_string(new_path(path_was)) - - move_namespace(namespace_id, path_was, path) - - begin - execute "UPDATE routes SET path = '#{path}' WHERE source_type = 'Namespace' AND source_id = #{namespace_id}" - execute "UPDATE namespaces SET path = '#{path}' WHERE id = #{namespace_id}" - execute "UPDATE users SET username = '#{path}' WHERE id = #{id}" - - select_all("SELECT id, path FROM routes WHERE path LIKE '#{path_was_wildcard}'").each do |route| - new_path = "#{path}/#{route['path'].split('/').last}" - execute "UPDATE routes SET path = '#{new_path}' WHERE id = #{route['id']}" - end - rescue => e - say("Couldn't update routes for path #{path_was} to #{path}") - # Move namespace back - move_namespace(namespace_id, path, path_was) - - raise e - end - end - end - - def down - # nothing to do here - end - - private - - def invalid_users - select_all("SELECT u.id, u.username, n.path AS namespace_path, n.id AS namespace_id FROM users u - INNER JOIN namespaces n ON n.owner_id = u.id - WHERE n.type is NULL AND n.path LIKE '%.git'") - end - - def route_exists?(path) - select_all("SELECT id, path FROM routes WHERE path = '#{quote_string(path)}'").present? - end - - def path_exists?(shard, repository_storage_path) - repository_storage_path && gitlab_shell.exists?(shard, repository_storage_path) - end - - # Accepts invalid path like test.git and returns test_git or - # test_git1 if test_git already taken - def new_path(path) - # To stay closer with original name and reduce risk of duplicates - # we rename suffix instead of removing it - path = path.sub(/\.git\z/, '_git') - - check_routes(path.dup, 0, path) - end - - def check_routes(base, counter, path) - route_exists = route_exists?(path) - - Gitlab.config.repositories.storages.each do |shard, _storage| - if route_exists || path_exists?(shard, path) - counter += 1 - path = "#{base}#{counter}" - - return check_routes(base, counter, path) - end - end - - path - end - - def move_namespace(namespace_id, path_was, path) - repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{namespace_id}").map do |row| - row['repository_storage'] - end.compact - - # Move the namespace directory in all storages used by member projects - repository_storages.each do |repository_storage| - # Ensure old directory exists before moving it - gitlab_shell.add_namespace(repository_storage, path_was) - - unless gitlab_shell.mv_namespace(repository_storage, path_was, path) - Rails.logger.error "Exception moving on shard #{repository_storage} from #{path_was} to #{path}" - - # if we cannot move namespace directory we should rollback - # db changes in order to prevent out of sync between db and fs - raise Exception.new('namespace directory cannot be moved') - end - end - - begin - Gitlab::UploadsTransfer.new.rename_namespace(path_was, path) - rescue => e - if path.nil? - say("Couldn't find a storage path for #{namespace_id}, #{path_was} -- skipping") - else - raise e - end - end - end -end diff --git a/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb b/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb deleted file mode 100644 index df5714278f2..00000000000 --- a/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb +++ /dev/null @@ -1,28 +0,0 @@ -# rubocop:disable Migration/UpdateColumnInBatches -class RenameSlackAndMattermostNotificationServices < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - update_column_in_batches(:services, :type, 'SlackService') do |table, query| - query.where(table[:type].eq('SlackNotificationService')) - end - - update_column_in_batches(:services, :type, 'MattermostService') do |table, query| - query.where(table[:type].eq('MattermostNotificationService')) - end - end - - def down - update_column_in_batches(:services, :type, 'SlackNotificationService') do |table, query| - query.where(table[:type].eq('SlackService')) - end - - update_column_in_batches(:services, :type, 'MattermostNotificationService') do |table, query| - query.where(table[:type].eq('MattermostService')) - end - end -end diff --git a/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb b/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb deleted file mode 100644 index f9f8f11316d..00000000000 --- a/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/Datetime -class ChangeExpiresAtToDateInPersonalAccessTokens < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because it alters expires_at column from datetime to date' - - def up - change_column :personal_access_tokens, :expires_at, :date - end - - def down - change_column :personal_access_tokens, :expires_at, :datetime - end -end diff --git a/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb b/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb deleted file mode 100644 index 489d7fb8b75..00000000000 --- a/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddImpersonationToPersonalAccessTokens < ActiveRecord::Migration[4.2] - 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 :personal_access_tokens, :impersonation, :boolean, default: false, allow_null: false - end - - def down - remove_column :personal_access_tokens, :impersonation - end -end diff --git a/db/migrate/20170120131253_create_chat_teams.rb b/db/migrate/20170120131253_create_chat_teams.rb deleted file mode 100644 index e9b9bd7bd2f..00000000000 --- a/db/migrate/20170120131253_create_chat_teams.rb +++ /dev/null @@ -1,19 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateChatTeams < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = "Adding a foreign key" - - disable_ddl_transaction! - - def change - create_table :chat_teams do |t| - t.references :namespace, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } - t.string :team_id - t.string :name - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb b/db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb deleted file mode 100644 index cc1a4d2db59..00000000000 --- a/db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexToCiBuildsForStatusRunnerIdAndType < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_builds, [:status, :type, :runner_id] - end - - def down - if index_exists?(:ci_builds, [:status, :type, :runner_id]) - remove_index :ci_builds, column: [:status, :type, :runner_id] - end - end -end diff --git a/db/migrate/20170121130655_add_index_to_ci_runners_for_is_shared.rb b/db/migrate/20170121130655_add_index_to_ci_runners_for_is_shared.rb deleted file mode 100644 index 1b83ce4cfe3..00000000000 --- a/db/migrate/20170121130655_add_index_to_ci_runners_for_is_shared.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexToCiRunnersForIsShared < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_runners, :is_shared - end - - def down - if index_exists?(:ci_runners, :is_shared) - remove_index :ci_runners, :is_shared - end - end -end diff --git a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb deleted file mode 100644 index ffd966be086..00000000000 --- a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb +++ /dev/null @@ -1,57 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddForeignKeysToTimelogs < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - disable_ddl_transaction! - - def up - change_table :timelogs do |t| - t.column :issue_id, :integer - t.column :merge_request_id, :integer - end - - add_concurrent_index :timelogs, :issue_id - add_concurrent_index :timelogs, :merge_request_id - - if Gitlab::Database.postgresql? - execute <<-EOF - ALTER TABLE timelogs ADD CONSTRAINT "fk_timelogs_issues_issue_id" FOREIGN KEY (issue_id) REFERENCES "issues" (id) ON DELETE CASCADE NOT VALID; - ALTER TABLE timelogs ADD CONSTRAINT "fk_timelogs_merge_requests_merge_request_id" FOREIGN KEY (merge_request_id) REFERENCES "merge_requests" (id) ON DELETE CASCADE NOT VALID; - EOF - else - execute "ALTER TABLE timelogs ADD CONSTRAINT fk_timelogs_issues_issue_id FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;" - execute "ALTER TABLE timelogs ADD CONSTRAINT fk_timelogs_merge_requests_merge_request_id FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;" - end - - Timelog.where(trackable_type: 'Issue').update_all("issue_id = trackable_id") - Timelog.where(trackable_type: 'MergeRequest').update_all("merge_request_id = trackable_id") - end - - def down - 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/20170124193147_add_two_factor_columns_to_namespaces.rb b/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb deleted file mode 100644 index 324e051666b..00000000000 --- a/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb +++ /dev/null @@ -1,22 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class AddTwoFactorColumnsToNamespaces < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:namespaces, :require_two_factor_authentication, :boolean, default: false) - add_column_with_default(:namespaces, :two_factor_grace_period, :integer, default: 48) - - add_concurrent_index(:namespaces, :require_two_factor_authentication) - end - - def down - remove_column(:namespaces, :require_two_factor_authentication) - remove_column(:namespaces, :two_factor_grace_period) - - remove_concurrent_index(:namespaces, :require_two_factor_authentication) if index_exists?(:namespaces, :require_two_factor_authentication) - end -end diff --git a/db/migrate/20170124193205_add_two_factor_columns_to_users.rb b/db/migrate/20170124193205_add_two_factor_columns_to_users.rb deleted file mode 100644 index 6c80dbfc965..00000000000 --- a/db/migrate/20170124193205_add_two_factor_columns_to_users.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class AddTwoFactorColumnsToUsers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:users, :require_two_factor_authentication_from_group, :boolean, default: false) - add_column_with_default(:users, :two_factor_grace_period, :integer, default: 48) - end - - def down - remove_column(:users, :require_two_factor_authentication_from_group) - remove_column(:users, :two_factor_grace_period) - end -end diff --git a/db/migrate/20170126174819_add_terminal_max_session_time_to_application_settings.rb b/db/migrate/20170126174819_add_terminal_max_session_time_to_application_settings.rb deleted file mode 100644 index 70f1669108a..00000000000 --- a/db/migrate/20170126174819_add_terminal_max_session_time_to_application_settings.rb +++ /dev/null @@ -1,33 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddTerminalMaxSessionTimeToApplicationSettings < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - disable_ddl_transaction! - - def up - add_column_with_default :application_settings, :terminal_max_session_time, :integer, default: 0, allow_null: false - end - - def down - remove_column :application_settings, :terminal_max_session_time - end -end diff --git a/db/migrate/20170127032550_remove_backlog_lists_from_boards.rb b/db/migrate/20170127032550_remove_backlog_lists_from_boards.rb deleted file mode 100644 index 2e2fecfa2a7..00000000000 --- a/db/migrate/20170127032550_remove_backlog_lists_from_boards.rb +++ /dev/null @@ -1,17 +0,0 @@ -class RemoveBacklogListsFromBoards < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - execute <<-SQL - DELETE FROM lists WHERE list_type = 0; - SQL - end - - def down - execute <<-SQL - INSERT INTO lists (board_id, list_type, created_at, updated_at) - SELECT boards.id, 0, NOW(), NOW() - FROM boards; - SQL - end -end diff --git a/db/migrate/20170130204620_add_index_to_project_authorizations.rb b/db/migrate/20170130204620_add_index_to_project_authorizations.rb deleted file mode 100644 index 28c4480e9c6..00000000000 --- a/db/migrate/20170130204620_add_index_to_project_authorizations.rb +++ /dev/null @@ -1,19 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexToProjectAuthorizations < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - unless index_exists?(:project_authorizations, :project_id) - add_concurrent_index(:project_authorizations, :project_id) - end - end - - def down - remove_index(:project_authorizations, :project_id) if - Gitlab::Database.postgresql? - end -end diff --git a/db/migrate/20170130221926_create_uploads.rb b/db/migrate/20170130221926_create_uploads.rb deleted file mode 100644 index 7bf15ca4978..00000000000 --- a/db/migrate/20170130221926_create_uploads.rb +++ /dev/null @@ -1,20 +0,0 @@ -class CreateUploads < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :uploads do |t| - t.integer :size, limit: 8, null: false - t.string :path, null: false - t.string :checksum, limit: 64 - t.references :model, polymorphic: true - t.string :uploader, null: false - t.datetime :created_at, null: false - end - - add_index :uploads, :path - add_index :uploads, :checksum - add_index :uploads, [:model_id, :model_type] - end -end diff --git a/db/migrate/20170131221752_add_relative_position_to_issues.rb b/db/migrate/20170131221752_add_relative_position_to_issues.rb deleted file mode 100644 index 126cb9e5415..00000000000 --- a/db/migrate/20170131221752_add_relative_position_to_issues.rb +++ /dev/null @@ -1,38 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddRelativePositionToIssues < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - disable_ddl_transaction! - - def up - add_column :issues, :relative_position, :integer - - add_concurrent_index :issues, :relative_position - end - - def down - remove_column :issues, :relative_position - - remove_index :issues, :relative_position if index_exists? :issues, :relative_position - end -end diff --git a/db/migrate/20170204172458_add_name_to_route.rb b/db/migrate/20170204172458_add_name_to_route.rb deleted file mode 100644 index e7c94aceb26..00000000000 --- a/db/migrate/20170204172458_add_name_to_route.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddNameToRoute < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :routes, :name, :string - end -end diff --git a/db/migrate/20170204181513_add_index_to_labels_for_type_and_project.rb b/db/migrate/20170204181513_add_index_to_labels_for_type_and_project.rb deleted file mode 100644 index 746322885b1..00000000000 --- a/db/migrate/20170204181513_add_index_to_labels_for_type_and_project.rb +++ /dev/null @@ -1,16 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexToLabelsForTypeAndProject < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :labels, [:type, :project_id] - end - - def down - remove_index :labels, [:type, :project_id] if index_exists? :labels, [:type, :project_id] - end -end diff --git a/db/migrate/20170206071414_add_recaptcha_verified_to_spam_logs.rb b/db/migrate/20170206071414_add_recaptcha_verified_to_spam_logs.rb deleted file mode 100644 index 06338ac943e..00000000000 --- a/db/migrate/20170206071414_add_recaptcha_verified_to_spam_logs.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddRecaptchaVerifiedToSpamLogs < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_column_with_default(:spam_logs, :recaptcha_verified, :boolean, default: false) - end - - def down - remove_column(:spam_logs, :recaptcha_verified) - end -end diff --git a/db/migrate/20170206115204_add_column_ghost_to_users.rb b/db/migrate/20170206115204_add_column_ghost_to_users.rb deleted file mode 100644 index 4b86814e05d..00000000000 --- a/db/migrate/20170206115204_add_column_ghost_to_users.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddColumnGhostToUsers < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - add_column :users, :ghost, :boolean - end - - def down - remove_column :users, :ghost - end -end diff --git a/db/migrate/20170210062829_add_index_to_labels_for_title_and_project.rb b/db/migrate/20170210062829_add_index_to_labels_for_title_and_project.rb deleted file mode 100644 index d0b440b8ccb..00000000000 --- a/db/migrate/20170210062829_add_index_to_labels_for_title_and_project.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexToLabelsForTitleAndProject < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :labels, :title - add_concurrent_index :labels, :project_id - end - - def down - remove_index :labels, :title if index_exists? :labels, :title - remove_index :labels, :project_id if index_exists? :labels, :project_id - end -end diff --git a/db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb b/db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb deleted file mode 100644 index 753d6c77e35..00000000000 --- a/db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb +++ /dev/null @@ -1,16 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexToCiTriggerRequestsForCommitId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_trigger_requests, :commit_id - end - - def down - remove_index :ci_trigger_requests, :commit_id if index_exists? :ci_trigger_requests, :commit_id - end -end diff --git a/db/migrate/20170210103609_add_index_to_user_agent_detail.rb b/db/migrate/20170210103609_add_index_to_user_agent_detail.rb deleted file mode 100644 index a2d6528ea82..00000000000 --- a/db/migrate/20170210103609_add_index_to_user_agent_detail.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddIndexToUserAgentDetail < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :user_agent_details, [:subject_id, :subject_type] - end - - def down - remove_index :user_agent_details, [:subject_id, :subject_type] if index_exists? :user_agent_details, [:subject_id, :subject_type] - end -end diff --git a/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb b/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb deleted file mode 100644 index c286354f476..00000000000 --- a/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddUniqueIpsLimitToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - disable_ddl_transaction! - - def up - add_column :application_settings, :unique_ips_limit_per_user, :integer - add_column :application_settings, :unique_ips_limit_time_window, :integer - add_column_with_default :application_settings, :unique_ips_limit_enabled, :boolean, default: false - end - - def down - remove_column :application_settings, :unique_ips_limit_per_user - remove_column :application_settings, :unique_ips_limit_time_window - remove_column :application_settings, :unique_ips_limit_enabled - end -end diff --git a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb deleted file mode 100644 index 84814c2f8f2..00000000000 --- a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddDefaultArtifactsExpirationToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, - :default_artifacts_expire_in, :string, - null: false, default: '0' - 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 deleted file mode 100644 index be393bd496d..00000000000 --- a/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb +++ /dev/null @@ -1,15 +0,0 @@ -# rubocop:disable RemoveIndex -class AddIndexForLatestSuccessfulPipeline < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index(:ci_commits, [:gl_project_id, :ref, :status]) - end - - def down - remove_index :ci_commits, [:gl_project_id, :ref, :status] if index_exists? :ci_commits, [:gl_project_id, :ref, :status] - end -end diff --git a/db/migrate/20170216141440_drop_index_for_builds_project_status.rb b/db/migrate/20170216141440_drop_index_for_builds_project_status.rb deleted file mode 100644 index 7edf7dd7e10..00000000000 --- a/db/migrate/20170216141440_drop_index_for_builds_project_status.rb +++ /dev/null @@ -1,9 +0,0 @@ -# rubocop:disable RemoveIndex -class DropIndexForBuildsProjectStatus < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - def change - remove_index(:ci_commits, column: [:gl_project_id, :status]) - end -end diff --git a/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb b/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb deleted file mode 100644 index ee8838eff56..00000000000 --- a/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameMergeWhenBuildSucceeds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - - # 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 = 'Renaming the column merge_when_build_succeeds' - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - rename_column :merge_requests, :merge_when_build_succeeds, :merge_when_pipeline_succeeds - end -end diff --git a/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb b/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb deleted file mode 100644 index 5d35216f3af..00000000000 --- a/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameOnlyAllowMergeIfBuildSucceeds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = true - - # 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 = 'Renaming the column only_allow_merge_if_build_succeeds' - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - rename_column :projects, :only_allow_merge_if_build_succeeds, :only_allow_merge_if_pipeline_succeeds - end -end diff --git a/db/migrate/20170217151948_add_owner_id_to_triggers.rb b/db/migrate/20170217151948_add_owner_id_to_triggers.rb deleted file mode 100644 index a28711ae59a..00000000000 --- a/db/migrate/20170217151948_add_owner_id_to_triggers.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddOwnerIdToTriggers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_triggers, :owner_id, :integer - end -end diff --git a/db/migrate/20170217151949_add_description_to_triggers.rb b/db/migrate/20170217151949_add_description_to_triggers.rb deleted file mode 100644 index 27cb4b3ab31..00000000000 --- a/db/migrate/20170217151949_add_description_to_triggers.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddDescriptionToTriggers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_triggers, :description, :string - end -end diff --git a/db/migrate/20170222111732_create_gpg_keys.rb b/db/migrate/20170222111732_create_gpg_keys.rb deleted file mode 100644 index 012e8ef5854..00000000000 --- a/db/migrate/20170222111732_create_gpg_keys.rb +++ /dev/null @@ -1,21 +0,0 @@ -class CreateGpgKeys < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :gpg_keys do |t| - t.timestamps_with_timezone null: false - - t.references :user, index: true, foreign_key: { on_delete: :cascade } - - t.binary :primary_keyid - t.binary :fingerprint - - t.text :key - - t.index :primary_keyid, unique: true, length: mysql_compatible_index_length - t.index :fingerprint, unique: true, length: mysql_compatible_index_length - end - end -end diff --git a/db/migrate/20170222143317_drop_ci_projects.rb b/db/migrate/20170222143317_drop_ci_projects.rb deleted file mode 100644 index 9f3aa2da382..00000000000 --- a/db/migrate/20170222143317_drop_ci_projects.rb +++ /dev/null @@ -1,34 +0,0 @@ -class DropCiProjects < ActiveRecord::Migration[4.2] - 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 deleted file mode 100644 index 356dee4a060..00000000000 --- a/db/migrate/20170222143500_remove_old_project_id_columns.rb +++ /dev/null @@ -1,30 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -# rubocop:disable RemoveIndex -class RemoveOldProjectIdColumns < ActiveRecord::Migration[4.2] - 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 deleted file mode 100644 index 390b2c33d91..00000000000 --- a/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb +++ /dev/null @@ -1,14 +0,0 @@ -class RenameGlProjectIdToProjectId < ActiveRecord::Migration[4.2] - 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/20170301101006_add_ci_runner_namespaces.rb b/db/migrate/20170301101006_add_ci_runner_namespaces.rb deleted file mode 100644 index aa2d8a14242..00000000000 --- a/db/migrate/20170301101006_add_ci_runner_namespaces.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddCiRunnerNamespaces < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :ci_runner_namespaces do |t| - t.integer :runner_id - t.integer :namespace_id - - t.index [:runner_id, :namespace_id], unique: true - t.index :namespace_id - t.foreign_key :ci_runners, column: :runner_id, on_delete: :cascade - t.foreign_key :namespaces, column: :namespace_id, on_delete: :cascade - end - 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 deleted file mode 100644 index a7efeb8ae6f..00000000000 --- a/db/migrate/20170301125302_add_printing_merge_request_link_enabled_to_project.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable Migration/UpdateLargeTable -class AddPrintingMergeRequestLinkEnabledToProject < ActiveRecord::Migration[4.2] - 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 deleted file mode 100644 index 791e9c845a6..00000000000 --- a/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb +++ /dev/null @@ -1,10 +0,0 @@ -class RenameCiCommitsToCiPipelines < ActiveRecord::Migration[4.2] - 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 deleted file mode 100644 index 08a11aee992..00000000000 --- a/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb +++ /dev/null @@ -1,84 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -class RemoveUnusedCiTablesAndColumns < ActiveRecord::Migration[4.2] - 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 if column_exists?(:ci_builds, :job_id) - 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/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb b/db/migrate/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb deleted file mode 100644 index 3e317bb5248..00000000000 --- a/db/migrate/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb +++ /dev/null @@ -1,16 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class AddAutoCancelPendingPipelinesToProject < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:projects, :auto_cancel_pending_pipelines, :integer, default: 0) - end - - def down - remove_column(:projects, :auto_cancel_pending_pipelines) - end -end diff --git a/db/migrate/20170305203726_add_owner_id_foreign_key.rb b/db/migrate/20170305203726_add_owner_id_foreign_key.rb deleted file mode 100644 index b3bd441ff9c..00000000000 --- a/db/migrate/20170305203726_add_owner_id_foreign_key.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddOwnerIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - 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/20170307125949_add_last_activity_on_to_users.rb b/db/migrate/20170307125949_add_last_activity_on_to_users.rb deleted file mode 100644 index 42331eab753..00000000000 --- a/db/migrate/20170307125949_add_last_activity_on_to_users.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddLastActivityOnToUsers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :users, :last_activity_on, :date - end -end diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb deleted file mode 100644 index f518b500bd4..00000000000 --- a/db/migrate/20170309173138_create_protected_tags.rb +++ /dev/null @@ -1,28 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateProtectedTags < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - GITLAB_ACCESS_MASTER = 40 - - def change - create_table :protected_tags do |t| - t.integer :project_id, null: false - t.string :name, null: false - t.timestamps null: false - end - - add_index :protected_tags, :project_id - - create_table :protected_tag_create_access_levels do |t| - t.references :protected_tag, index: { name: "index_protected_tag_create_access" }, foreign_key: true, null: false - t.integer :access_level, default: GITLAB_ACCESS_MASTER, null: true - t.references :user, foreign_key: true, index: true - t.integer :group_id - t.timestamps null: false - end - - add_foreign_key :protected_tag_create_access_levels, :namespaces, column: :group_id # rubocop: disable Migration/AddConcurrentForeignKey - end -end diff --git a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb deleted file mode 100644 index 26187a9e8b3..00000000000 --- a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddAutoCanceledByIdToPipeline < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_pipelines, :auto_canceled_by_id, :integer - end -end diff --git a/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb b/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb deleted file mode 100644 index a2b5c1c4533..00000000000 --- a/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb +++ /dev/null @@ -1,22 +0,0 @@ -class AddAutoCanceledByIdForeignKeyToPipeline < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - on_delete = - if Gitlab::Database.mysql? - :nullify - else - 'SET NULL' - end - - add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete - end - - def down - remove_foreign_key :ci_pipelines, column: :auto_canceled_by_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 deleted file mode 100644 index 66e57b444a0..00000000000 --- a/db/migrate/20170313213916_add_index_to_user_ghost.rb +++ /dev/null @@ -1,25 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# rubocop:disable RemoveIndex -class AddIndexToUserGhost < ActiveRecord::Migration[4.2] - 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/20170314082049_create_system_note_metadata.rb b/db/migrate/20170314082049_create_system_note_metadata.rb deleted file mode 100644 index d0cc6e3be36..00000000000 --- a/db/migrate/20170314082049_create_system_note_metadata.rb +++ /dev/null @@ -1,24 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateSystemNoteMetadata < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - create_table :system_note_metadata do |t| - t.references :note, null: false - t.integer :commit_count - t.string :action - - t.timestamps null: false - end - - add_concurrent_foreign_key :system_note_metadata, :notes, column: :note_id - end - - def down - drop_table :system_note_metadata - 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 deleted file mode 100644 index 8773c7ea657..00000000000 --- a/db/migrate/20170315174634_revert_add_notified_of_own_activity_to_users.rb +++ /dev/null @@ -1,26 +0,0 @@ -# rubocop:disable Migration/RemoveColumn -# rubocop:disable Migration/UpdateLargeTable -class RevertAddNotifiedOfOwnActivityToUsers < ActiveRecord::Migration[4.2] - 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 deleted file mode 100644 index 0b06ee6e74c..00000000000 --- a/db/migrate/20170315194013_add_closed_at_to_issues.rb +++ /dev/null @@ -1,8 +0,0 @@ -# rubocop:disable Migration/Datetime -class AddClosedAtToIssues < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column :issues, :closed_at, :datetime - end -end diff --git a/db/migrate/20170316061730_readd_notified_of_own_activity_to_users.rb b/db/migrate/20170316061730_readd_notified_of_own_activity_to_users.rb deleted file mode 100644 index 82029dfd3fc..00000000000 --- a/db/migrate/20170316061730_readd_notified_of_own_activity_to_users.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ReaddNotifiedOfOwnActivityToUsers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def change - add_column :users, :notified_of_own_activity, :boolean - end -end diff --git a/db/migrate/20170316163845_move_uploads_to_system_dir.rb b/db/migrate/20170316163845_move_uploads_to_system_dir.rb deleted file mode 100644 index d24527b55cd..00000000000 --- a/db/migrate/20170316163845_move_uploads_to_system_dir.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 MoveUploadsToSystemDir < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - DIRECTORIES_TO_MOVE = %w(user project note group appearance).freeze - - def up - return unless file_storage? - - FileUtils.mkdir_p(new_upload_dir) - - DIRECTORIES_TO_MOVE.each do |dir| - source = File.join(old_upload_dir, dir) - destination = File.join(new_upload_dir, dir) - next unless File.directory?(source) - next if File.directory?(destination) - - say "Moving #{source} -> #{destination}" - FileUtils.mv(source, destination) - FileUtils.ln_s(destination, source) - end - end - - def down - return unless file_storage? - return unless File.directory?(new_upload_dir) - - DIRECTORIES_TO_MOVE.each do |dir| - source = File.join(new_upload_dir, dir) - destination = File.join(old_upload_dir, dir) - next unless File.directory?(source) - next if File.directory?(destination) && !File.symlink?(destination) - - say "Moving #{source} -> #{destination}" - FileUtils.rm(destination) if File.symlink?(destination) - FileUtils.mv(source, destination) - end - end - - def file_storage? - CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File - end - - def base_directory - Rails.root - end - - def old_upload_dir - File.join(base_directory, "public", "uploads") - end - - def new_upload_dir - File.join(base_directory, "public", "uploads", "-", "system") - end -end diff --git a/db/migrate/20170317203554_index_routes_path_for_like.rb b/db/migrate/20170317203554_index_routes_path_for_like.rb deleted file mode 100644 index a1bee3c8783..00000000000 --- a/db/migrate/20170317203554_index_routes_path_for_like.rb +++ /dev/null @@ -1,28 +0,0 @@ -# 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[4.2] - 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, :path, name: INDEX_NAME) - execute("CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON routes (path varchar_pattern_ops);") - end - end - - def down - return unless Gitlab::Database.postgresql? - return unless index_exists?(:routes, :path, name: INDEX_NAME) - - remove_concurrent_index_by_name(:routes, INDEX_NAME) - end -end diff --git a/db/migrate/20170320173259_migrate_assignees.rb b/db/migrate/20170320173259_migrate_assignees.rb deleted file mode 100644 index 43a90758bd9..00000000000 --- a/db/migrate/20170320173259_migrate_assignees.rb +++ /dev/null @@ -1,43 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -# rubocop:disable Migration/UpdateColumnInBatches -class MigrateAssignees < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - disable_ddl_transaction! - - def up - # Optimisation: this accounts for most of the invalid assignee IDs on GitLab.com - update_column_in_batches(:issues, :assignee_id, nil) do |table, query| - query.where(table[:assignee_id].eq(0)) - end - - users = Arel::Table.new(:users) - - update_column_in_batches(:issues, :assignee_id, nil) do |table, query| - query.where(table[:assignee_id].not_eq(nil)\ - .and( - users.project("true").where(users[:id].eq(table[:assignee_id])).exists.not - )) - end - end - - def down - end -end diff --git a/db/migrate/20170322013926_create_container_repository.rb b/db/migrate/20170322013926_create_container_repository.rb deleted file mode 100644 index b1e778671b2..00000000000 --- a/db/migrate/20170322013926_create_container_repository.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateContainerRepository < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :container_repositories do |t| - t.references :project, foreign_key: true, index: true, null: false - t.string :name, null: false - - t.timestamps null: false - end - - add_index :container_repositories, [:project_id, :name], unique: true - end -end diff --git a/db/migrate/20170327091750_add_created_at_index_to_deployments.rb b/db/migrate/20170327091750_add_created_at_index_to_deployments.rb deleted file mode 100644 index f29fff7d5b9..00000000000 --- a/db/migrate/20170327091750_add_created_at_index_to_deployments.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddCreatedAtIndexToDeployments < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :deployments, :created_at - end - - def down - remove_concurrent_index :deployments, :created_at - end -end diff --git a/db/migrate/20170328010804_add_uuid_to_application_settings.rb b/db/migrate/20170328010804_add_uuid_to_application_settings.rb deleted file mode 100644 index 95a01c2dc8f..00000000000 --- a/db/migrate/20170328010804_add_uuid_to_application_settings.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddUuidToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column :application_settings, :uuid, :string - execute("UPDATE application_settings SET uuid = #{quote(SecureRandom.uuid)}") - end - - def down - remove_column :application_settings, :uuid - end -end diff --git a/db/migrate/20170329095325_add_ref_to_triggers.rb b/db/migrate/20170329095325_add_ref_to_triggers.rb deleted file mode 100644 index db09b36db17..00000000000 --- a/db/migrate/20170329095325_add_ref_to_triggers.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddRefToTriggers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_triggers, :ref, :string - end -end diff --git a/db/migrate/20170329095907_create_ci_trigger_schedules.rb b/db/migrate/20170329095907_create_ci_trigger_schedules.rb deleted file mode 100644 index 7f759f908cd..00000000000 --- a/db/migrate/20170329095907_create_ci_trigger_schedules.rb +++ /dev/null @@ -1,21 +0,0 @@ -class CreateCiTriggerSchedules < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :ci_trigger_schedules do |t| - t.integer "project_id" - t.integer "trigger_id", null: false - t.datetime "deleted_at" - t.datetime "created_at" - t.datetime "updated_at" - t.string "cron" - t.string "cron_timezone" - t.datetime "next_run_at" - end - - add_index :ci_trigger_schedules, :next_run_at - add_index :ci_trigger_schedules, :project_id - end -end diff --git a/db/migrate/20170329124448_add_polling_interval_multiplier_to_application_settings.rb b/db/migrate/20170329124448_add_polling_interval_multiplier_to_application_settings.rb deleted file mode 100644 index 17307879a2a..00000000000 --- a/db/migrate/20170329124448_add_polling_interval_multiplier_to_application_settings.rb +++ /dev/null @@ -1,33 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddPollingIntervalMultiplierToApplicationSettings < ActiveRecord::Migration[4.2] - 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" 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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - disable_ddl_transaction! - - def up - add_column_with_default :application_settings, :polling_interval_multiplier, :decimal, default: 1, allow_null: false - end - - def down - remove_column :application_settings, :polling_interval_multiplier - end -end diff --git a/db/migrate/20170330141723_disable_invalid_service_templates2.rb b/db/migrate/20170330141723_disable_invalid_service_templates2.rb deleted file mode 100644 index f09f3b3e355..00000000000 --- a/db/migrate/20170330141723_disable_invalid_service_templates2.rb +++ /dev/null @@ -1,18 +0,0 @@ -# This is the same as DisableInvalidServiceTemplates. Later migrations may have -# inadvertently enabled some invalid templates again. -# -class DisableInvalidServiceTemplates2 < ActiveRecord::Migration[4.2] - DOWNTIME = false - - unless defined?(Service) - class Service < ActiveRecord::Base - self.inheritance_column = nil - end - end - - def up - Service.where(template: true, active: true).each do |template| - template.update(active: false) unless template.valid? - end - end -end 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 deleted file mode 100644 index 4c417ce2f71..00000000000 --- a/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb +++ /dev/null @@ -1,18 +0,0 @@ -# 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[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - remove_concurrent_index :users, :current_sign_in_at - end - - def down - add_concurrent_index :users, :current_sign_in_at - end -end diff --git a/db/migrate/20170404163427_add_trigger_id_foreign_key.rb b/db/migrate/20170404163427_add_trigger_id_foreign_key.rb deleted file mode 100644 index f35730c8e45..00000000000 --- a/db/migrate/20170404163427_add_trigger_id_foreign_key.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddTriggerIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :ci_trigger_schedules, :ci_triggers, column: :trigger_id, on_delete: :cascade - end - - def down - remove_foreign_key :ci_trigger_schedules, column: :trigger_id - end -end diff --git a/db/migrate/20170405080720_add_import_jid_to_projects.rb b/db/migrate/20170405080720_add_import_jid_to_projects.rb deleted file mode 100644 index ddbea9d7ab6..00000000000 --- a/db/migrate/20170405080720_add_import_jid_to_projects.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddImportJidToProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :projects, :import_jid, :string - end -end diff --git a/db/migrate/20170406114958_add_auto_canceled_by_id_to_ci_builds.rb b/db/migrate/20170406114958_add_auto_canceled_by_id_to_ci_builds.rb deleted file mode 100644 index ba43a070587..00000000000 --- a/db/migrate/20170406114958_add_auto_canceled_by_id_to_ci_builds.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddAutoCanceledByIdToCiBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_builds, :auto_canceled_by_id, :integer - end -end diff --git a/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb b/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb deleted file mode 100644 index 2ec281e20c1..00000000000 --- a/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb +++ /dev/null @@ -1,22 +0,0 @@ -class AddAutoCanceledByIdForeignKeyToCiBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - on_delete = - if Gitlab::Database.mysql? - :nullify - else - 'SET NULL' - end - - add_concurrent_foreign_key :ci_builds, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete - end - - def down - remove_foreign_key :ci_builds, column: :auto_canceled_by_id - end -end diff --git a/db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.rb b/db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.rb deleted file mode 100644 index 5d156b7ef2e..00000000000 --- a/db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddRefToCiTriggerSchedule < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_trigger_schedules, :ref, :string - end -end diff --git a/db/migrate/20170407122426_add_active_to_ci_trigger_schedule.rb b/db/migrate/20170407122426_add_active_to_ci_trigger_schedule.rb deleted file mode 100644 index 33295bd3f2e..00000000000 --- a/db/migrate/20170407122426_add_active_to_ci_trigger_schedule.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddActiveToCiTriggerSchedule < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_trigger_schedules, :active, :boolean - end -end diff --git a/db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb b/db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb deleted file mode 100644 index 9aaa4d0eddf..00000000000 --- a/db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddForeighKeyTriggerRequestsTrigger < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key(:ci_trigger_requests, :ci_triggers, column: :trigger_id) - end - - def down - remove_foreign_key(:ci_trigger_requests, column: :trigger_id) - end -end diff --git a/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb b/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb deleted file mode 100644 index 0bde4f69b3b..00000000000 --- a/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddIndexToNextRunAtAndActive < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_trigger_schedules, [:active, :next_run_at] - end - - def down - remove_concurrent_index :ci_trigger_schedules, [:active, :next_run_at] - end -end diff --git a/db/migrate/20170410133135_add_version_field_to_markdown_cache.rb b/db/migrate/20170410133135_add_version_field_to_markdown_cache.rb deleted file mode 100644 index c019e0627d3..00000000000 --- a/db/migrate/20170410133135_add_version_field_to_markdown_cache.rb +++ /dev/null @@ -1,25 +0,0 @@ -class AddVersionFieldToMarkdownCache < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - %i[ - abuse_reports - appearances - application_settings - broadcast_messages - issues - labels - merge_requests - milestones - namespaces - notes - projects - releases - snippets - ].each do |table| - add_column table, :cached_markdown_version, :integer, limit: 4 - end - end -end diff --git a/db/migrate/20170413035209_add_preferred_language_to_users.rb b/db/migrate/20170413035209_add_preferred_language_to_users.rb deleted file mode 100644 index 5b5f00ea60f..00000000000 --- a/db/migrate/20170413035209_add_preferred_language_to_users.rb +++ /dev/null @@ -1,16 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddPreferredLanguageToUsers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - add_column :users, :preferred_language, :string - end - - def down - remove_column :users, :preferred_language - end -end diff --git a/db/migrate/20170418103908_delete_orphan_notification_settings.rb b/db/migrate/20170418103908_delete_orphan_notification_settings.rb deleted file mode 100644 index c99729b9127..00000000000 --- a/db/migrate/20170418103908_delete_orphan_notification_settings.rb +++ /dev/null @@ -1,24 +0,0 @@ -class DeleteOrphanNotificationSettings < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - execute("DELETE FROM notification_settings WHERE EXISTS (SELECT true FROM (#{orphan_notification_settings}) AS ns WHERE ns.id = notification_settings.id)") - end - - def down - # This is a no-op method to make the migration reversible. - # If someone is trying to rollback for other reasons, we should not throw an Exception. - # raise ActiveRecord::IrreversibleMigration - end - - def orphan_notification_settings - <<-SQL - SELECT notification_settings.id - FROM notification_settings - LEFT OUTER JOIN namespaces - ON namespaces.id = notification_settings.source_id - WHERE notification_settings.source_type = 'Namespace' - AND namespaces.id IS NULL - SQL - end -end diff --git a/db/migrate/20170419001229_add_index_to_system_note_metadata.rb b/db/migrate/20170419001229_add_index_to_system_note_metadata.rb deleted file mode 100644 index 59cd55395fc..00000000000 --- a/db/migrate/20170419001229_add_index_to_system_note_metadata.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddIndexToSystemNoteMetadata < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - # MySQL automatically creates an index on a foreign-key constraint; PostgreSQL does not - add_concurrent_index :system_note_metadata, :note_id, unique: true if Gitlab::Database.postgresql? - end - - def down - remove_concurrent_index :system_note_metadata, :note_id, unique: true if Gitlab::Database.postgresql? - end -end diff --git a/db/migrate/20170421102337_remove_nil_type_services.rb b/db/migrate/20170421102337_remove_nil_type_services.rb deleted file mode 100644 index 561eddf69e0..00000000000 --- a/db/migrate/20170421102337_remove_nil_type_services.rb +++ /dev/null @@ -1,12 +0,0 @@ -class RemoveNilTypeServices < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - execute <<-SQL - DELETE FROM services WHERE type IS NULL OR type = ''; - SQL - end - - def down - end -end diff --git a/db/migrate/20170423064036_add_index_on_ci_builds_updated_at.rb b/db/migrate/20170423064036_add_index_on_ci_builds_updated_at.rb deleted file mode 100644 index 76252378c2e..00000000000 --- a/db/migrate/20170423064036_add_index_on_ci_builds_updated_at.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddIndexOnCiBuildsUpdatedAt < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_builds, :updated_at - end - - def down - remove_concurrent_index :ci_builds, :updated_at if index_exists?(:ci_builds, :updated_at) - end -end diff --git a/db/migrate/20170424095707_add_index_on_ci_builds_user_id.rb b/db/migrate/20170424095707_add_index_on_ci_builds_user_id.rb deleted file mode 100644 index ab2501da941..00000000000 --- a/db/migrate/20170424095707_add_index_on_ci_builds_user_id.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddIndexOnCiBuildsUserId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_builds, :user_id - end - - def down - remove_concurrent_index :ci_builds, :user_id if index_exists?(:ci_builds, :user_id) - end -end diff --git a/db/migrate/20170424142900_add_index_to_web_hooks_type.rb b/db/migrate/20170424142900_add_index_to_web_hooks_type.rb deleted file mode 100644 index 1c56c1ed65a..00000000000 --- a/db/migrate/20170424142900_add_index_to_web_hooks_type.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddIndexToWebHooksType < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :web_hooks, :type - end - - def down - remove_concurrent_index :web_hooks, :type - end -end diff --git a/db/migrate/20170425112128_create_pipeline_schedules_table.rb b/db/migrate/20170425112128_create_pipeline_schedules_table.rb deleted file mode 100644 index e66e81b34be..00000000000 --- a/db/migrate/20170425112128_create_pipeline_schedules_table.rb +++ /dev/null @@ -1,29 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreatePipelineSchedulesTable < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - create_table :ci_pipeline_schedules do |t| - t.string :description - t.string :ref - t.string :cron - t.string :cron_timezone - t.datetime :next_run_at - t.integer :project_id - t.integer :owner_id - t.boolean :active, default: true - t.datetime :deleted_at - - t.timestamps null: true - end - - add_index(:ci_pipeline_schedules, :project_id) - add_index(:ci_pipeline_schedules, [:next_run_at, :active]) - end - - def down - drop_table :ci_pipeline_schedules - end -end diff --git a/db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb b/db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb deleted file mode 100644 index d89c4c61cbe..00000000000 --- a/db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb +++ /dev/null @@ -1,23 +0,0 @@ -class RemoveForeighKeyCiTriggerSchedules < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - if fk_on_trigger_schedules? - remove_foreign_key :ci_trigger_schedules, column: :trigger_id - end - end - - def down - # no op, the foreign key should not have been here - end - - private - - # Not made more generic and lifted to the helpers as Rails 5 will provide - # such an API - def fk_on_trigger_schedules? - connection.foreign_keys(:ci_trigger_schedules).include?("ci_triggers") - end -end diff --git a/db/migrate/20170425114731_add_pipeline_schedule_id_to_pipelines.rb b/db/migrate/20170425114731_add_pipeline_schedule_id_to_pipelines.rb deleted file mode 100644 index da16d89febc..00000000000 --- a/db/migrate/20170425114731_add_pipeline_schedule_id_to_pipelines.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddPipelineScheduleIdToPipelines < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_pipelines, :pipeline_schedule_id, :integer - end -end diff --git a/db/migrate/20170426175636_fill_missing_uuid_on_application_settings.rb b/db/migrate/20170426175636_fill_missing_uuid_on_application_settings.rb deleted file mode 100644 index eeeb216f32c..00000000000 --- a/db/migrate/20170426175636_fill_missing_uuid_on_application_settings.rb +++ /dev/null @@ -1,10 +0,0 @@ -class FillMissingUuidOnApplicationSettings < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - execute("UPDATE application_settings SET uuid = #{quote(SecureRandom.uuid)} WHERE uuid is NULL") - end - - def down - end -end diff --git a/db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb b/db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb deleted file mode 100644 index e14b2eb4c8a..00000000000 --- a/db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddIndexOnCiRunnersContactedAt < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_runners, :contacted_at - end - - def down - remove_concurrent_index :ci_runners, :contacted_at if index_exists?(:ci_runners, :contacted_at) - end -end diff --git a/db/migrate/20170427103502_create_web_hook_logs.rb b/db/migrate/20170427103502_create_web_hook_logs.rb deleted file mode 100644 index a7a061e7bae..00000000000 --- a/db/migrate/20170427103502_create_web_hook_logs.rb +++ /dev/null @@ -1,22 +0,0 @@ -# rubocop:disable all -class CreateWebHookLogs < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :web_hook_logs do |t| - t.references :web_hook, null: false, index: true, foreign_key: { on_delete: :cascade } - - t.string :trigger - t.string :url - t.text :request_headers - t.text :request_data - t.text :response_headers - t.text :response_body - t.string :response_status - t.float :execution_duration - t.string :internal_error_message - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20170427215854_create_redirect_routes.rb b/db/migrate/20170427215854_create_redirect_routes.rb deleted file mode 100644 index 069c9b39d37..00000000000 --- a/db/migrate/20170427215854_create_redirect_routes.rb +++ /dev/null @@ -1,15 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateRedirectRoutes < ActiveRecord::Migration[4.2] - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - create_table :redirect_routes do |t| - t.integer :source_id, null: false - t.string :source_type, null: false - t.string :path, null: false - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20170428064307_add_column_delete_error_to_projects.rb b/db/migrate/20170428064307_add_column_delete_error_to_projects.rb deleted file mode 100644 index bef0373309c..00000000000 --- a/db/migrate/20170428064307_add_column_delete_error_to_projects.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddColumnDeleteErrorToProjects < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column :projects, :delete_error, :text - end -end diff --git a/db/migrate/20170502065653_make_auto_cancel_pending_pipelines_on_by_default.rb b/db/migrate/20170502065653_make_auto_cancel_pending_pipelines_on_by_default.rb deleted file mode 100644 index e51a790de4d..00000000000 --- a/db/migrate/20170502065653_make_auto_cancel_pending_pipelines_on_by_default.rb +++ /dev/null @@ -1,13 +0,0 @@ -class MakeAutoCancelPendingPipelinesOnByDefault < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - change_column_default(:projects, :auto_cancel_pending_pipelines, 1) - end - - def down - change_column_default(:projects, :auto_cancel_pending_pipelines, 0) - end -end diff --git a/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb b/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb deleted file mode 100644 index 1c5d4997d40..00000000000 --- a/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb +++ /dev/null @@ -1 +0,0 @@ -require_relative 'markdown_cache_limits_to_mysql' diff --git a/db/migrate/20170502135553_create_index_ci_pipelines_auto_canceled_by_id.rb b/db/migrate/20170502135553_create_index_ci_pipelines_auto_canceled_by_id.rb deleted file mode 100644 index 7acae645c7b..00000000000 --- a/db/migrate/20170502135553_create_index_ci_pipelines_auto_canceled_by_id.rb +++ /dev/null @@ -1,21 +0,0 @@ -class CreateIndexCiPipelinesAutoCanceledById < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - # MySQL would already have the index - unless index_exists?(:ci_pipelines, :auto_canceled_by_id) - add_concurrent_index(:ci_pipelines, :auto_canceled_by_id) - end - end - - def down - # We cannot remove index for MySQL because it's needed for foreign key - if Gitlab::Database.postgresql? - remove_concurrent_index(:ci_pipelines, :auto_canceled_by_id) - end - end -end diff --git a/db/migrate/20170502140503_create_index_ci_builds_auto_canceled_by_id.rb b/db/migrate/20170502140503_create_index_ci_builds_auto_canceled_by_id.rb deleted file mode 100644 index f5148f6fdb8..00000000000 --- a/db/migrate/20170502140503_create_index_ci_builds_auto_canceled_by_id.rb +++ /dev/null @@ -1,21 +0,0 @@ -class CreateIndexCiBuildsAutoCanceledById < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - # MySQL would already have the index - unless index_exists?(:ci_builds, :auto_canceled_by_id) - add_concurrent_index(:ci_builds, :auto_canceled_by_id) - end - end - - def down - # We cannot remove index for MySQL because it's needed for foreign key - if Gitlab::Database.postgresql? - remove_concurrent_index(:ci_builds, :auto_canceled_by_id) - end - end -end diff --git a/db/migrate/20170503004125_add_last_repository_updated_at_to_projects.rb b/db/migrate/20170503004125_add_last_repository_updated_at_to_projects.rb deleted file mode 100644 index 303250ff3b0..00000000000 --- a/db/migrate/20170503004125_add_last_repository_updated_at_to_projects.rb +++ /dev/null @@ -1,8 +0,0 @@ -# rubocop:disable Migration/Datetime -class AddLastRepositoryUpdatedAtToProjects < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column :projects, :last_repository_updated_at, :datetime - end -end diff --git a/db/migrate/20170503004425_add_index_to_last_repository_updated_at_on_projects.rb b/db/migrate/20170503004425_add_index_to_last_repository_updated_at_on_projects.rb deleted file mode 100644 index ae54cfb39f5..00000000000 --- a/db/migrate/20170503004425_add_index_to_last_repository_updated_at_on_projects.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddIndexToLastRepositoryUpdatedAtOnProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index(:projects, :last_repository_updated_at) - end - - def down - remove_concurrent_index(:projects, :last_repository_updated_at) if index_exists?(:projects, :last_repository_updated_at) - end -end diff --git a/db/migrate/20170503004426_add_retried_to_ci_build.rb b/db/migrate/20170503004426_add_retried_to_ci_build.rb deleted file mode 100644 index ff2e0ba64c5..00000000000 --- a/db/migrate/20170503004426_add_retried_to_ci_build.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddRetriedToCiBuild < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column(:ci_builds, :retried, :boolean) - end -end diff --git a/db/migrate/20170503021915_add_last_edited_at_and_last_edited_by_id_to_issues.rb b/db/migrate/20170503021915_add_last_edited_at_and_last_edited_by_id_to_issues.rb deleted file mode 100644 index ef527bb8007..00000000000 --- a/db/migrate/20170503021915_add_last_edited_at_and_last_edited_by_id_to_issues.rb +++ /dev/null @@ -1,15 +0,0 @@ -# rubocop:disable Migration/Datetime -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddLastEditedAtAndLastEditedByIdToIssues < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - add_column :issues, :last_edited_at, :timestamp - add_column :issues, :last_edited_by_id, :integer - end -end diff --git a/db/migrate/20170503022548_add_last_edited_at_and_last_edited_by_id_to_merge_requests.rb b/db/migrate/20170503022548_add_last_edited_at_and_last_edited_by_id_to_merge_requests.rb deleted file mode 100644 index 19b8a9d66e7..00000000000 --- a/db/migrate/20170503022548_add_last_edited_at_and_last_edited_by_id_to_merge_requests.rb +++ /dev/null @@ -1,15 +0,0 @@ -# rubocop:disable Migration/Datetime -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddLastEditedAtAndLastEditedByIdToMergeRequests < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - add_column :merge_requests, :last_edited_at, :timestamp - add_column :merge_requests, :last_edited_by_id, :integer - end -end diff --git a/db/migrate/20170503023315_add_repository_update_events_to_web_hooks.rb b/db/migrate/20170503023315_add_repository_update_events_to_web_hooks.rb deleted file mode 100644 index 4824c404ec7..00000000000 --- a/db/migrate/20170503023315_add_repository_update_events_to_web_hooks.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddRepositoryUpdateEventsToWebHooks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :web_hooks, :repository_update_events, :boolean, default: false, allow_null: false - end - - def down - remove_column :web_hooks, :repository_update_events - end -end diff --git a/db/migrate/20170503114228_add_description_to_snippets.rb b/db/migrate/20170503114228_add_description_to_snippets.rb deleted file mode 100644 index 78151ed9ff6..00000000000 --- a/db/migrate/20170503114228_add_description_to_snippets.rb +++ /dev/null @@ -1,12 +0,0 @@ -class AddDescriptionToSnippets < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def change - add_column :snippets, :description, :text - add_column :snippets, :description_html, :text - end -end diff --git a/db/migrate/20170503140201_reschedule_project_authorizations.rb b/db/migrate/20170503140201_reschedule_project_authorizations.rb deleted file mode 100644 index aa940bed2d3..00000000000 --- a/db/migrate/20170503140201_reschedule_project_authorizations.rb +++ /dev/null @@ -1,44 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RescheduleProjectAuthorizations < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class User < ActiveRecord::Base - self.table_name = 'users' - end - - def up - offset = 0 - batch = 5000 - start = Time.now - - loop do - relation = User.where('id > ?', offset) - user_ids = relation.limit(batch).reorder(id: :asc).pluck(:id) - - break if user_ids.empty? - - offset = user_ids.last - - # This will schedule each batch 5 minutes after the previous batch was - # scheduled. This smears out the load over time, instead of immediately - # scheduling a million jobs. - Sidekiq::Client.push_bulk( - 'queue' => 'authorized_projects', - 'args' => user_ids.zip, - 'class' => 'AuthorizedProjectsWorker', - 'at' => start.to_i - ) - - start += 5.minutes - end - end - - def down - end -end diff --git a/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb b/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb deleted file mode 100644 index 65b2c6a57be..00000000000 --- a/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb +++ /dev/null @@ -1,116 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# This migration depends on code external to it. For example, it relies on -# updating a namespace to also rename directories (uploads, GitLab pages, etc). -# The alternative is to copy hundreds of lines of code into this migration, -# adjust them where needed, etc; something which doesn't work well at all. -class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def run_migration? - Gitlab::Database.mysql? - end - - def up - return unless run_migration? - - # For all sub-groups we need to give the right people access. We do this as - # follows: - # - # 1. Get all the ancestors for the current namespace - # 2. Get all the members of these namespaces, along with their higher access - # level - # 3. Give these members access to the current namespace - Namespace.unscoped.where('parent_id IS NOT NULL').find_each do |namespace| - rows = [] - existing = namespace.members.pluck(:user_id) - - all_members_for(namespace).each do |member| - next if existing.include?(member[:user_id]) - - rows << { - access_level: member[:access_level], - source_id: namespace.id, - source_type: 'Namespace', - user_id: member[:user_id], - notification_level: 3, # global - type: 'GroupMember', - created_at: Time.current, - updated_at: Time.current - } - end - - bulk_insert_members(rows) - - namespace.update!(parent_id: nil, path: new_path_for(namespace)) - end - end - - def down - # There is no way to go back from regular groups to nested groups. - end - - # Generates a new (unique) path for a namespace. - def new_path_for(namespace) - counter = 1 - base = namespace.full_path.tr('/', '-') - new_path = base - - while Namespace.unscoped.where(path: new_path).exists? - new_path = base + "-#{counter}" - counter += 1 - end - - new_path - end - - # Returns an Array containing all the ancestors of the current namespace. - # - # This method is not particularly efficient, but it's probably still faster - # than using the "routes" table. Most importantly of all, it _only_ depends - # on the namespaces table and the "parent_id" column. - def ancestors_for(namespace) - ancestors = [] - current = namespace - - while current&.parent_id - # We're using find_by(id: ...) here to deal with cases where the - # parent_id may point to a missing row. - current = Namespace.unscoped.select([:id, :parent_id]) - .find_by(id: current.parent_id) - - ancestors << current.id if current - end - - ancestors - end - - # Returns a relation containing all the members that have access to any of - # the current namespace's parent namespaces. - def all_members_for(namespace) - Member - .unscoped - .select(['user_id', 'MAX(access_level) AS access_level']) - .where(source_type: 'Namespace', source_id: ancestors_for(namespace)) - .group(:user_id) - end - - def bulk_insert_members(rows) - return if rows.empty? - - keys = rows.first.keys - - tuples = rows.map do |row| - row.map { |(_, value)| connection.quote(value) } - end - - execute <<-EOF.strip_heredoc - INSERT INTO members (#{keys.join(', ')}) - VALUES #{tuples.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')} - EOF - end -end diff --git a/db/migrate/20170503184421_add_index_to_redirect_routes.rb b/db/migrate/20170503184421_add_index_to_redirect_routes.rb deleted file mode 100644 index 6320d4bbc99..00000000000 --- a/db/migrate/20170503184421_add_index_to_redirect_routes.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddIndexToRedirectRoutes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index(:redirect_routes, :path, unique: true) - add_concurrent_index(:redirect_routes, [:source_type, :source_id]) - end - - def down - remove_concurrent_index(:redirect_routes, :path) if index_exists?(:redirect_routes, :path) - remove_concurrent_index(:redirect_routes, [:source_type, :source_id]) if index_exists?(:redirect_routes, [:source_type, :source_id]) - end -end diff --git a/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb b/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb deleted file mode 100644 index 5d06fd0511c..00000000000 --- a/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb +++ /dev/null @@ -1,28 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class IndexRedirectRoutesPathForLike < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - INDEX_NAME = 'index_redirect_routes_on_path_text_pattern_ops' - - disable_ddl_transaction! - - def up - return unless Gitlab::Database.postgresql? - - unless index_exists?(:redirect_routes, :path, name: INDEX_NAME) - execute("CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON redirect_routes (path varchar_pattern_ops);") - end - end - - def down - return unless Gitlab::Database.postgresql? - return unless index_exists?(:redirect_routes, :path, name: INDEX_NAME) - - remove_concurrent_index_by_name(:redirect_routes, INDEX_NAME) - end -end diff --git a/db/migrate/20170504102911_add_clientside_sentry_to_application_settings.rb b/db/migrate/20170504102911_add_clientside_sentry_to_application_settings.rb deleted file mode 100644 index 4659f694020..00000000000 --- a/db/migrate/20170504102911_add_clientside_sentry_to_application_settings.rb +++ /dev/null @@ -1,33 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddClientsideSentryToApplicationSettings < ActiveRecord::Migration[4.2] - 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 "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 up - add_column_with_default :application_settings, :clientside_sentry_enabled, :boolean, default: false - add_column :application_settings, :clientside_sentry_dsn, :string - end - - def down - remove_columns :application_settings, :clientside_sentry_enabled, :clientside_sentry_dsn - end -end diff --git a/db/migrate/20170504182103_add_index_project_group_links_group_id.rb b/db/migrate/20170504182103_add_index_project_group_links_group_id.rb deleted file mode 100644 index 5b1c14e66dd..00000000000 --- a/db/migrate/20170504182103_add_index_project_group_links_group_id.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddIndexProjectGroupLinksGroupId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :project_group_links, :group_id - end - - def down - remove_concurrent_index :project_group_links, :group_id - end -end diff --git a/db/migrate/20170506085040_add_index_to_pipeline_pipeline_schedule_id.rb b/db/migrate/20170506085040_add_index_to_pipeline_pipeline_schedule_id.rb deleted file mode 100644 index 9d8cc8a83a2..00000000000 --- a/db/migrate/20170506085040_add_index_to_pipeline_pipeline_schedule_id.rb +++ /dev/null @@ -1,19 +0,0 @@ -class AddIndexToPipelinePipelineScheduleId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - unless index_exists?(:ci_pipelines, :pipeline_schedule_id) - add_concurrent_index(:ci_pipelines, :pipeline_schedule_id) - end - end - - def down - if index_exists?(:ci_pipelines, :pipeline_schedule_id) - remove_concurrent_index(:ci_pipelines, :pipeline_schedule_id) - end - end -end diff --git a/db/migrate/20170506091344_add_foreign_key_to_pipeline_schedules.rb b/db/migrate/20170506091344_add_foreign_key_to_pipeline_schedules.rb deleted file mode 100644 index 244e41e2f07..00000000000 --- a/db/migrate/20170506091344_add_foreign_key_to_pipeline_schedules.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddForeignKeyToPipelineSchedules < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :ci_pipeline_schedules, :projects, column: :project_id - end - - def down - remove_foreign_key :ci_pipeline_schedules, :projects - end -end diff --git a/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb deleted file mode 100644 index 50364cac259..00000000000 --- a/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb +++ /dev/null @@ -1,23 +0,0 @@ -class AddForeignKeyPipelineSchedulesAndPipelines < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - on_delete = - if Gitlab::Database.mysql? - :nullify - else - 'SET NULL' - end - - add_concurrent_foreign_key :ci_pipelines, :ci_pipeline_schedules, - column: :pipeline_schedule_id, on_delete: on_delete - end - - def down - remove_foreign_key :ci_pipelines, column: :pipeline_schedule_id - end -end diff --git a/db/migrate/20170507205316_add_head_pipeline_id_to_merge_requests.rb b/db/migrate/20170507205316_add_head_pipeline_id_to_merge_requests.rb deleted file mode 100644 index adfe6559084..00000000000 --- a/db/migrate/20170507205316_add_head_pipeline_id_to_merge_requests.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddHeadPipelineIdToMergeRequests < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column :merge_requests, :head_pipeline_id, :integer - end -end diff --git a/db/migrate/20170508153950_add_not_null_contraints_to_ci_variables.rb b/db/migrate/20170508153950_add_not_null_contraints_to_ci_variables.rb deleted file mode 100644 index 2a0c7132bfd..00000000000 --- a/db/migrate/20170508153950_add_not_null_contraints_to_ci_variables.rb +++ /dev/null @@ -1,12 +0,0 @@ -class AddNotNullContraintsToCiVariables < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - change_column(:ci_variables, :key, :string, null: false) - change_column(:ci_variables, :project_id, :integer, null: false) - end - - def down - # no op - end -end diff --git a/db/migrate/20170508190732_add_foreign_key_to_ci_variables.rb b/db/migrate/20170508190732_add_foreign_key_to_ci_variables.rb deleted file mode 100644 index 305366b2171..00000000000 --- a/db/migrate/20170508190732_add_foreign_key_to_ci_variables.rb +++ /dev/null @@ -1,24 +0,0 @@ -class AddForeignKeyToCiVariables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - execute <<~SQL - DELETE FROM ci_variables - WHERE NOT EXISTS ( - SELECT true - FROM projects - WHERE projects.id = ci_variables.project_id - ) - SQL - - add_concurrent_foreign_key(:ci_variables, :projects, column: :project_id) - end - - def down - remove_foreign_key(:ci_variables, column: :project_id) - end -end diff --git a/db/migrate/20170511082759_rename_web_hooks_build_events_to_job_events.rb b/db/migrate/20170511082759_rename_web_hooks_build_events_to_job_events.rb deleted file mode 100644 index 3a44057d948..00000000000 --- a/db/migrate/20170511082759_rename_web_hooks_build_events_to_job_events.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameWebHooksBuildEventsToJobEvents < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - rename_column_concurrently :web_hooks, :build_events, :job_events - end - - def down - cleanup_concurrent_column_rename :web_hooks, :job_events, :build_events - end -end diff --git a/db/migrate/20170511083824_rename_services_build_events_to_job_events.rb b/db/migrate/20170511083824_rename_services_build_events_to_job_events.rb deleted file mode 100644 index 713adde76ef..00000000000 --- a/db/migrate/20170511083824_rename_services_build_events_to_job_events.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameServicesBuildEventsToJobEvents < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - rename_column_concurrently :services, :build_events, :job_events - end - - def down - cleanup_concurrent_column_rename :services, :job_events, :build_events - end -end diff --git a/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb b/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb deleted file mode 100644 index 0ed45775421..00000000000 --- a/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb +++ /dev/null @@ -1,83 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MigrateAssigneeToSeparateTable < ActiveRecord::Migration[4.2] - 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 up - drop_table(:issue_assignees) if table_exists?(:issue_assignees) - - if Gitlab::Database.mysql? - execute <<-EOF - CREATE TABLE issue_assignees AS - SELECT assignee_id AS user_id, id AS issue_id FROM issues WHERE assignee_id IS NOT NULL - EOF - else - ActiveRecord::Base.transaction do - execute('LOCK TABLE issues IN EXCLUSIVE MODE') - - execute <<-EOF - CREATE TABLE issue_assignees AS - SELECT assignee_id AS user_id, id AS issue_id FROM issues WHERE assignee_id IS NOT NULL - EOF - - execute <<-EOF - CREATE OR REPLACE FUNCTION replicate_assignee_id() - RETURNS trigger AS - $BODY$ - BEGIN - if OLD IS NOT NULL AND OLD.assignee_id IS NOT NULL THEN - DELETE FROM issue_assignees WHERE issue_id = OLD.id; - END IF; - - if NEW.assignee_id IS NOT NULL THEN - INSERT INTO issue_assignees (user_id, issue_id) VALUES (NEW.assignee_id, NEW.id); - END IF; - - RETURN NEW; - END; - $BODY$ - LANGUAGE 'plpgsql' - VOLATILE; - - CREATE TRIGGER replicate_assignee_id - BEFORE INSERT OR UPDATE OF assignee_id - ON issues - FOR EACH ROW EXECUTE PROCEDURE replicate_assignee_id(); - EOF - end - end - end - - def down - drop_table(:issue_assignees) if table_exists?(:issue_assignees) - - if Gitlab::Database.postgresql? - execute <<-EOF - DROP TRIGGER IF EXISTS replicate_assignee_id ON issues; - DROP FUNCTION IF EXISTS replicate_assignee_id(); - EOF - end - end -end diff --git a/db/migrate/20170516183131_add_indices_to_issue_assignees.rb b/db/migrate/20170516183131_add_indices_to_issue_assignees.rb deleted file mode 100644 index 6877fe9ff98..00000000000 --- a/db/migrate/20170516183131_add_indices_to_issue_assignees.rb +++ /dev/null @@ -1,41 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddIndicesToIssueAssignees < ActiveRecord::Migration[4.2] - 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 up - add_concurrent_index :issue_assignees, [:issue_id, :user_id], unique: true, name: 'index_issue_assignees_on_issue_id_and_user_id' - add_concurrent_index :issue_assignees, :user_id, name: 'index_issue_assignees_on_user_id' - add_concurrent_foreign_key :issue_assignees, :users, column: :user_id, on_delete: :cascade - add_concurrent_foreign_key :issue_assignees, :issues, column: :issue_id, on_delete: :cascade - end - - def down - remove_foreign_key :issue_assignees, column: :user_id - remove_foreign_key :issue_assignees, column: :issue_id - remove_concurrent_index :issue_assignees, [:issue_id, :user_id] if index_exists?(:issue_assignees, [:issue_id, :user_id]) - remove_concurrent_index :issue_assignees, :user_id if index_exists?(:issue_assignees, :user_id) - end -end diff --git a/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb b/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb deleted file mode 100644 index 9c8f58104bd..00000000000 --- a/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddPrometheusSettingsToMetricsSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_column_with_default(:application_settings, :prometheus_metrics_enabled, :boolean, - default: false, allow_null: false) - end - - def down - remove_column(:application_settings, :prometheus_metrics_enabled) - end -end diff --git a/db/migrate/20170521184006_add_change_position_to_notes.rb b/db/migrate/20170521184006_add_change_position_to_notes.rb deleted file mode 100644 index f0ca3a2a9ea..00000000000 --- a/db/migrate/20170521184006_add_change_position_to_notes.rb +++ /dev/null @@ -1,13 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddChangePositionToNotes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - add_column :notes, :change_position, :text - end -end diff --git a/db/migrate/20170523091700_add_rss_token_to_users.rb b/db/migrate/20170523091700_add_rss_token_to_users.rb deleted file mode 100644 index e1bcd9b3fee..00000000000 --- a/db/migrate/20170523091700_add_rss_token_to_users.rb +++ /dev/null @@ -1,19 +0,0 @@ -class AddRssTokenToUsers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column :users, :rss_token, :string - - add_concurrent_index :users, :rss_token - end - - def down - remove_concurrent_index :users, :rss_token if index_exists? :users, :rss_token - - remove_column :users, :rss_token - end -end diff --git a/db/migrate/20170523121229_create_conversational_development_index_metrics.rb b/db/migrate/20170523121229_create_conversational_development_index_metrics.rb deleted file mode 100644 index 5f8c0d07e3c..00000000000 --- a/db/migrate/20170523121229_create_conversational_development_index_metrics.rb +++ /dev/null @@ -1,40 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreateConversationalDevelopmentIndexMetrics < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :conversational_development_index_metrics do |t| - t.float :leader_issues, null: false - t.float :instance_issues, null: false - - t.float :leader_notes, null: false - t.float :instance_notes, null: false - - t.float :leader_milestones, null: false - t.float :instance_milestones, null: false - - t.float :leader_boards, null: false - t.float :instance_boards, null: false - - t.float :leader_merge_requests, null: false - t.float :instance_merge_requests, null: false - - t.float :leader_ci_pipelines, null: false - t.float :instance_ci_pipelines, null: false - - t.float :leader_environments, null: false - t.float :instance_environments, null: false - - t.float :leader_deployments, null: false - t.float :instance_deployments, null: false - - t.float :leader_projects_prometheus_active, null: false - t.float :instance_projects_prometheus_active, null: false - - t.float :leader_service_desk_issues, null: false - t.float :instance_service_desk_issues, null: false - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20170524125940_add_source_to_ci_pipeline.rb b/db/migrate/20170524125940_add_source_to_ci_pipeline.rb deleted file mode 100644 index 81358e7ce3d..00000000000 --- a/db/migrate/20170524125940_add_source_to_ci_pipeline.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddSourceToCiPipeline < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_pipelines, :source, :integer - end -end diff --git a/db/migrate/20170524161101_add_protected_to_ci_variables.rb b/db/migrate/20170524161101_add_protected_to_ci_variables.rb deleted file mode 100644 index 6125ea5d5a8..00000000000 --- a/db/migrate/20170524161101_add_protected_to_ci_variables.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddProtectedToCiVariables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:ci_variables, :protected, :boolean, default: false) - end - - def down - remove_column(:ci_variables, :protected) - end -end diff --git a/db/migrate/20170525130346_create_group_variables_table.rb b/db/migrate/20170525130346_create_group_variables_table.rb deleted file mode 100644 index 6eae7eff7bd..00000000000 --- a/db/migrate/20170525130346_create_group_variables_table.rb +++ /dev/null @@ -1,23 +0,0 @@ -class CreateGroupVariablesTable < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - create_table :ci_group_variables do |t| - t.string :key, null: false - t.text :value - t.text :encrypted_value - t.string :encrypted_value_salt - t.string :encrypted_value_iv - t.integer :group_id, null: false - t.boolean :protected, default: false, null: false - - t.timestamps_with_timezone null: false - end - - add_index :ci_group_variables, [:group_id, :key], unique: true - end - - def down - drop_table :ci_group_variables - end -end diff --git a/db/migrate/20170525130758_add_foreign_key_to_group_variables.rb b/db/migrate/20170525130758_add_foreign_key_to_group_variables.rb deleted file mode 100644 index f1f51a1dda3..00000000000 --- a/db/migrate/20170525130758_add_foreign_key_to_group_variables.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddForeignKeyToGroupVariables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :ci_group_variables, :namespaces, column: :group_id - end - - def down - remove_foreign_key :ci_group_variables, column: :group_id - end -end diff --git a/db/migrate/20170525132202_create_pipeline_stages.rb b/db/migrate/20170525132202_create_pipeline_stages.rb deleted file mode 100644 index 0a6400fde90..00000000000 --- a/db/migrate/20170525132202_create_pipeline_stages.rb +++ /dev/null @@ -1,26 +0,0 @@ -# rubocop:disable Migration/Timestamps -class CreatePipelineStages < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - create_table :ci_stages do |t| - t.integer :project_id - t.integer :pipeline_id - t.timestamps null: true - t.string :name - end - - add_concurrent_foreign_key :ci_stages, :projects, column: :project_id, on_delete: :cascade - add_concurrent_foreign_key :ci_stages, :ci_pipelines, column: :pipeline_id, on_delete: :cascade - add_concurrent_index :ci_stages, :project_id - add_concurrent_index :ci_stages, :pipeline_id - end - - def down - drop_table :ci_stages - end -end diff --git a/db/migrate/20170525174156_create_feature_tables.rb b/db/migrate/20170525174156_create_feature_tables.rb deleted file mode 100644 index e1eaaff8d35..00000000000 --- a/db/migrate/20170525174156_create_feature_tables.rb +++ /dev/null @@ -1,26 +0,0 @@ -class CreateFeatureTables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def self.up - create_table :features do |t| - t.string :key, null: false - t.timestamps null: false - end - add_index :features, :key, unique: true - - create_table :feature_gates do |t| - t.string :feature_key, null: false - t.string :key, null: false - t.string :value - t.timestamps null: false - end - add_index :feature_gates, [:feature_key, :key, :value], unique: true - end - - def self.down - drop_table :feature_gates - drop_table :features - end -end diff --git a/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb b/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb deleted file mode 100644 index 6958557d118..00000000000 --- a/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddStageIdToCiBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - add_column :ci_builds, :stage_id, :integer - end - - def down - remove_column :ci_builds, :stage_id, :integer - end -end diff --git a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb deleted file mode 100644 index b4658bc4017..00000000000 --- a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb +++ /dev/null @@ -1,198 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - CONCURRENCY = 4 - - disable_ddl_transaction! - - # The tables/columns for which to remove orphans and add foreign keys. Order - # matters as some tables/columns should be processed before others. - TABLES = [ - [:boards, :projects, :project_id], - [:lists, :labels, :label_id], - [:lists, :boards, :board_id], - [:services, :projects, :project_id], - [:forked_project_links, :projects, :forked_to_project_id], - [:merge_requests, :projects, :target_project_id], - [:labels, :projects, :project_id], - [:issues, :projects, :project_id], - [:events, :projects, :project_id], - [:milestones, :projects, :project_id], - [:notes, :projects, :project_id], - [:snippets, :projects, :project_id], - [:web_hooks, :projects, :project_id], - [:protected_branch_merge_access_levels, :protected_branches, :protected_branch_id], - [:protected_branch_push_access_levels, :protected_branches, :protected_branch_id], - [:protected_branches, :projects, :project_id], - [:protected_tags, :projects, :project_id], - [:deploy_keys_projects, :projects, :project_id], - [:users_star_projects, :projects, :project_id], - [:releases, :projects, :project_id], - [:project_group_links, :projects, :project_id], - [:pages_domains, :projects, :project_id], - [:todos, :projects, :project_id], - [:project_import_data, :projects, :project_id], - [:project_features, :projects, :project_id], - [:ci_builds, :projects, :project_id], - [:ci_pipelines, :projects, :project_id], - [:ci_runner_projects, :projects, :project_id], - [:ci_triggers, :projects, :project_id], - [:environments, :projects, :project_id], - [:deployments, :projects, :project_id] - ] - - def up - # These existing foreign keys don't have an "ON DELETE CASCADE" clause. - remove_foreign_key_without_error(:boards, :project_id) - remove_foreign_key_without_error(:lists, :label_id) - remove_foreign_key_without_error(:lists, :board_id) - remove_foreign_key_without_error(:protected_branch_merge_access_levels, - :protected_branch_id) - - remove_foreign_key_without_error(:protected_branch_push_access_levels, - :protected_branch_id) - - remove_orphaned_rows - add_foreign_keys - - # These columns are not indexed yet, meaning a cascading delete would take - # forever. - add_index_if_not_exists(:project_group_links, :project_id) - add_index_if_not_exists(:pages_domains, :project_id) - end - - def down - TABLES.each do |(source, _, column)| - remove_foreign_key_without_error(source, column) - end - - add_foreign_key_if_not_exists(:boards, :projects, column: :project_id) - add_foreign_key_if_not_exists(:lists, :labels, column: :label_id) - add_foreign_key_if_not_exists(:lists, :boards, column: :board_id) - - add_foreign_key_if_not_exists(:protected_branch_merge_access_levels, - :protected_branches, - column: :protected_branch_id) - - add_foreign_key_if_not_exists(:protected_branch_push_access_levels, - :protected_branches, - column: :protected_branch_id) - - remove_index_without_error(:project_group_links, :project_id) - remove_index_without_error(:pages_domains, :project_id) - end - - def add_foreign_keys - TABLES.each do |(source, target, column)| - add_foreign_key_if_not_exists(source, target, column: column) - end - end - - # Removes orphans from various tables concurrently. - def remove_orphaned_rows - Gitlab::Database.with_connection_pool(CONCURRENCY) do |pool| - queues = queues_for_rows(TABLES) - - threads = queues.map do |queue| - Thread.new do - pool.with_connection do |connection| - Thread.current[:foreign_key_connection] = connection - - # Disables statement timeouts for the current connection. This is - # necessary as removing of orphaned data might otherwise exceed the - # statement timeout. - disable_statement_timeout do - remove_orphans(*queue.pop) until queue.empty? - - steal_from_queues(queues - [queue]) - end - end - end - end - - threads.each(&:join) - end - end - - def steal_from_queues(queues) - loop do - stolen = false - - queues.each do |queue| - # Stealing is racy so it's possible a pop might be called on an - # already-empty queue. - - remove_orphans(*queue.pop(true)) - stolen = true - rescue ThreadError - end - - break unless stolen - end - end - - def remove_orphans(source, target, column) - quoted_source = quote_table_name(source) - quoted_target = quote_table_name(target) - quoted_column = quote_column_name(column) - - execute <<-EOF.strip_heredoc - DELETE FROM #{quoted_source} - WHERE NOT EXISTS ( - SELECT true - FROM #{quoted_target} - WHERE #{quoted_target}.id = #{quoted_source}.#{quoted_column} - ) - AND #{quoted_source}.#{quoted_column} IS NOT NULL - EOF - end - - def add_foreign_key_if_not_exists(source, target, column:) - return if foreign_key_exists?(source, target, column: column) - - add_concurrent_foreign_key(source, target, column: column) - end - - def add_index_if_not_exists(table, column) - return if index_exists?(table, column) - - add_concurrent_index(table, column) - end - - def remove_foreign_key_without_error(table, column) - remove_foreign_key(table, column: column) - rescue ArgumentError - end - - def remove_index_without_error(table, column) - remove_concurrent_index(table, column) - rescue ArgumentError - 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 - - def queues_for_rows(rows) - queues = Array.new(CONCURRENCY) { Queue.new } - slice_size = rows.length / CONCURRENCY - - # Divide all the tuples as evenly as possible amongst the queues. - rows.each_slice(slice_size).each_with_index do |slice, index| - bucket = index % CONCURRENCY - - slice.each do |row| - queues[bucket] << row - end - end - - queues - end -end diff --git a/db/migrate/20170531180233_add_authorized_keys_enabled_to_application_settings.rb b/db/migrate/20170531180233_add_authorized_keys_enabled_to_application_settings.rb deleted file mode 100644 index f440609ff8a..00000000000 --- a/db/migrate/20170531180233_add_authorized_keys_enabled_to_application_settings.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddAuthorizedKeysEnabledToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :application_settings, :authorized_keys_enabled, :boolean, default: true, allow_null: false - end - - def down - remove_column :application_settings, :authorized_keys_enabled - end -end diff --git a/db/migrate/20170531202042_rename_users_ldap_email_to_external_email.rb b/db/migrate/20170531202042_rename_users_ldap_email_to_external_email.rb deleted file mode 100644 index 7b1a7644555..00000000000 --- a/db/migrate/20170531202042_rename_users_ldap_email_to_external_email.rb +++ /dev/null @@ -1,16 +0,0 @@ -class RenameUsersLdapEmailToExternalEmail < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - # rubocop:disable Migration/UpdateLargeTable - rename_column_concurrently :users, :ldap_email, :external_email - end - - def down - cleanup_concurrent_column_rename :users, :external_email, :ldap_email - end -end diff --git a/db/migrate/20170601163708_add_artifacts_store_to_ci_build.rb b/db/migrate/20170601163708_add_artifacts_store_to_ci_build.rb deleted file mode 100644 index 4c9ac821b20..00000000000 --- a/db/migrate/20170601163708_add_artifacts_store_to_ci_build.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddArtifactsStoreToCiBuild < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column(:ci_builds, :artifacts_file_store, :integer) - add_column(:ci_builds, :artifacts_metadata_store, :integer) - end -end diff --git a/db/migrate/20170602154736_add_help_page_hide_commercial_content_to_application_settings.rb b/db/migrate/20170602154736_add_help_page_hide_commercial_content_to_application_settings.rb deleted file mode 100644 index ff9e188d7a8..00000000000 --- a/db/migrate/20170602154736_add_help_page_hide_commercial_content_to_application_settings.rb +++ /dev/null @@ -1,10 +0,0 @@ -# rubocop:disable Migration/SaferBooleanColumn -class AddHelpPageHideCommercialContentToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, :help_page_hide_commercial_content, :boolean, default: false - end -end diff --git a/db/migrate/20170602154813_add_help_page_support_url_to_application_settings.rb b/db/migrate/20170602154813_add_help_page_support_url_to_application_settings.rb deleted file mode 100644 index 388e130ab88..00000000000 --- a/db/migrate/20170602154813_add_help_page_support_url_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddHelpPageSupportUrlToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, :help_page_support_url, :string - end -end diff --git a/db/migrate/20170603200744_add_email_provider_to_users.rb b/db/migrate/20170603200744_add_email_provider_to_users.rb deleted file mode 100644 index ad6e813d31b..00000000000 --- a/db/migrate/20170603200744_add_email_provider_to_users.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddEmailProviderToUsers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :users, :email_provider, :string - end -end diff --git a/db/migrate/20170606154216_add_notification_setting_columns.rb b/db/migrate/20170606154216_add_notification_setting_columns.rb deleted file mode 100644 index 3b9493e6b49..00000000000 --- a/db/migrate/20170606154216_add_notification_setting_columns.rb +++ /dev/null @@ -1,26 +0,0 @@ -class AddNotificationSettingColumns < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - COLUMNS = [ - :new_note, - :new_issue, - :reopen_issue, - :close_issue, - :reassign_issue, - :new_merge_request, - :reopen_merge_request, - :close_merge_request, - :reassign_merge_request, - :merge_merge_request, - :failed_pipeline, - :success_pipeline - ] - - def change - COLUMNS.each do |column| - add_column(:notification_settings, column, :boolean) - end - end -end diff --git a/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb b/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb deleted file mode 100644 index 851af7f7bf6..00000000000 --- a/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb +++ /dev/null @@ -1,51 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class PrepareEventsTableForPushEventsMigration < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - # The order of these columns is deliberate and results in the following - # columns and sizes: - # - # * id (4 bytes) - # * project_id (4 bytes) - # * author_id (4 bytes) - # * target_id (4 bytes) - # * created_at (8 bytes) - # * updated_at (8 bytes) - # * action (2 bytes) - # * target_type (variable) - # - # Unfortunately we can't make the "id" column a bigint/bigserial as Rails 4 - # does not support this properly. - create_table :events_for_migration do |t| - t.references :project, - index: true, - foreign_key: { on_delete: :cascade } - - t.integer :author_id, index: true, null: false - t.integer :target_id - - t.timestamps_with_timezone null: false - - t.integer :action, null: false, limit: 2, index: true - t.string :target_type - - t.index %i[target_type target_id] - end - - # t.references doesn't like it when the column name doesn't make the table - # name so we have to add the foreign key separately. - add_concurrent_foreign_key(:events_for_migration, :users, column: :author_id) - end - - def down - drop_table :events_for_migration - end -end diff --git a/db/migrate/20170608152748_create_push_event_payloads_tables.rb b/db/migrate/20170608152748_create_push_event_payloads_tables.rb deleted file mode 100644 index 292d9e3ca06..00000000000 --- a/db/migrate/20170608152748_create_push_event_payloads_tables.rb +++ /dev/null @@ -1,46 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CreatePushEventPayloadsTables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - create_table :push_event_payloads, id: false do |t| - t.bigint :commit_count, null: false - - t.integer :event_id, null: false - t.integer :action, null: false, limit: 2 - t.integer :ref_type, null: false, limit: 2 - - t.binary :commit_from - t.binary :commit_to - - t.text :ref - t.string :commit_title, limit: 70 - - t.index :event_id, unique: true - end - - # We're adding a foreign key to the _shadow_ table, and this is deliberate. - # By using the shadow table we don't have to recreate/revalidate this - # foreign key after swapping the "events_for_migration" and "events" tables. - # - # The "events_for_migration" table has a foreign key to "projects.id" - # ensuring that project removals also remove events from the shadow table - # (and thus also from this table). - add_concurrent_foreign_key( - :push_event_payloads, - :events_for_migration, - column: :event_id - ) - end - - def down - drop_table :push_event_payloads - end -end diff --git a/db/migrate/20170608171156_create_merge_request_diff_files.rb b/db/migrate/20170608171156_create_merge_request_diff_files.rb deleted file mode 100644 index 94b518455ee..00000000000 --- a/db/migrate/20170608171156_create_merge_request_diff_files.rb +++ /dev/null @@ -1,22 +0,0 @@ -class CreateMergeRequestDiffFiles < ActiveRecord::Migration[4.2] - DOWNTIME = false - - disable_ddl_transaction! - - def change - create_table :merge_request_diff_files, id: false do |t| - t.belongs_to :merge_request_diff, null: false, foreign_key: { on_delete: :cascade } - t.integer :relative_order, null: false - t.boolean :new_file, null: false - t.boolean :renamed_file, null: false - t.boolean :deleted_file, null: false - t.boolean :too_large, null: false - t.string :a_mode, null: false - t.string :b_mode, null: false - t.text :new_path, null: false - t.text :old_path, null: false - t.text :diff, null: false - t.index [:merge_request_diff_id, :relative_order], name: 'index_merge_request_diff_files_on_mr_diff_id_and_order', unique: true - end - end -end diff --git a/db/migrate/20170613154149_create_gpg_signatures.rb b/db/migrate/20170613154149_create_gpg_signatures.rb deleted file mode 100644 index 181d35fe7af..00000000000 --- a/db/migrate/20170613154149_create_gpg_signatures.rb +++ /dev/null @@ -1,25 +0,0 @@ -class CreateGpgSignatures < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :gpg_signatures do |t| - t.timestamps_with_timezone null: false - - t.references :project, index: true, foreign_key: { on_delete: :cascade } - t.references :gpg_key, index: true, foreign_key: { on_delete: :nullify } - - t.boolean :valid_signature - - t.binary :commit_sha - t.binary :gpg_key_primary_keyid - - t.text :gpg_key_user_name - t.text :gpg_key_user_email - - t.index :commit_sha, unique: true, length: mysql_compatible_index_length - t.index :gpg_key_primary_keyid, length: mysql_compatible_index_length - end - end -end diff --git a/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb b/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb deleted file mode 100644 index 4c1cf08aa06..00000000000 --- a/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb +++ /dev/null @@ -1 +0,0 @@ -require_relative 'merge_request_diff_file_limits_to_mysql' diff --git a/db/migrate/20170616133147_create_merge_request_diff_commits.rb b/db/migrate/20170616133147_create_merge_request_diff_commits.rb deleted file mode 100644 index 5e148affba2..00000000000 --- a/db/migrate/20170616133147_create_merge_request_diff_commits.rb +++ /dev/null @@ -1,20 +0,0 @@ -class CreateMergeRequestDiffCommits < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :merge_request_diff_commits, id: false do |t| - t.datetime_with_timezone :authored_date - t.datetime_with_timezone :committed_date - t.belongs_to :merge_request_diff, null: false, foreign_key: { on_delete: :cascade } - t.integer :relative_order, null: false - t.binary :sha, null: false, limit: 20 - t.text :author_name - t.text :author_email - t.text :committer_name - t.text :committer_email - t.text :message - - t.index [:merge_request_diff_id, :relative_order], name: 'index_merge_request_diff_commits_on_mr_diff_id_and_order', unique: true - end - end -end diff --git a/db/migrate/20170619144837_add_index_for_head_pipeline_merge_request.rb b/db/migrate/20170619144837_add_index_for_head_pipeline_merge_request.rb deleted file mode 100644 index f97c8a14b8d..00000000000 --- a/db/migrate/20170619144837_add_index_for_head_pipeline_merge_request.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddIndexForHeadPipelineMergeRequest < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :merge_requests, :head_pipeline_id - end - - def down - remove_concurrent_index :merge_requests, :head_pipeline_id if index_exists?(:merge_requests, :head_pipeline_id) - end -end diff --git a/db/migrate/20170620064728_create_ci_pipeline_schedule_variables.rb b/db/migrate/20170620064728_create_ci_pipeline_schedule_variables.rb deleted file mode 100644 index 74f3603505b..00000000000 --- a/db/migrate/20170620064728_create_ci_pipeline_schedule_variables.rb +++ /dev/null @@ -1,25 +0,0 @@ -class CreateCiPipelineScheduleVariables < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - create_table :ci_pipeline_schedule_variables do |t| - t.string :key, null: false - t.text :value - t.text :encrypted_value - t.string :encrypted_value_salt - t.string :encrypted_value_iv - t.integer :pipeline_schedule_id, null: false - - t.timestamps_with_timezone null: true - end - - add_index :ci_pipeline_schedule_variables, - [:pipeline_schedule_id, :key], - name: "index_ci_pipeline_schedule_variables_on_schedule_id_and_key", - unique: true - end - - def down - drop_table :ci_pipeline_schedule_variables - end -end diff --git a/db/migrate/20170620065449_add_foreign_key_to_ci_pipeline_schedule_variables.rb b/db/migrate/20170620065449_add_foreign_key_to_ci_pipeline_schedule_variables.rb deleted file mode 100644 index f6de19aeaf2..00000000000 --- a/db/migrate/20170620065449_add_foreign_key_to_ci_pipeline_schedule_variables.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddForeignKeyToCiPipelineScheduleVariables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key(:ci_pipeline_schedule_variables, :ci_pipeline_schedules, column: :pipeline_schedule_id) - end - - def down - remove_foreign_key(:ci_pipeline_schedule_variables, column: :pipeline_schedule_id) - end -end diff --git a/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb b/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb deleted file mode 100644 index c4ba3ec2cc0..00000000000 --- a/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb +++ /dev/null @@ -1,40 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CorrectProtectedBranchesForeignKeys < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - remove_foreign_key_without_error(:protected_branch_push_access_levels, - column: :protected_branch_id) - - execute <<-EOF - DELETE FROM protected_branch_push_access_levels - WHERE NOT EXISTS ( - SELECT true - FROM protected_branches - WHERE protected_branch_push_access_levels.protected_branch_id = protected_branches.id - ) - AND protected_branch_id IS NOT NULL - EOF - - add_concurrent_foreign_key(:protected_branch_push_access_levels, - :protected_branches, - column: :protected_branch_id) - end - - def down - # Previously there was a foreign key without a CASCADING DELETE, so we'll - # just leave the foreign key in place. - end - - def remove_foreign_key_without_error(*args) - remove_foreign_key(*args) - rescue ArgumentError - end -end diff --git a/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb b/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb deleted file mode 100644 index b826f67ff39..00000000000 --- a/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb +++ /dev/null @@ -1,30 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddForeignKeyForMergeRequestDiffs < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - execute <<-EOF - DELETE FROM merge_request_diffs - WHERE NOT EXISTS ( - SELECT true - FROM merge_requests - WHERE merge_requests.id = merge_request_diffs.merge_request_id - ) - EOF - - add_concurrent_foreign_key(:merge_request_diffs, - :merge_requests, - column: :merge_request_id) - end - - def down - remove_foreign_key(:merge_request_diffs, column: :merge_request_id) - end -end diff --git a/db/migrate/20170622135451_rename_duplicated_variable_key.rb b/db/migrate/20170622135451_rename_duplicated_variable_key.rb deleted file mode 100644 index 06a9529ae79..00000000000 --- a/db/migrate/20170622135451_rename_duplicated_variable_key.rb +++ /dev/null @@ -1,38 +0,0 @@ -class RenameDuplicatedVariableKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - execute(<<~SQL) - UPDATE ci_variables - SET #{key} = CONCAT(#{key}, #{underscore}, id) - WHERE id IN ( - SELECT * - FROM ( -- MySQL requires an extra layer - SELECT dup.id - FROM ci_variables dup - INNER JOIN (SELECT max(id) AS id, #{key}, project_id - FROM ci_variables tmp - GROUP BY #{key}, project_id) var - USING (#{key}, project_id) where dup.id <> var.id - ) dummy - ) - SQL - end - - def down - # noop - end - - def key - # key needs to be quoted in MySQL - quote_column_name('key') - end - - def underscore - quote('_') - end -end diff --git a/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb b/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb deleted file mode 100644 index 8fbb2ab57d5..00000000000 --- a/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddEnvironmentScopeToCiVariables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:ci_variables, :environment_scope, :string, default: '*') - end - - def down - remove_column(:ci_variables, :environment_scope) - end -end diff --git a/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb b/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb deleted file mode 100644 index 240f55766d3..00000000000 --- a/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb +++ /dev/null @@ -1,35 +0,0 @@ -class AddUniqueConstraintToCiVariables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'index_ci_variables_on_project_id_and_key_and_environment_scope' - - disable_ddl_transaction! - - def up - unless this_index_exists? - add_concurrent_index(:ci_variables, columns, name: INDEX_NAME, unique: true) - end - end - - def down - if this_index_exists? - if Gitlab::Database.mysql? && !index_exists?(:ci_variables, :project_id) - # Need to add this index for MySQL project_id foreign key constraint - add_concurrent_index(:ci_variables, :project_id) - end - - remove_concurrent_index(:ci_variables, columns, name: INDEX_NAME) - end - end - - private - - def this_index_exists? - index_exists?(:ci_variables, columns, name: INDEX_NAME) - end - - def columns - @columns ||= [:project_id, :key, :environment_scope] - end -end diff --git a/db/migrate/20170622162730_add_ref_fetched_to_merge_request.rb b/db/migrate/20170622162730_add_ref_fetched_to_merge_request.rb deleted file mode 100644 index 4715ff7a715..00000000000 --- a/db/migrate/20170622162730_add_ref_fetched_to_merge_request.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddRefFetchedToMergeRequest < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :merge_requests, :ref_fetched, :boolean - end -end diff --git a/db/migrate/20170623080805_remove_ci_variables_project_id_index.rb b/db/migrate/20170623080805_remove_ci_variables_project_id_index.rb deleted file mode 100644 index 861dbd2ee14..00000000000 --- a/db/migrate/20170623080805_remove_ci_variables_project_id_index.rb +++ /dev/null @@ -1,19 +0,0 @@ -class RemoveCiVariablesProjectIdIndex < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - if index_exists?(:ci_variables, :project_id) - remove_concurrent_index(:ci_variables, :project_id) - end - end - - def down - unless index_exists?(:ci_variables, :project_id) - add_concurrent_index(:ci_variables, :project_id) - end - end -end diff --git a/db/migrate/20170629171610_rename_application_settings_signin_enabled_to_password_authentication_enabled.rb b/db/migrate/20170629171610_rename_application_settings_signin_enabled_to_password_authentication_enabled.rb deleted file mode 100644 index 1651a47ebec..00000000000 --- a/db/migrate/20170629171610_rename_application_settings_signin_enabled_to_password_authentication_enabled.rb +++ /dev/null @@ -1,15 +0,0 @@ -class RenameApplicationSettingsSigninEnabledToPasswordAuthenticationEnabled < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - rename_column_concurrently :application_settings, :signin_enabled, :password_authentication_enabled - end - - def down - cleanup_concurrent_column_rename :application_settings, :password_authentication_enabled, :signin_enabled - end -end diff --git a/db/migrate/20170703102400_add_stage_id_foreign_key_to_builds.rb b/db/migrate/20170703102400_add_stage_id_foreign_key_to_builds.rb deleted file mode 100644 index 36ac360fb0b..00000000000 --- a/db/migrate/20170703102400_add_stage_id_foreign_key_to_builds.rb +++ /dev/null @@ -1,27 +0,0 @@ -class AddStageIdForeignKeyToBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - unless index_exists?(:ci_builds, :stage_id) - add_concurrent_index(:ci_builds, :stage_id) - end - - unless foreign_key_exists?(:ci_builds, :ci_stages, column: :stage_id) - add_concurrent_foreign_key(:ci_builds, :ci_stages, column: :stage_id, on_delete: :cascade) - end - end - - def down - if foreign_key_exists?(:ci_builds, column: :stage_id) - remove_foreign_key(:ci_builds, column: :stage_id) - end - - if index_exists?(:ci_builds, :stage_id) - remove_concurrent_index(:ci_builds, :stage_id) - end - end -end diff --git a/db/migrate/20170706151212_add_performance_bar_allowed_group_id_to_application_settings.rb b/db/migrate/20170706151212_add_performance_bar_allowed_group_id_to_application_settings.rb deleted file mode 100644 index 61416f74b63..00000000000 --- a/db/migrate/20170706151212_add_performance_bar_allowed_group_id_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddPerformanceBarAllowedGroupIdToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, :performance_bar_allowed_group_id, :integer - end -end diff --git a/db/migrate/20170707183807_add_group_id_to_milestones.rb b/db/migrate/20170707183807_add_group_id_to_milestones.rb deleted file mode 100644 index e778a30192f..00000000000 --- a/db/migrate/20170707183807_add_group_id_to_milestones.rb +++ /dev/null @@ -1,20 +0,0 @@ -class AddGroupIdToMilestones < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - return if column_exists? :milestones, :group_id - - change_column_null :milestones, :project_id, true - - add_column :milestones, :group_id, :integer - end - - def down - # We cannot rollback project_id not null constraint if there are records - # with null values. - execute "DELETE from milestones WHERE project_id IS NULL" - - remove_column :milestones, :group_id - change_column :milestones, :project_id, :integer, null: false - end -end diff --git a/db/migrate/20170707184243_add_group_milestone_id_indexes.rb b/db/migrate/20170707184243_add_group_milestone_id_indexes.rb deleted file mode 100644 index 545ee070194..00000000000 --- a/db/migrate/20170707184243_add_group_milestone_id_indexes.rb +++ /dev/null @@ -1,21 +0,0 @@ -class AddGroupMilestoneIdIndexes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - - def up - return if index_exists?(:milestones, :group_id) - - add_concurrent_foreign_key :milestones, :namespaces, column: :group_id, on_delete: :cascade - - add_concurrent_index :milestones, :group_id - end - - def down - remove_foreign_key :milestones, column: :group_id - - remove_concurrent_index :milestones, :group_id - end -end diff --git a/db/migrate/20170707184244_remove_wrong_versions_from_schema_versions.rb b/db/migrate/20170707184244_remove_wrong_versions_from_schema_versions.rb deleted file mode 100644 index f99206c7f78..00000000000 --- a/db/migrate/20170707184244_remove_wrong_versions_from_schema_versions.rb +++ /dev/null @@ -1,10 +0,0 @@ -class RemoveWrongVersionsFromSchemaVersions < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - execute("DELETE FROM schema_migrations WHERE version IN ('20170723183807', '20170724184243')") - end - - def down - end -end diff --git a/db/migrate/20170710083355_clean_stage_id_reference_migration.rb b/db/migrate/20170710083355_clean_stage_id_reference_migration.rb deleted file mode 100644 index d33c6f53b15..00000000000 --- a/db/migrate/20170710083355_clean_stage_id_reference_migration.rb +++ /dev/null @@ -1,18 +0,0 @@ -class CleanStageIdReferenceMigration < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - ## - # `MigrateStageIdReferenceInBackground` background migration cleanup. - # - def up - Gitlab::BackgroundMigration.steal('MigrateBuildStageIdReference') - end - - def down - # noop - end -end diff --git a/db/migrate/20170711145320_add_status_to_ci_stages.rb b/db/migrate/20170711145320_add_status_to_ci_stages.rb deleted file mode 100644 index 3ea7b750882..00000000000 --- a/db/migrate/20170711145320_add_status_to_ci_stages.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddStatusToCiStages < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_stages, :status, :integer - end -end diff --git a/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb b/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb deleted file mode 100644 index 908b122c659..00000000000 --- a/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb +++ /dev/null @@ -1,37 +0,0 @@ -class AddForeignKeyToMergeRequests < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' - include ::EachBatch - end - - def up - scope = <<-SQL.strip_heredoc - head_pipeline_id IS NOT NULL - AND NOT EXISTS ( - SELECT 1 FROM ci_pipelines - WHERE ci_pipelines.id = merge_requests.head_pipeline_id - ) - SQL - - MergeRequest.where(scope).each_batch(of: 1000) do |merge_requests| - merge_requests.update_all(head_pipeline_id: nil) - end - - unless foreign_key_exists?(:merge_requests, column: :head_pipeline_id) - add_concurrent_foreign_key(:merge_requests, :ci_pipelines, - column: :head_pipeline_id, on_delete: :nullify) - end - end - - def down - if foreign_key_exists?(:merge_requests, column: :head_pipeline_id) - remove_foreign_key(:merge_requests, column: :head_pipeline_id) - end - end -end diff --git a/db/migrate/20170717074009_move_system_upload_folder.rb b/db/migrate/20170717074009_move_system_upload_folder.rb deleted file mode 100644 index 6c57a751c8d..00000000000 --- a/db/migrate/20170717074009_move_system_upload_folder.rb +++ /dev/null @@ -1,70 +0,0 @@ -class MoveSystemUploadFolder < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - unless file_storage? - say 'Using object storage, no need to move.' - return - end - - unless File.directory?(old_directory) - say "#{old_directory} doesn't exist, no need to move it." - return - end - - if File.directory?(new_directory) - say "#{new_directory} already exists. No need to redo the move." - return - end - - FileUtils.mkdir_p(File.join(base_directory, '-')) - - say "Moving #{old_directory} -> #{new_directory}" - FileUtils.mv(old_directory, new_directory) - FileUtils.ln_s(new_directory, old_directory) - end - - def down - unless file_storage? - say 'Using object storage, no need to move.' - return - end - - unless File.directory?(new_directory) - say "#{new_directory} doesn't exist, no need to move it." - return - end - - if !File.symlink?(old_directory) && File.directory?(old_directory) - say "#{old_directory} already exists and is not a symlink, no need to revert." - return - end - - if File.symlink?(old_directory) - say "Removing #{old_directory} -> #{new_directory} symlink" - FileUtils.rm(old_directory) - end - - say "Moving #{new_directory} -> #{old_directory}" - FileUtils.mv(new_directory, old_directory) - end - - def new_directory - File.join(base_directory, '-', 'system') - end - - def old_directory - File.join(base_directory, 'system') - end - - def base_directory - File.join(Rails.root, 'public', 'uploads') - end - - def file_storage? - CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File - end -end diff --git a/db/migrate/20170717200542_add_trusted_column_to_oauth_applications.rb b/db/migrate/20170717200542_add_trusted_column_to_oauth_applications.rb deleted file mode 100644 index d9ae86f6c52..00000000000 --- a/db/migrate/20170717200542_add_trusted_column_to_oauth_applications.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddTrustedColumnToOauthApplications < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:oauth_applications, :trusted, :boolean, default: false) - end - - def down - remove_column(:oauth_applications, :trusted) - end -end diff --git a/db/migrate/20170720111708_add_lock_version_to_ci_stages.rb b/db/migrate/20170720111708_add_lock_version_to_ci_stages.rb deleted file mode 100644 index a5caca7e80c..00000000000 --- a/db/migrate/20170720111708_add_lock_version_to_ci_stages.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddLockVersionToCiStages < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_stages, :lock_version, :integer - end -end diff --git a/db/migrate/20170720122741_create_user_custom_attributes.rb b/db/migrate/20170720122741_create_user_custom_attributes.rb deleted file mode 100644 index 0e6f37d7317..00000000000 --- a/db/migrate/20170720122741_create_user_custom_attributes.rb +++ /dev/null @@ -1,17 +0,0 @@ -class CreateUserCustomAttributes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :user_custom_attributes do |t| - t.timestamps_with_timezone null: false - t.references :user, null: false, foreign_key: { on_delete: :cascade } - t.string :key, null: false - t.string :value, null: false - - t.index [:user_id, :key], unique: true - t.index [:key, :value] - end - end -end diff --git a/db/migrate/20170720130522_create_ci_pipeline_variables.rb b/db/migrate/20170720130522_create_ci_pipeline_variables.rb deleted file mode 100644 index 4f162d46cf5..00000000000 --- a/db/migrate/20170720130522_create_ci_pipeline_variables.rb +++ /dev/null @@ -1,20 +0,0 @@ -class CreateCiPipelineVariables < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - create_table :ci_pipeline_variables do |t| - t.string :key, null: false - t.text :value - t.text :encrypted_value - t.string :encrypted_value_salt - t.string :encrypted_value_iv - t.integer :pipeline_id, null: false - end - - add_index :ci_pipeline_variables, [:pipeline_id, :key], unique: true - end - - def down - drop_table :ci_pipeline_variables - end -end diff --git a/db/migrate/20170720130749_add_foreign_key_to_ci_pipeline_variables.rb b/db/migrate/20170720130749_add_foreign_key_to_ci_pipeline_variables.rb deleted file mode 100644 index df9350d9ad5..00000000000 --- a/db/migrate/20170720130749_add_foreign_key_to_ci_pipeline_variables.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddForeignKeyToCiPipelineVariables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key(:ci_pipeline_variables, :ci_pipelines, column: :pipeline_id) - end - - def down - remove_foreign_key(:ci_pipeline_variables, column: :pipeline_id) - end -end diff --git a/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb b/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb deleted file mode 100644 index 1a6516f8777..00000000000 --- a/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb +++ /dev/null @@ -1,35 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddLowerPathIndexToRedirectRoutes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'index_on_redirect_routes_lower_path' - - disable_ddl_transaction! - - def up - return unless Gitlab::Database.postgresql? - - execute "CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON redirect_routes (LOWER(path));" - end - - def down - return unless Gitlab::Database.postgresql? - - # Why not use remove_concurrent_index_by_name? - # - # `index_exists?` doesn't work on this index. Perhaps this is related to the - # fact that the index doesn't show up in the schema. And apparently it isn't - # trivial to write a query that checks for an index. BUT there is a - # convenient `IF EXISTS` parameter for `DROP INDEX`. - if supports_drop_index_concurrently? - disable_statement_timeout do - execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME};" - end - else - execute "DROP INDEX IF EXISTS #{INDEX_NAME};" - end - end -end diff --git a/db/migrate/20170725145659_add_binary_to_merge_request_diff_files.rb b/db/migrate/20170725145659_add_binary_to_merge_request_diff_files.rb deleted file mode 100644 index c7d377547e4..00000000000 --- a/db/migrate/20170725145659_add_binary_to_merge_request_diff_files.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddBinaryToMergeRequestDiffFiles < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :merge_request_diff_files, :binary, :boolean - end -end diff --git a/db/migrate/20170727123534_add_index_on_events_project_id_id.rb b/db/migrate/20170727123534_add_index_on_events_project_id_id.rb deleted file mode 100644 index 076b8ee87b2..00000000000 --- a/db/migrate/20170727123534_add_index_on_events_project_id_id.rb +++ /dev/null @@ -1,37 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddIndexOnEventsProjectIdId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - COLUMNS = %i[project_id id].freeze - TABLES = %i[events events_for_migration].freeze - - disable_ddl_transaction! - - def up - TABLES.each do |table| - add_concurrent_index(table, COLUMNS) unless index_exists?(table, COLUMNS) - - # We remove the index _after_ adding the new one since MySQL doesn't let - # you remove an index when a foreign key exists for the same column. - if index_exists?(table, :project_id) - remove_concurrent_index(table, :project_id) - end - end - end - - def down - TABLES.each do |table| - unless index_exists?(table, :project_id) - add_concurrent_index(table, :project_id) - end - - unless index_exists?(table, COLUMNS) - remove_concurrent_index(table, COLUMNS) - end - end - end -end diff --git a/db/migrate/20170731175128_add_percentages_to_conv_dev.rb b/db/migrate/20170731175128_add_percentages_to_conv_dev.rb deleted file mode 100644 index 522e99c0751..00000000000 --- a/db/migrate/20170731175128_add_percentages_to_conv_dev.rb +++ /dev/null @@ -1,32 +0,0 @@ -class AddPercentagesToConvDev < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_column_with_default :conversational_development_index_metrics, :percentage_boards, :float, allow_null: false, default: 0 - add_column_with_default :conversational_development_index_metrics, :percentage_ci_pipelines, :float, allow_null: false, default: 0 - add_column_with_default :conversational_development_index_metrics, :percentage_deployments, :float, allow_null: false, default: 0 - add_column_with_default :conversational_development_index_metrics, :percentage_environments, :float, allow_null: false, default: 0 - add_column_with_default :conversational_development_index_metrics, :percentage_issues, :float, allow_null: false, default: 0 - add_column_with_default :conversational_development_index_metrics, :percentage_merge_requests, :float, allow_null: false, default: 0 - add_column_with_default :conversational_development_index_metrics, :percentage_milestones, :float, allow_null: false, default: 0 - add_column_with_default :conversational_development_index_metrics, :percentage_notes, :float, allow_null: false, default: 0 - add_column_with_default :conversational_development_index_metrics, :percentage_projects_prometheus_active, :float, allow_null: false, default: 0 - add_column_with_default :conversational_development_index_metrics, :percentage_service_desk_issues, :float, allow_null: false, default: 0 - end - - def down - remove_column :conversational_development_index_metrics, :percentage_boards - remove_column :conversational_development_index_metrics, :percentage_ci_pipelines - remove_column :conversational_development_index_metrics, :percentage_deployments - remove_column :conversational_development_index_metrics, :percentage_environments - remove_column :conversational_development_index_metrics, :percentage_issues - remove_column :conversational_development_index_metrics, :percentage_merge_requests - remove_column :conversational_development_index_metrics, :percentage_milestones - remove_column :conversational_development_index_metrics, :percentage_notes - remove_column :conversational_development_index_metrics, :percentage_projects_prometheus_active - remove_column :conversational_development_index_metrics, :percentage_service_desk_issues - end -end diff --git a/db/migrate/20170731183033_add_merge_jid_to_merge_requests.rb b/db/migrate/20170731183033_add_merge_jid_to_merge_requests.rb deleted file mode 100644 index 3c677f3bc2d..00000000000 --- a/db/migrate/20170731183033_add_merge_jid_to_merge_requests.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddMergeJidToMergeRequests < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column :merge_requests, :merge_jid, :string - end -end diff --git a/db/migrate/20170802013652_add_storage_fields_to_project.rb b/db/migrate/20170802013652_add_storage_fields_to_project.rb deleted file mode 100644 index d6672b9b3af..00000000000 --- a/db/migrate/20170802013652_add_storage_fields_to_project.rb +++ /dev/null @@ -1,16 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddStorageFieldsToProject < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - add_column :projects, :storage_version, :integer, limit: 2 - end - - def down - remove_column :projects, :storage_version - end -end diff --git a/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb b/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb deleted file mode 100644 index e92b5f28685..00000000000 --- a/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb +++ /dev/null @@ -1,43 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class ReorganiseIssuesIndexesForFasterSorting < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - REMOVE_INDEX_COLUMNS = %i[project_id created_at due_date updated_at].freeze - - ADD_INDEX_COLUMNS = [ - %i[project_id created_at id state], - %i[project_id due_date id state], - %i[project_id updated_at id state] - ].freeze - - TABLE = :issues - - def up - add_indexes(ADD_INDEX_COLUMNS) - remove_indexes(REMOVE_INDEX_COLUMNS) - end - - def down - add_indexes(REMOVE_INDEX_COLUMNS) - remove_indexes(ADD_INDEX_COLUMNS) - end - - def add_indexes(columns) - columns.each do |column| - add_concurrent_index(TABLE, column) unless index_exists?(TABLE, column) - end - end - - def remove_indexes(columns) - columns.each do |column| - remove_concurrent_index(TABLE, column) if index_exists?(TABLE, column) - end - end -end diff --git a/db/migrate/20170807071105_add_hashed_storage_to_settings.rb b/db/migrate/20170807071105_add_hashed_storage_to_settings.rb deleted file mode 100644 index cfb89743127..00000000000 --- a/db/migrate/20170807071105_add_hashed_storage_to_settings.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddHashedStorageToSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :application_settings, :hashed_storage_enabled, :boolean, default: false - end - - def down - remove_columns :application_settings, :hashed_storage_enabled - end -end diff --git a/db/migrate/20170809133343_add_broadcast_messages_index.rb b/db/migrate/20170809133343_add_broadcast_messages_index.rb deleted file mode 100644 index bcbc6c9f7d2..00000000000 --- a/db/migrate/20170809133343_add_broadcast_messages_index.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddBroadcastMessagesIndex < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - COLUMNS = %i[starts_at ends_at id].freeze - - def up - add_concurrent_index :broadcast_messages, COLUMNS - end - - def down - remove_concurrent_index :broadcast_messages, COLUMNS - end -end diff --git a/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb b/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb deleted file mode 100644 index fd8cdbb95aa..00000000000 --- a/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddBroadcastMessageNotNullConstraints < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - COLUMNS = %i[starts_at ends_at created_at updated_at message_html] - - class BroadcastMessage < ActiveRecord::Base - self.table_name = 'broadcast_messages' - end - - def up - COLUMNS.each do |column| - BroadcastMessage.where(column => nil).delete_all - - change_column_null :broadcast_messages, column, false - end - end - - def down - COLUMNS.each do |column| - change_column_null :broadcast_messages, column, true - end - end -end diff --git a/db/migrate/20170809142252_cleanup_appearances_schema.rb b/db/migrate/20170809142252_cleanup_appearances_schema.rb deleted file mode 100644 index 4c5d6a6d75d..00000000000 --- a/db/migrate/20170809142252_cleanup_appearances_schema.rb +++ /dev/null @@ -1,33 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CleanupAppearancesSchema < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - NOT_NULL_COLUMNS = %i[title description created_at updated_at] - - TIME_COLUMNS = %i[created_at updated_at] - - def up - NOT_NULL_COLUMNS.each do |column| - change_column_null :appearances, column, false - end - - TIME_COLUMNS.each do |column| - change_column :appearances, column, :datetime_with_timezone - end - end - - def down - NOT_NULL_COLUMNS.each do |column| - change_column_null :appearances, column, true - end - - TIME_COLUMNS.each do |column| - change_column :appearances, column, :datetime # rubocop: disable Migration/Datetime - end - end -end diff --git a/db/migrate/20170809161910_add_project_export_enabled_to_application_settings.rb b/db/migrate/20170809161910_add_project_export_enabled_to_application_settings.rb deleted file mode 100644 index 9dd520de264..00000000000 --- a/db/migrate/20170809161910_add_project_export_enabled_to_application_settings.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddProjectExportEnabledToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_column_with_default(:application_settings, :project_export_enabled, :boolean, default: true) - end - - def down - remove_column(:application_settings, :project_export_enabled) - end -end diff --git a/db/migrate/20170815221154_add_discussion_locked_to_issuable.rb b/db/migrate/20170815221154_add_discussion_locked_to_issuable.rb deleted file mode 100644 index 1444ca480b3..00000000000 --- a/db/migrate/20170815221154_add_discussion_locked_to_issuable.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddDiscussionLockedToIssuable < ActiveRecord::Migration[4.2] - 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/migrate/20170816133938_add_access_level_to_ci_runners.rb b/db/migrate/20170816133938_add_access_level_to_ci_runners.rb deleted file mode 100644 index 5a1ea9514d1..00000000000 --- a/db/migrate/20170816133938_add_access_level_to_ci_runners.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddAccessLevelToCiRunners < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:ci_runners, :access_level, :integer, - default: Ci::Runner.access_levels['not_protected']) - end - - def down - remove_column(:ci_runners, :access_level) - end -end diff --git a/db/migrate/20170816133940_add_protected_to_ci_builds.rb b/db/migrate/20170816133940_add_protected_to_ci_builds.rb deleted file mode 100644 index 13e1be0d89c..00000000000 --- a/db/migrate/20170816133940_add_protected_to_ci_builds.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddProtectedToCiBuilds < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column :ci_builds, :protected, :boolean - end -end diff --git a/db/migrate/20170816143940_add_protected_to_ci_pipelines.rb b/db/migrate/20170816143940_add_protected_to_ci_pipelines.rb deleted file mode 100644 index aefaf4a487b..00000000000 --- a/db/migrate/20170816143940_add_protected_to_ci_pipelines.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddProtectedToCiPipelines < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column :ci_pipelines, :protected, :boolean - end -end diff --git a/db/migrate/20170816153940_add_index_on_ci_builds_protected.rb b/db/migrate/20170816153940_add_index_on_ci_builds_protected.rb deleted file mode 100644 index fbe5fe31ae8..00000000000 --- a/db/migrate/20170816153940_add_index_on_ci_builds_protected.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddIndexOnCiBuildsProtected < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_builds, :protected - end - - def down - remove_concurrent_index :ci_builds, :protected if index_exists?(:ci_builds, :protected) - end -end diff --git a/db/migrate/20170816234252_add_theme_id_to_users.rb b/db/migrate/20170816234252_add_theme_id_to_users.rb deleted file mode 100644 index bd04445cac6..00000000000 --- a/db/migrate/20170816234252_add_theme_id_to_users.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 AddThemeIdToUsers < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column :users, :theme_id, :integer, limit: 2 - end -end diff --git a/db/migrate/20170817123339_add_verification_status_to_gpg_signatures.rb b/db/migrate/20170817123339_add_verification_status_to_gpg_signatures.rb deleted file mode 100644 index c7d81dc005a..00000000000 --- a/db/migrate/20170817123339_add_verification_status_to_gpg_signatures.rb +++ /dev/null @@ -1,20 +0,0 @@ -class AddVerificationStatusToGpgSignatures < ActiveRecord::Migration[4.2] - DOWNTIME = false - - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - # First we remove all signatures because we need to re-verify them all - # again anyway (because of the updated verification logic). - # - # This makes adding the column with default values faster - truncate(:gpg_signatures) - - add_column_with_default(:gpg_signatures, :verification_status, :smallint, default: 0) - end - - def down - remove_column(:gpg_signatures, :verification_status) - end -end diff --git a/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb b/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb deleted file mode 100644 index 82e05885b0e..00000000000 --- a/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb +++ /dev/null @@ -1,35 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CorrectProtectedTagsForeignKeys < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - remove_foreign_key_without_error(:protected_tag_create_access_levels, - column: :protected_tag_id) - - execute <<-EOF - DELETE FROM protected_tag_create_access_levels - WHERE NOT EXISTS ( - SELECT true - FROM protected_tags - WHERE protected_tag_create_access_levels.protected_tag_id = protected_tags.id - ) - AND protected_tag_id IS NOT NULL - EOF - - add_concurrent_foreign_key(:protected_tag_create_access_levels, - :protected_tags, - column: :protected_tag_id) - end - - def down - # Previously there was a foreign key without a CASCADING DELETE, so we'll - # just leave the foreign key in place. - end -end diff --git a/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb b/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb deleted file mode 100644 index 131dcf7ac25..00000000000 --- a/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateUserSyncedAttributesMetadata < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :user_synced_attributes_metadata do |t| - t.boolean :name_synced, default: false - t.boolean :email_synced, default: false - t.boolean :location_synced, default: false - t.references :user, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } - t.string :provider - end - end -end diff --git a/db/migrate/20170824101926_add_auto_devops_enabled_to_application_settings.rb b/db/migrate/20170824101926_add_auto_devops_enabled_to_application_settings.rb deleted file mode 100644 index f7c0aeab8f9..00000000000 --- a/db/migrate/20170824101926_add_auto_devops_enabled_to_application_settings.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddAutoDevopsEnabledToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:application_settings, :auto_devops_enabled, :boolean, default: false) - end - - def down - remove_column(:application_settings, :auto_devops_enabled, :boolean) - end -end diff --git a/db/migrate/20170824162758_allow_appearances_description_html_null.rb b/db/migrate/20170824162758_allow_appearances_description_html_null.rb deleted file mode 100644 index 6efa3452796..00000000000 --- a/db/migrate/20170824162758_allow_appearances_description_html_null.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AllowAppearancesDescriptionHtmlNull < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def up - change_column_null :appearances, :description_html, true - end - - def down - # This column should not have a `NOT NULL` class, so we don't want to revert - # back to re-adding it. - end -end diff --git a/db/migrate/20170825015534_add_file_store_to_lfs_objects.rb b/db/migrate/20170825015534_add_file_store_to_lfs_objects.rb deleted file mode 100644 index be543ffc983..00000000000 --- a/db/migrate/20170825015534_add_file_store_to_lfs_objects.rb +++ /dev/null @@ -1,31 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddFileStoreToLfsObjects < ActiveRecord::Migration[4.2] - 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(:lfs_objects, :file_store, :integer) - end -end diff --git a/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb b/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb deleted file mode 100644 index b1adccc9c5c..00000000000 --- a/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb +++ /dev/null @@ -1,37 +0,0 @@ -class MigrateIssuesToGhostUser < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - disable_ddl_transaction! - - class User < ActiveRecord::Base - self.table_name = 'users' - end - - class Issue < ActiveRecord::Base - self.table_name = 'issues' - - include ::EachBatch - end - - def reset_column_in_migration_models - ActiveRecord::Base.clear_cache! - - ::User.reset_column_information - ::Namespace.reset_column_information - end - - def up - reset_column_in_migration_models - - # we use the model method because rewriting it is too complicated and would require copying multiple methods - ghost_id = ::User.ghost.id - - Issue.where('NOT EXISTS (?)', User.unscoped.select(1).where('issues.author_id = users.id')).each_batch do |relation| - relation.update_all(author_id: ghost_id) - end - end - - def down - end -end diff --git a/db/migrate/20170825154015_resolve_outdated_diff_discussions.rb b/db/migrate/20170825154015_resolve_outdated_diff_discussions.rb deleted file mode 100644 index 1aed21f10a0..00000000000 --- a/db/migrate/20170825154015_resolve_outdated_diff_discussions.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ResolveOutdatedDiffDiscussions < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column(:projects, :resolve_outdated_diff_discussions, :boolean) - end -end diff --git a/db/migrate/20170827123848_add_index_on_merge_request_diff_commit_sha.rb b/db/migrate/20170827123848_add_index_on_merge_request_diff_commit_sha.rb deleted file mode 100644 index e2061b5600a..00000000000 --- a/db/migrate/20170827123848_add_index_on_merge_request_diff_commit_sha.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable RemoveIndex - -class AddIndexOnMergeRequestDiffCommitSha < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :merge_request_diff_commits, :sha, length: mysql_compatible_index_length - end - - def down - remove_index :merge_request_diff_commits, :sha if index_exists? :merge_request_diff_commits, :sha - end -end diff --git a/db/migrate/20170828093725_create_project_auto_dev_ops.rb b/db/migrate/20170828093725_create_project_auto_dev_ops.rb deleted file mode 100644 index ea895dc14c1..00000000000 --- a/db/migrate/20170828093725_create_project_auto_dev_ops.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateProjectAutoDevOps < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - create_table :project_auto_devops do |t| - t.belongs_to :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false - t.boolean :enabled, default: nil, null: true - t.string :domain - end - end - - def down - drop_table(:project_auto_devops) - end -end diff --git a/db/migrate/20170828135939_migrate_user_external_mail_data.rb b/db/migrate/20170828135939_migrate_user_external_mail_data.rb deleted file mode 100644 index 9ee4a4598bf..00000000000 --- a/db/migrate/20170828135939_migrate_user_external_mail_data.rb +++ /dev/null @@ -1,57 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MigrateUserExternalMailData < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class User < ActiveRecord::Base - self.table_name = 'users' - - include EachBatch - end - - class UserSyncedAttributesMetadata < ActiveRecord::Base - self.table_name = 'user_synced_attributes_metadata' - - include EachBatch - end - - def up - User.each_batch do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first - - execute <<-EOF - INSERT INTO user_synced_attributes_metadata (user_id, provider, email_synced) - SELECT id, email_provider, external_email - FROM users - WHERE external_email = TRUE - AND NOT EXISTS ( - SELECT true - FROM user_synced_attributes_metadata - WHERE user_id = users.id - AND (provider = users.email_provider OR (provider IS NULL AND users.email_provider IS NULL)) - ) - AND id BETWEEN #{start_id} AND #{end_id} - EOF - end - end - - def down - UserSyncedAttributesMetadata.each_batch do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first - - execute <<-EOF - UPDATE users - SET users.email_provider = metadata.provider, users.external_email = metadata.email_synced - FROM user_synced_attributes_metadata as metadata, users - WHERE metadata.email_synced = TRUE - AND metadata.user_id = users.id - AND id BETWEEN #{start_id} AND #{end_id} - EOF - end - end -end diff --git a/db/migrate/20170830125940_add_failure_reason_to_ci_builds.rb b/db/migrate/20170830125940_add_failure_reason_to_ci_builds.rb deleted file mode 100644 index 44f709868ca..00000000000 --- a/db/migrate/20170830125940_add_failure_reason_to_ci_builds.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddFailureReasonToCiBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_builds, :failure_reason, :integer - end -end diff --git a/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb b/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb deleted file mode 100644 index bcc34d56d2d..00000000000 --- a/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class StealRemainingEventMigrationJobs < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - Gitlab::BackgroundMigration.steal('MigrateEventsToPushEventPayloads') - end - - def down - end -end diff --git a/db/migrate/20170830131015_swap_event_migration_tables.rb b/db/migrate/20170830131015_swap_event_migration_tables.rb deleted file mode 100644 index fb3b2472ffe..00000000000 --- a/db/migrate/20170830131015_swap_event_migration_tables.rb +++ /dev/null @@ -1,47 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class SwapEventMigrationTables < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - class Event < ActiveRecord::Base - self.table_name = 'events' - end - - def up - rename_tables - end - - def down - rename_tables - end - - def rename_tables - rename_table :events, :events_old - rename_table :events_for_migration, :events - rename_table :events_old, :events_for_migration - - # Once swapped we need to reset the primary key of the new "events" table to - # make sure that data created starts with the right value. This isn't - # necessary for events_for_migration since we replicate existing primary key - # values to it. - if Gitlab::Database.postgresql? - reset_primary_key_for_postgresql - else - reset_primary_key_for_mysql - end - end - - def reset_primary_key_for_postgresql - reset_pk_sequence!(Event.table_name) - end - - def reset_primary_key_for_mysql - amount = Event.pluck('COALESCE(MAX(id), 1)').first - - execute "ALTER TABLE #{Event.table_name} AUTO_INCREMENT = #{amount}" - end -end diff --git a/db/migrate/20170831092813_add_config_source_to_pipelines.rb b/db/migrate/20170831092813_add_config_source_to_pipelines.rb deleted file mode 100644 index ba1f73f0e68..00000000000 --- a/db/migrate/20170831092813_add_config_source_to_pipelines.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddConfigSourceToPipelines < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column(:ci_pipelines, :config_source, :integer, allow_null: true) - end -end diff --git a/db/migrate/20170901071411_add_foreign_key_to_issue_author.rb b/db/migrate/20170901071411_add_foreign_key_to_issue_author.rb deleted file mode 100644 index 00d0b0f2c7f..00000000000 --- a/db/migrate/20170901071411_add_foreign_key_to_issue_author.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddForeignKeyToIssueAuthor < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - disable_ddl_transaction! - - def up - add_concurrent_foreign_key(:issues, :users, column: :author_id, on_delete: :nullify) - end - - def down - remove_foreign_key(:issues, column: :author_id) - end -end diff --git a/db/migrate/20170904092148_add_email_confirmation.rb b/db/migrate/20170904092148_add_email_confirmation.rb deleted file mode 100644 index 8bfb2005936..00000000000 --- a/db/migrate/20170904092148_add_email_confirmation.rb +++ /dev/null @@ -1,33 +0,0 @@ -# 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[4.2] - 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_with_timezone - add_column :emails, :confirmation_sent_at, :datetime_with_timezone - end -end diff --git a/db/migrate/20170905112933_add_resolved_by_push_to_notes.rb b/db/migrate/20170905112933_add_resolved_by_push_to_notes.rb deleted file mode 100644 index 1f27ea3c467..00000000000 --- a/db/migrate/20170905112933_add_resolved_by_push_to_notes.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddResolvedByPushToNotes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :notes, :resolved_by_push, :boolean - end -end diff --git a/db/migrate/20170906133745_add_runners_token_to_groups.rb b/db/migrate/20170906133745_add_runners_token_to_groups.rb deleted file mode 100644 index a02160feb83..00000000000 --- a/db/migrate/20170906133745_add_runners_token_to_groups.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddRunnersTokenToGroups < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :namespaces, :runners_token, :string - end -end diff --git a/db/migrate/20170909090114_add_email_confirmation_index.rb b/db/migrate/20170909090114_add_email_confirmation_index.rb deleted file mode 100644 index 31c48db2bd2..00000000000 --- a/db/migrate/20170909090114_add_email_confirmation_index.rb +++ /dev/null @@ -1,36 +0,0 @@ -# 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[4.2] - 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_concurrent_index :emails, :confirmation_token if index_exists?(:emails, :confirmation_token) - end -end diff --git a/db/migrate/20170909150936_add_spent_at_to_timelogs.rb b/db/migrate/20170909150936_add_spent_at_to_timelogs.rb deleted file mode 100644 index 3a2c900b445..00000000000 --- a/db/migrate/20170909150936_add_spent_at_to_timelogs.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddSpentAtToTimelogs < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - add_column :timelogs, :spent_at, :datetime_with_timezone - end - - def down - remove_column :timelogs, :spent_at - end -end diff --git a/db/migrate/20170912113435_clean_stages_statuses_migration.rb b/db/migrate/20170912113435_clean_stages_statuses_migration.rb deleted file mode 100644 index f2040f819cd..00000000000 --- a/db/migrate/20170912113435_clean_stages_statuses_migration.rb +++ /dev/null @@ -1,26 +0,0 @@ -class CleanStagesStatusesMigration < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class Stage < ActiveRecord::Base - include ::EachBatch - self.table_name = 'ci_stages' - end - - def up - Gitlab::BackgroundMigration.steal('MigrateStageStatus') - - Stage.where('status IS NULL').each_batch(of: 50) do |batch| - range = batch.pluck('MIN(id)', 'MAX(id)').first - - Gitlab::BackgroundMigration::MigrateStageStatus.new.perform(*range) - end - end - - def down - # noop - end -end diff --git a/db/migrate/20170913131410_environments_project_id_not_null.rb b/db/migrate/20170913131410_environments_project_id_not_null.rb deleted file mode 100644 index ba66113945b..00000000000 --- a/db/migrate/20170913131410_environments_project_id_not_null.rb +++ /dev/null @@ -1,16 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class EnvironmentsProjectIdNotNull < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - change_column_null :environments, :project_id, false - end - - def down - change_column_null :environments, :project_id, true - end -end diff --git a/db/migrate/20170914135630_add_index_for_recent_push_events.rb b/db/migrate/20170914135630_add_index_for_recent_push_events.rb deleted file mode 100644 index ac86185ba50..00000000000 --- a/db/migrate/20170914135630_add_index_for_recent_push_events.rb +++ /dev/null @@ -1,40 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddIndexForRecentPushEvents < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index_if_not_present( - :merge_requests, - [:source_project_id, :source_branch] - ) - - remove_concurrent_index_if_present(:merge_requests, :source_project_id) - end - - def down - add_concurrent_index_if_not_present(:merge_requests, :source_project_id) - - remove_concurrent_index_if_present( - :merge_requests, - [:source_project_id, :source_branch] - ) - end - - def add_concurrent_index_if_not_present(table, columns) - return if index_exists?(table, columns) - - add_concurrent_index(table, columns) - end - - def remove_concurrent_index_if_present(table, columns) - return unless index_exists?(table, columns) - - remove_concurrent_index(table, columns) - end -end diff --git a/db/migrate/20170918072948_create_job_artifacts.rb b/db/migrate/20170918072948_create_job_artifacts.rb deleted file mode 100644 index 4dd24aaff99..00000000000 --- a/db/migrate/20170918072948_create_job_artifacts.rb +++ /dev/null @@ -1,23 +0,0 @@ -class CreateJobArtifacts < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :ci_job_artifacts do |t| - t.belongs_to :project, null: false, index: true, foreign_key: { on_delete: :cascade } - t.integer :job_id, null: false - t.integer :file_type, null: false - t.integer :size, limit: 8 - - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false - t.datetime_with_timezone :expire_at - - t.string :file - - t.foreign_key :ci_builds, column: :job_id, on_delete: :cascade - t.index [:job_id, :file_type], unique: true - end - end -end diff --git a/db/migrate/20170918072949_add_file_store_job_artifacts.rb b/db/migrate/20170918072949_add_file_store_job_artifacts.rb deleted file mode 100644 index 3eb355c9305..00000000000 --- a/db/migrate/20170918072949_add_file_store_job_artifacts.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddFileStoreJobArtifacts < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - DOWNTIME = false - - def change - add_column(:ci_job_artifacts, :file_store, :integer) - end -end diff --git a/db/migrate/20170918111708_create_project_custom_attributes.rb b/db/migrate/20170918111708_create_project_custom_attributes.rb deleted file mode 100644 index bd6064689ff..00000000000 --- a/db/migrate/20170918111708_create_project_custom_attributes.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateProjectCustomAttributes < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :project_custom_attributes do |t| - t.timestamps_with_timezone null: false - t.references :project, null: false, foreign_key: { on_delete: :cascade } - t.string :key, null: false - t.string :value, null: false - - t.index [:project_id, :key], unique: true - t.index [:key, :value] - end - end -end diff --git a/db/migrate/20170918140927_create_group_custom_attributes.rb b/db/migrate/20170918140927_create_group_custom_attributes.rb deleted file mode 100644 index 215a0f16b6f..00000000000 --- a/db/migrate/20170918140927_create_group_custom_attributes.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateGroupCustomAttributes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :group_custom_attributes do |t| - t.timestamps_with_timezone null: false - t.references :group, null: false - t.string :key, null: false - t.string :value, null: false - - t.index [:group_id, :key], unique: true - t.index [:key, :value] - end - - add_foreign_key :group_custom_attributes, :namespaces, column: :group_id, on_delete: :cascade # rubocop: disable Migration/AddConcurrentForeignKey - end -end diff --git a/db/migrate/20170918222253_reorganize_deployments_indexes.rb b/db/migrate/20170918222253_reorganize_deployments_indexes.rb deleted file mode 100644 index 480847ac393..00000000000 --- a/db/migrate/20170918222253_reorganize_deployments_indexes.rb +++ /dev/null @@ -1,28 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class ReorganizeDeploymentsIndexes < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_index_if_not_exists :deployments, [:environment_id, :iid, :project_id] - remove_index_if_exists :deployments, [:project_id, :environment_id, :iid] - end - - def down - add_index_if_not_exists :deployments, [:project_id, :environment_id, :iid] - remove_index_if_exists :deployments, [:environment_id, :iid, :project_id] - end - - def add_index_if_not_exists(table, columns) - add_concurrent_index(table, columns) unless index_exists?(table, columns) - end - - def remove_index_if_exists(table, columns) - remove_concurrent_index(table, columns) if index_exists?(table, columns) - end -end diff --git a/db/migrate/20170918223303_add_deployments_index_for_last_deployment.rb b/db/migrate/20170918223303_add_deployments_index_for_last_deployment.rb deleted file mode 100644 index 8e165ac647d..00000000000 --- a/db/migrate/20170918223303_add_deployments_index_for_last_deployment.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddDeploymentsIndexForLastDeployment < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - TO_INDEX = [:deployments, %i[environment_id id]].freeze - - def up - add_concurrent_index(*TO_INDEX) - end - - def down - remove_concurrent_index(*TO_INDEX) - end -end diff --git a/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb b/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb deleted file mode 100644 index 23c94a809d4..00000000000 --- a/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb +++ /dev/null @@ -1,28 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveTemporaryCiBuildsIndex < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - # To use create/remove index concurrently - disable_ddl_transaction! - - def up - return unless index_exists?(:ci_builds, :id, name: 'index_for_ci_builds_retried_migration') - - remove_concurrent_index(:ci_builds, :id, name: "index_for_ci_builds_retried_migration") - end - - def down - # this was a temporary index for a migration that was never - # present previously so this probably shouldn't be here but it's - # easier to test the drop if we have a way to create it. - add_concurrent_index("ci_builds", ["id"], - name: "index_for_ci_builds_retried_migration", - where: "(retried IS NULL)", - using: :btree) - end -end diff --git a/db/migrate/20170921115009_add_project_repository_storage_index.rb b/db/migrate/20170921115009_add_project_repository_storage_index.rb deleted file mode 100644 index 9e1f5052f28..00000000000 --- a/db/migrate/20170921115009_add_project_repository_storage_index.rb +++ /dev/null @@ -1,19 +0,0 @@ -class AddProjectRepositoryStorageIndex < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index(*index_spec) unless index_exists?(*index_spec) - end - - def down - remove_concurrent_index(*index_spec) if index_exists?(*index_spec) - end - - def index_spec - [:projects, :repository_storage] - end -end diff --git a/db/migrate/20170924094327_create_gcp_clusters.rb b/db/migrate/20170924094327_create_gcp_clusters.rb deleted file mode 100644 index 43201f75ad7..00000000000 --- a/db/migrate/20170924094327_create_gcp_clusters.rb +++ /dev/null @@ -1,45 +0,0 @@ -class CreateGcpClusters < ActiveRecord::Migration[4.2] - DOWNTIME = false - - 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 - - # Timestamps - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false - - # Enable/disable - t.boolean :enabled, default: true - - # General - t.text :status_reason - - # k8s integration specific - t.string :project_namespace - - # Cluster details - t.string :endpoint - t.text :ca_cert - t.text :encrypted_kubernetes_token - t.string :encrypted_kubernetes_token_iv - t.string :username - t.text :encrypted_password - t.string :encrypted_password_iv - - # GKE - t.string :gcp_project_id, null: false - t.string :gcp_cluster_zone, null: false - t.string :gcp_cluster_name, null: false - t.string :gcp_machine_type - t.string :gcp_operation_id - t.text :encrypted_gcp_token - t.string :encrypted_gcp_token_iv - end - end -end diff --git a/db/migrate/20170925184228_add_favicon_to_appearances.rb b/db/migrate/20170925184228_add_favicon_to_appearances.rb deleted file mode 100644 index 1ce750f7e83..00000000000 --- a/db/migrate/20170925184228_add_favicon_to_appearances.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddFaviconToAppearances < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - add_column :appearances, :favicon, :string - end -end diff --git a/db/migrate/20170927095921_add_ci_builds_index_for_jobscontroller.rb b/db/migrate/20170927095921_add_ci_builds_index_for_jobscontroller.rb deleted file mode 100644 index 3ee9c959fca..00000000000 --- a/db/migrate/20170927095921_add_ci_builds_index_for_jobscontroller.rb +++ /dev/null @@ -1,39 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddCiBuildsIndexForJobscontroller < ActiveRecord::Migration[4.2] - 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! - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_builds, [:project_id, :id] unless index_exists? :ci_builds, [:project_id, :id] - remove_concurrent_index :ci_builds, :project_id if index_exists? :ci_builds, :project_id - end - - def down - add_concurrent_index :ci_builds, :project_id unless index_exists? :ci_builds, :project_id - remove_concurrent_index :ci_builds, [:project_id, :id] if index_exists? :ci_builds, [:project_id, :id] - end -end diff --git a/db/migrate/20170927122209_add_partial_index_for_labels_template.rb b/db/migrate/20170927122209_add_partial_index_for_labels_template.rb deleted file mode 100644 index dd79e024df4..00000000000 --- a/db/migrate/20170927122209_add_partial_index_for_labels_template.rb +++ /dev/null @@ -1,45 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddPartialIndexForLabelsTemplate < ActiveRecord::Migration[4.2] - 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! - - # Note this is a partial index in Postgres but MySQL will ignore the - # partial index clause. By making it an index on "template" this - # means the index will still accomplish the same goal of optimizing - # a query with "where template = true" on MySQL -- it'll just take - # more space. In this case the number of records with template=true - # is expected to be very small (small enough to display on a single - # web page) so it's ok to filter or sort them without the index - # anyways. - - def up - add_concurrent_index "labels", ["template"], where: "template" - end - - def down - remove_concurrent_index "labels", ["template"], where: "template" - end -end diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb deleted file mode 100644 index 3b5d452ee12..00000000000 --- a/db/migrate/20170927161718_create_gpg_key_subkeys.rb +++ /dev/null @@ -1,25 +0,0 @@ -class CreateGpgKeySubkeys < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - 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.index :keyid, unique: true, length: mysql_compatible_index_length - t.index :fingerprint, unique: true, length: mysql_compatible_index_length - 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/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb b/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb deleted file mode 100644 index cb16589e8db..00000000000 --- a/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb +++ /dev/null @@ -1,33 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddCompositeIndexOnMergeRequestsMergeCommitSha < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - # The default index name is too long for PostgreSQL and would thus be - # truncated. - INDEX_NAME = 'index_merge_requests_on_tp_id_and_merge_commit_sha_and_id' - - COLUMNS = [:target_project_id, :merge_commit_sha, :id] - - disable_ddl_transaction! - - def up - return if index_is_present? - - add_concurrent_index(:merge_requests, COLUMNS, name: INDEX_NAME) - end - - def down - return unless index_is_present? - - remove_concurrent_index(:merge_requests, COLUMNS, name: INDEX_NAME) - end - - def index_is_present? - index_exists?(:merge_requests, COLUMNS, name: INDEX_NAME) - end -end diff --git a/db/migrate/20170928124105_create_fork_networks.rb b/db/migrate/20170928124105_create_fork_networks.rb deleted file mode 100644 index 01f623117f5..00000000000 --- a/db/migrate/20170928124105_create_fork_networks.rb +++ /dev/null @@ -1,29 +0,0 @@ -class CreateForkNetworks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - create_table :fork_networks do |t| - t.references :root_project, - references: :projects, - index: { unique: true } - - t.string :deleted_root_project_name - end - - add_concurrent_foreign_key :fork_networks, :projects, - column: :root_project_id, - on_delete: :nullify - end - - def down - if foreign_keys_for(:fork_networks, :root_project_id).any? - remove_foreign_key :fork_networks, column: :root_project_id - end - - drop_table :fork_networks - end -end diff --git a/db/migrate/20170928133643_create_fork_network_members.rb b/db/migrate/20170928133643_create_fork_network_members.rb deleted file mode 100644 index e2a6d7b0e8a..00000000000 --- a/db/migrate/20170928133643_create_fork_network_members.rb +++ /dev/null @@ -1,27 +0,0 @@ -class CreateForkNetworkMembers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - create_table :fork_network_members do |t| - t.references :fork_network, null: false, index: true, foreign_key: { on_delete: :cascade } - t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } - t.references :forked_from_project, references: :projects - end - - add_concurrent_foreign_key :fork_network_members, :projects, - column: :forked_from_project_id, - on_delete: :nullify - end - - def down - if foreign_keys_for(:fork_network_members, :forked_from_project_id).any? - remove_foreign_key :fork_network_members, column: :forked_from_project_id - end - - drop_table :fork_network_members - end -end diff --git a/db/migrate/20170929080234_add_failure_reason_to_pipelines.rb b/db/migrate/20170929080234_add_failure_reason_to_pipelines.rb deleted file mode 100644 index e000ee27eef..00000000000 --- a/db/migrate/20170929080234_add_failure_reason_to_pipelines.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddFailureReasonToPipelines < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_pipelines, :failure_reason, :integer - end -end diff --git a/db/migrate/20170929131201_populate_fork_networks.rb b/db/migrate/20170929131201_populate_fork_networks.rb deleted file mode 100644 index ba4f8ef2531..00000000000 --- a/db/migrate/20170929131201_populate_fork_networks.rb +++ /dev/null @@ -1,16 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class PopulateForkNetworks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - say 'Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller' - end - - def down - # nothing - end -end diff --git a/db/migrate/20171004121444_make_sure_fast_forward_option_exists.rb b/db/migrate/20171004121444_make_sure_fast_forward_option_exists.rb deleted file mode 100644 index 9b417de1793..00000000000 --- a/db/migrate/20171004121444_make_sure_fast_forward_option_exists.rb +++ /dev/null @@ -1,25 +0,0 @@ -# rubocop:disable all -class MakeSureFastForwardOptionExists < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - # We had to fix the migration db/migrate/20150827121444_add_fast_forward_option_to_project.rb - # And this is why it's possible that someone has ran the migrations but does - # not have the merge_requests_ff_only_enabled column. This migration makes sure it will - # be added - unless column_exists?(:projects, :merge_requests_ff_only_enabled) - add_column_with_default(:projects, :merge_requests_ff_only_enabled, :boolean, default: false) - end - end - - def down - if column_exists?(:projects, :merge_requests_ff_only_enabled) - remove_column(:projects, :merge_requests_ff_only_enabled) - end - end -end diff --git a/db/migrate/20171006090001_create_ci_build_trace_sections.rb b/db/migrate/20171006090001_create_ci_build_trace_sections.rb deleted file mode 100644 index a2eca0832f2..00000000000 --- a/db/migrate/20171006090001_create_ci_build_trace_sections.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateCiBuildTraceSections < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :ci_build_trace_sections do |t| - t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade } - t.datetime_with_timezone :date_start, null: false - t.datetime_with_timezone :date_end, null: false - t.integer :byte_start, limit: 8, null: false - t.integer :byte_end, limit: 8, null: false - t.integer :build_id, null: false - t.integer :section_name_id, null: false - end - - add_index :ci_build_trace_sections, [:build_id, :section_name_id], unique: true - end -end diff --git a/db/migrate/20171006090010_add_build_foreign_key_to_ci_build_trace_sections.rb b/db/migrate/20171006090010_add_build_foreign_key_to_ci_build_trace_sections.rb deleted file mode 100644 index 7b17763ac84..00000000000 --- a/db/migrate/20171006090010_add_build_foreign_key_to_ci_build_trace_sections.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddBuildForeignKeyToCiBuildTraceSections < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key(:ci_build_trace_sections, :ci_builds, column: :build_id) - end - - def down - remove_foreign_key(:ci_build_trace_sections, column: :build_id) - end -end diff --git a/db/migrate/20171006090100_create_ci_build_trace_section_names.rb b/db/migrate/20171006090100_create_ci_build_trace_section_names.rb deleted file mode 100644 index 00a38fa59c2..00000000000 --- a/db/migrate/20171006090100_create_ci_build_trace_section_names.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateCiBuildTraceSectionNames < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - create_table :ci_build_trace_section_names do |t| - t.references :project, null: false, foreign_key: { on_delete: :cascade } - t.string :name, null: false - end - - add_index :ci_build_trace_section_names, [:project_id, :name], unique: true - end - - def down - remove_foreign_key :ci_build_trace_section_names, column: :project_id - drop_table :ci_build_trace_section_names - end -end diff --git a/db/migrate/20171006091000_add_name_foreign_key_to_ci_build_trace_sections.rb b/db/migrate/20171006091000_add_name_foreign_key_to_ci_build_trace_sections.rb deleted file mode 100644 index 1342ff013b7..00000000000 --- a/db/migrate/20171006091000_add_name_foreign_key_to_ci_build_trace_sections.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddNameForeignKeyToCiBuildTraceSections < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key(:ci_build_trace_sections, :ci_build_trace_section_names, column: :section_name_id) - end - - def down - remove_foreign_key(:ci_build_trace_sections, column: :section_name_id) - end -end diff --git a/db/migrate/20171006220837_add_global_rate_limits_to_application_settings.rb b/db/migrate/20171006220837_add_global_rate_limits_to_application_settings.rb deleted file mode 100644 index 96d76069b35..00000000000 --- a/db/migrate/20171006220837_add_global_rate_limits_to_application_settings.rb +++ /dev/null @@ -1,38 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddGlobalRateLimitsToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :application_settings, :throttle_unauthenticated_enabled, :boolean, default: false, allow_null: false - add_column_with_default :application_settings, :throttle_unauthenticated_requests_per_period, :integer, default: 3600, allow_null: false - add_column_with_default :application_settings, :throttle_unauthenticated_period_in_seconds, :integer, default: 3600, allow_null: false - - add_column_with_default :application_settings, :throttle_authenticated_api_enabled, :boolean, default: false, allow_null: false - add_column_with_default :application_settings, :throttle_authenticated_api_requests_per_period, :integer, default: 7200, allow_null: false - add_column_with_default :application_settings, :throttle_authenticated_api_period_in_seconds, :integer, default: 3600, allow_null: false - - add_column_with_default :application_settings, :throttle_authenticated_web_enabled, :boolean, default: false, allow_null: false - add_column_with_default :application_settings, :throttle_authenticated_web_requests_per_period, :integer, default: 7200, allow_null: false - add_column_with_default :application_settings, :throttle_authenticated_web_period_in_seconds, :integer, default: 3600, allow_null: false - end - - def down - remove_column :application_settings, :throttle_authenticated_web_period_in_seconds - remove_column :application_settings, :throttle_authenticated_web_requests_per_period - remove_column :application_settings, :throttle_authenticated_web_enabled - - remove_column :application_settings, :throttle_authenticated_api_period_in_seconds - remove_column :application_settings, :throttle_authenticated_api_requests_per_period - remove_column :application_settings, :throttle_authenticated_api_enabled - - remove_column :application_settings, :throttle_unauthenticated_period_in_seconds - remove_column :application_settings, :throttle_unauthenticated_requests_per_period - remove_column :application_settings, :throttle_unauthenticated_enabled - end -end diff --git a/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb b/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb deleted file mode 100644 index 91bba07b4d7..00000000000 --- a/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb +++ /dev/null @@ -1,27 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddCircuitBreakerPropertiesToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, - :circuitbreaker_failure_count_threshold, - :integer, - default: 160 - add_column :application_settings, - :circuitbreaker_failure_wait_time, - :integer, - default: 30 - add_column :application_settings, - :circuitbreaker_failure_reset_time, - :integer, - default: 1800 - add_column :application_settings, - :circuitbreaker_storage_timeout, - :integer, - default: 30 - end -end diff --git a/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb b/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb deleted file mode 100644 index 305c12e31f8..00000000000 --- a/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb +++ /dev/null @@ -1,78 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MigrateUserAuthenticationTokenToPersonalAccessToken < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - # disable_ddl_transaction! - - TOKEN_NAME = 'Private Token'.freeze - - def up - execute <<~SQL - INSERT INTO personal_access_tokens (user_id, token, name, created_at, updated_at, scopes) - SELECT id, authentication_token, '#{TOKEN_NAME}', NOW(), NOW(), '#{%w[api].to_yaml}' - FROM users - WHERE authentication_token IS NOT NULL - AND admin = FALSE - AND NOT EXISTS ( - SELECT true - FROM personal_access_tokens - WHERE user_id = users.id - AND token = users.authentication_token - ) - SQL - - # Admins also need the `sudo` scope - execute <<~SQL - INSERT INTO personal_access_tokens (user_id, token, name, created_at, updated_at, scopes) - SELECT id, authentication_token, '#{TOKEN_NAME}', NOW(), NOW(), '#{%w[api sudo].to_yaml}' - FROM users - WHERE authentication_token IS NOT NULL - AND admin = TRUE - AND NOT EXISTS ( - SELECT true - FROM personal_access_tokens - WHERE user_id = users.id - AND token = users.authentication_token - ) - SQL - end - - def down - if Gitlab::Database.postgresql? - execute <<~SQL - UPDATE users - SET authentication_token = pats.token - FROM ( - SELECT user_id, token - FROM personal_access_tokens - WHERE name = '#{TOKEN_NAME}' - ) AS pats - WHERE id = pats.user_id - SQL - else - execute <<~SQL - UPDATE users - INNER JOIN personal_access_tokens AS pats - ON users.id = pats.user_id - SET authentication_token = pats.token - WHERE pats.name = '#{TOKEN_NAME}' - SQL - end - - execute <<~SQL - DELETE FROM personal_access_tokens - WHERE name = '#{TOKEN_NAME}' - AND EXISTS ( - SELECT true - FROM users - WHERE id = personal_access_tokens.user_id - AND authentication_token = personal_access_tokens.token - ) - SQL - end -end diff --git a/db/migrate/20171013094327_create_new_clusters_architectures.rb b/db/migrate/20171013094327_create_new_clusters_architectures.rb deleted file mode 100644 index 98f91e6130f..00000000000 --- a/db/migrate/20171013094327_create_new_clusters_architectures.rb +++ /dev/null @@ -1,68 +0,0 @@ -class CreateNewClustersArchitectures < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - create_table :clusters do |t| - t.references :user, index: true, foreign_key: { on_delete: :nullify } - - t.integer :provider_type - t.integer :platform_type - - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false - - t.boolean :enabled, index: true, default: true - - t.string :name, null: false # If manual, read-write. If gcp, read-only. - end - - create_table :cluster_projects do |t| - t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade } - t.references :cluster, null: false, index: true, foreign_key: { on_delete: :cascade } - - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false - end - - create_table :cluster_platforms_kubernetes do |t| - t.references :cluster, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } - - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false - - t.text :api_url - t.text :ca_cert - - t.string :namespace - - t.string :username - t.text :encrypted_password - t.string :encrypted_password_iv - - t.text :encrypted_token - t.string :encrypted_token_iv - end - - create_table :cluster_providers_gcp do |t| - t.references :cluster, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } - - t.integer :status - t.integer :num_nodes, null: false - - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false - - t.text :status_reason - - t.string :gcp_project_id, null: false - t.string :zone, null: false - t.string :machine_type - t.string :operation_id - - t.string :endpoint - - t.text :encrypted_access_token - t.string :encrypted_access_token_iv - end - end -end diff --git a/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb b/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb deleted file mode 100644 index 4a0cadea364..00000000000 --- a/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddNewCircuitbreakerSettingsToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, - :circuitbreaker_access_retries, - :integer, - default: 3 - add_column :application_settings, - :circuitbreaker_backoff_threshold, - :integer, - default: 80 - end -end diff --git a/db/migrate/20171019141859_fix_dev_timezone_schema.rb b/db/migrate/20171019141859_fix_dev_timezone_schema.rb deleted file mode 100644 index 68c8b528e17..00000000000 --- a/db/migrate/20171019141859_fix_dev_timezone_schema.rb +++ /dev/null @@ -1,25 +0,0 @@ -class FixDevTimezoneSchema < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # The this migrations tries to help solve unwanted changes to `schema.rb` - # while developing GitLab. Installations created before we started using - # `datetime_with_timezone` are likely to face this problem. Updating those - # columns to the new type should help fix this. - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - TIMEZONE_TABLES = %i(appearances ci_group_variables ci_pipeline_schedule_variables events gpg_keys gpg_signatures project_auto_devops) - - def up - return unless Rails.env.development? || Rails.env.test? - - TIMEZONE_TABLES.each do |table| - change_column table, :created_at, :datetime_with_timezone - change_column table, :updated_at, :datetime_with_timezone - end - end - - def down - end -end diff --git a/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb b/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb deleted file mode 100644 index 1af0cf70958..00000000000 --- a/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb +++ /dev/null @@ -1,26 +0,0 @@ -class AddLatestMergeRequestDiffIdToMergeRequests < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column :merge_requests, :latest_merge_request_diff_id, :integer - add_concurrent_index :merge_requests, :latest_merge_request_diff_id - - add_concurrent_foreign_key :merge_requests, :merge_request_diffs, - column: :latest_merge_request_diff_id, - on_delete: :nullify - end - - def down - remove_foreign_key :merge_requests, column: :latest_merge_request_diff_id - - if index_exists?(:merge_requests, :latest_merge_request_diff_id) - remove_concurrent_index :merge_requests, :latest_merge_request_diff_id - end - - remove_column :merge_requests, :latest_merge_request_diff_id - end -end diff --git a/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb b/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb deleted file mode 100644 index 0af05f5c94a..00000000000 --- a/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb +++ /dev/null @@ -1,18 +0,0 @@ -class CreateClustersKubernetesHelmApps < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :clusters_applications_helm do |t| - t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } - - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false - - t.integer :status, null: false - t.string :version, null: false - t.text :status_reason - end - end -end diff --git a/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb b/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb deleted file mode 100644 index 6d60fdc6132..00000000000 --- a/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb +++ /dev/null @@ -1,31 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddGitalyTimeoutPropertiesToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :application_settings, - :gitaly_timeout_default, - :integer, - default: 55 - add_column_with_default :application_settings, - :gitaly_timeout_medium, - :integer, - default: 30 - add_column_with_default :application_settings, - :gitaly_timeout_fast, - :integer, - default: 10 - end - - def down - remove_column :application_settings, :gitaly_timeout_default - remove_column :application_settings, :gitaly_timeout_medium - remove_column :application_settings, :gitaly_timeout_fast - end -end diff --git a/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb b/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb deleted file mode 100644 index 93cec87f999..00000000000 --- a/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb +++ /dev/null @@ -1,25 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class SetUploadsPathSizeForMysql < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def up - # We need at least 297 at the moment. For more detail on that number, see: - # https://gitlab.com/gitlab-org/gitlab-ce/issues/40168#what-is-the-expected-correct-behavior - # - # Rails + PostgreSQL `string` is equivalent to a `text` field, but - # Rails + MySQL `string` is `varchar(255)` by default. Also, note that we - # have an upper limit because with a unique index, MySQL has a max key - # length of 3072 bytes which seems to correspond to `varchar(1024)`. - change_column :uploads, :path, :string, limit: 511 - end - - def down - # It was unspecified, which is varchar(255) by default in Rails for MySQL. - change_column :uploads, :path, :string - end -end diff --git a/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb b/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb deleted file mode 100644 index 770cb94ee18..00000000000 --- a/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb +++ /dev/null @@ -1,21 +0,0 @@ -class CreateClustersKubernetesIngressApps < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :clusters_applications_ingress do |t| - t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } - - t.datetime_with_timezone :created_at, null: false - t.datetime_with_timezone :updated_at, null: false - - t.integer :status, null: false - t.integer :ingress_type, null: false - - t.string :version, null: false - t.string :cluster_ip - t.text :status_reason - end - end -end diff --git a/db/migrate/20171106132212_issues_confidential_not_null.rb b/db/migrate/20171106132212_issues_confidential_not_null.rb deleted file mode 100644 index 444a38c2dc5..00000000000 --- a/db/migrate/20171106132212_issues_confidential_not_null.rb +++ /dev/null @@ -1,23 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class IssuesConfidentialNotNull < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - class Issue < ActiveRecord::Base - self.table_name = 'issues' - end - - def up - Issue.where('confidential IS NULL').update_all(confidential: false) - - change_column_null :issues, :confidential, false - end - - def down - # There's no way / point to revert this. - end -end diff --git a/db/migrate/20171106133143_rename_application_settings_password_authentication_enabled_to_password_authentication_enabled_for_web.rb b/db/migrate/20171106133143_rename_application_settings_password_authentication_enabled_to_password_authentication_enabled_for_web.rb deleted file mode 100644 index 58762a4f852..00000000000 --- a/db/migrate/20171106133143_rename_application_settings_password_authentication_enabled_to_password_authentication_enabled_for_web.rb +++ /dev/null @@ -1,15 +0,0 @@ -class RenameApplicationSettingsPasswordAuthenticationEnabledToPasswordAuthenticationEnabledForWeb < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - rename_column_concurrently :application_settings, :password_authentication_enabled, :password_authentication_enabled_for_web - end - - def down - cleanup_concurrent_column_rename :application_settings, :password_authentication_enabled_for_web, :password_authentication_enabled - end -end diff --git a/db/migrate/20171106133911_add_password_authentication_enabled_for_git_to_application_settings.rb b/db/migrate/20171106133911_add_password_authentication_enabled_for_git_to_application_settings.rb deleted file mode 100644 index 1f96a0426a1..00000000000 --- a/db/migrate/20171106133911_add_password_authentication_enabled_for_git_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddPasswordAuthenticationEnabledForGitToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :application_settings, :password_authentication_enabled_for_git, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb b/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb deleted file mode 100644 index 1de7d5e768e..00000000000 --- a/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb +++ /dev/null @@ -1,39 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class IssuesMilestoneIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - class Issue < ActiveRecord::Base - include EachBatch - - self.table_name = 'issues' - - def self.with_orphaned_milestones - where('NOT EXISTS (SELECT true FROM milestones WHERE milestones.id = issues.milestone_id)') - .where('milestone_id IS NOT NULL') - end - end - - def up - Issue.with_orphaned_milestones.each_batch(of: 100) do |batch| - batch.update_all(milestone_id: nil) - end - - add_concurrent_foreign_key( - :issues, - :milestones, - column: :milestone_id, - on_delete: :nullify - ) - end - - def down - remove_foreign_key_without_error(:issues, column: :milestone_id) - end -end diff --git a/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb b/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb deleted file mode 100644 index b2992b1ff5d..00000000000 --- a/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb +++ /dev/null @@ -1,45 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class IssuesUpdatedByIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - class Issue < ActiveRecord::Base - include EachBatch - - self.table_name = 'issues' - - def self.with_orphaned_updaters - where('NOT EXISTS (SELECT true FROM users WHERE users.id = issues.updated_by_id)') - .where('updated_by_id IS NOT NULL') - end - end - - def up - Issue.with_orphaned_updaters.each_batch(of: 100) do |batch| - batch.update_all(updated_by_id: nil) - end - - # This index is only used for foreign keys, and those in turn will always - # specify a value. As such we can add a WHERE condition to make the index - # smaller. - add_concurrent_index(:issues, :updated_by_id, where: 'updated_by_id IS NOT NULL') - - add_concurrent_foreign_key( - :issues, - :users, - column: :updated_by_id, - on_delete: :nullify - ) - end - - def down - remove_foreign_key_without_error(:issues, column: :updated_by_id) - remove_concurrent_index(:issues, :updated_by_id) - end -end diff --git a/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb b/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb deleted file mode 100644 index 66bfb5718dc..00000000000 --- a/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb +++ /dev/null @@ -1,56 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class IssuesMovedToIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - class Issue < ActiveRecord::Base - include EachBatch - - self.table_name = 'issues' - - def self.with_orphaned_moved_to_issues - if Gitlab::Database.postgresql? - # Be careful to use a second table here for comparison otherwise we'll null - # out all rows that don't have id == moved.to_id! - where('NOT EXISTS (SELECT true FROM issues B WHERE issues.moved_to_id = B.id)') - .where('moved_to_id IS NOT NULL') - else - # MySQL doesn't allow modification of the same table in a subquery, - # and using a temporary table isn't automatically guaranteed to work - # due to the MySQL query optimizer. See - # https://dev.mysql.com/doc/refman/5.7/en/update.html for more - # details. - joins('LEFT JOIN issues AS b ON issues.moved_to_id = b.id') - .where('issues.moved_to_id IS NOT NULL AND b.id IS NULL') - end - end - end - - def up - Issue.with_orphaned_moved_to_issues.each_batch(of: 100) do |batch| - batch.update_all(moved_to_id: nil) - end - - add_concurrent_foreign_key( - :issues, - :issues, - column: :moved_to_id, - on_delete: :nullify - ) - - # We're using a partial index here so we only index the data we actually - # care about. - add_concurrent_index(:issues, :moved_to_id, where: 'moved_to_id IS NOT NULL') - end - - def down - remove_foreign_key_without_error(:issues, column: :moved_to_id) - remove_concurrent_index(:issues, :moved_to_id) - end -end diff --git a/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb b/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb deleted file mode 100644 index 58392de5e6b..00000000000 --- a/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb +++ /dev/null @@ -1,35 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - NEW_INDEX_NAME = 'idx_issues_on_project_id_and_due_date_and_id_and_state_partial' - OLD_INDEX_NAME = 'index_issues_on_project_id_and_due_date_and_id_and_state' - - disable_ddl_transaction! - - def up - add_concurrent_index( - :issues, - [:project_id, :due_date, :id, :state], - where: 'due_date IS NOT NULL', - name: NEW_INDEX_NAME - ) - - remove_concurrent_index_by_name(:issues, OLD_INDEX_NAME) - end - - def down - add_concurrent_index( - :issues, - [:project_id, :due_date, :id, :state], - name: OLD_INDEX_NAME - ) - - remove_concurrent_index_by_name(:issues, NEW_INDEX_NAME) - end -end diff --git a/db/migrate/20171106171453_add_timezone_to_issues_closed_at.rb b/db/migrate/20171106171453_add_timezone_to_issues_closed_at.rb deleted file mode 100644 index c6edc1af6cb..00000000000 --- a/db/migrate/20171106171453_add_timezone_to_issues_closed_at.rb +++ /dev/null @@ -1,20 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddTimezoneToIssuesClosedAt < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - # rubocop:disable Migration/UpdateLargeTable - change_column_type_concurrently(:issues, :closed_at, :datetime_with_timezone) - end - - def down - cleanup_concurrent_column_type_change(:issues, :closed_at) - end -end diff --git a/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb b/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb deleted file mode 100644 index 4ebb6fad059..00000000000 --- a/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb +++ /dev/null @@ -1,43 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MergeRequestsAuthorIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - include EachBatch - - self.table_name = 'merge_requests' - - def self.with_orphaned_authors - where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.author_id = users.id)') - .where('author_id IS NOT NULL') - end - end - - def up - # Replacing the ghost user ID logic would be too complex, hence we don't - # redefine the User model here. - ghost_id = User.select(:id).ghost.id - - MergeRequest.with_orphaned_authors.each_batch(of: 100) do |batch| - batch.update_all(author_id: ghost_id) - end - - add_concurrent_foreign_key( - :merge_requests, - :users, - column: :author_id, - on_delete: :nullify - ) - end - - def down - remove_foreign_key(:merge_requests, column: :author_id) - end -end diff --git a/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb b/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb deleted file mode 100644 index 73c177c44f9..00000000000 --- a/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb +++ /dev/null @@ -1,39 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MergeRequestsAssigneeIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - include EachBatch - - self.table_name = 'merge_requests' - - def self.with_orphaned_assignees - where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.assignee_id = users.id)') - .where('assignee_id IS NOT NULL') - end - end - - def up - MergeRequest.with_orphaned_assignees.each_batch(of: 100) do |batch| - batch.update_all(assignee_id: nil) - end - - add_concurrent_foreign_key( - :merge_requests, - :users, - column: :assignee_id, - on_delete: :nullify - ) - end - - def down - remove_foreign_key(:merge_requests, column: :assignee_id) - end -end diff --git a/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb b/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb deleted file mode 100644 index 69f9c181c10..00000000000 --- a/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb +++ /dev/null @@ -1,46 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MergeRequestsUpdatedByIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - include EachBatch - - self.table_name = 'merge_requests' - - def self.with_orphaned_updaters - where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.updated_by_id = users.id)') - .where('updated_by_id IS NOT NULL') - end - end - - def up - MergeRequest.with_orphaned_updaters.each_batch(of: 100) do |batch| - batch.update_all(updated_by_id: nil) - end - - add_concurrent_index( - :merge_requests, - :updated_by_id, - where: 'updated_by_id IS NOT NULL' - ) - - add_concurrent_foreign_key( - :merge_requests, - :users, - column: :updated_by_id, - on_delete: :nullify - ) - end - - def down - remove_foreign_key_without_error(:merge_requests, column: :updated_by_id) - remove_concurrent_index(:merge_requests, :updated_by_id) - end -end diff --git a/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb b/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb deleted file mode 100644 index ccd275d5bb4..00000000000 --- a/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb +++ /dev/null @@ -1,46 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MergeRequestsMergeUserIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - include EachBatch - - self.table_name = 'merge_requests' - - def self.with_orphaned_mergers - where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.merge_user_id = users.id)') - .where('merge_user_id IS NOT NULL') - end - end - - def up - MergeRequest.with_orphaned_mergers.each_batch(of: 100) do |batch| - batch.update_all(merge_user_id: nil) - end - - add_concurrent_index( - :merge_requests, - :merge_user_id, - where: 'merge_user_id IS NOT NULL' - ) - - add_concurrent_foreign_key( - :merge_requests, - :users, - column: :merge_user_id, - on_delete: :nullify - ) - end - - def down - remove_foreign_key_without_error(:merge_requests, column: :merge_user_id) - remove_concurrent_index(:merge_requests, :merge_user_id) - end -end diff --git a/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb b/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb deleted file mode 100644 index 250928a6551..00000000000 --- a/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb +++ /dev/null @@ -1,45 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MergeRequestsSourceProjectIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - include EachBatch - - self.table_name = 'merge_requests' - - def self.with_orphaned_source_projects - where('NOT EXISTS (SELECT true FROM projects WHERE merge_requests.source_project_id = projects.id)') - .where('source_project_id IS NOT NULL') - end - end - - def up - # We need to allow NULL values so we can nullify the column when the source - # project is removed. We _don't_ want to remove the merge request, instead - # the application will keep them but close them. - change_column_null(:merge_requests, :source_project_id, true) - - MergeRequest.with_orphaned_source_projects.each_batch(of: 100) do |batch| - batch.update_all(source_project_id: nil) - end - - add_concurrent_foreign_key( - :merge_requests, - :projects, - column: :source_project_id, - on_delete: :nullify - ) - end - - def down - remove_foreign_key_without_error(:merge_requests, column: :source_project_id) - change_column_null(:merge_requests, :source_project_id, false) - end -end diff --git a/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb b/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb deleted file mode 100644 index cafe0ce0853..00000000000 --- a/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb +++ /dev/null @@ -1,39 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MergeRequestsMilestoneIdForeignKey < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - include EachBatch - - self.table_name = 'merge_requests' - - def self.with_orphaned_milestones - where('NOT EXISTS (SELECT true FROM milestones WHERE merge_requests.milestone_id = milestones.id)') - .where('milestone_id IS NOT NULL') - end - end - - def up - MergeRequest.with_orphaned_milestones.each_batch(of: 100) do |batch| - batch.update_all(milestone_id: nil) - end - - add_concurrent_foreign_key( - :merge_requests, - :milestones, - column: :milestone_id, - on_delete: :nullify - ) - end - - def down - remove_foreign_key_without_error(:merge_requests, column: :milestone_id) - end -end diff --git a/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb b/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb deleted file mode 100644 index 935092ce46a..00000000000 --- a/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb +++ /dev/null @@ -1,30 +0,0 @@ -# This is identical to the stolen background migration, which already has specs. -class PopulateMergeRequestsLatestMergeRequestDiffIdTakeTwo < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - BATCH_SIZE = 1_000 - - class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' - - include ::EachBatch - end - - disable_ddl_transaction! - - def up - Gitlab::BackgroundMigration.steal('PopulateMergeRequestsLatestMergeRequestDiffId') - - update = ' - latest_merge_request_diff_id = ( - SELECT MAX(id) - FROM merge_request_diffs - WHERE merge_requests.id = merge_request_diffs.merge_request_id - )'.squish - - MergeRequest.where(latest_merge_request_diff_id: nil).each_batch(of: BATCH_SIZE) do |relation| - relation.update_all(update) - end - end -end diff --git a/db/migrate/20171116135628_add_environment_scope_to_clusters.rb b/db/migrate/20171116135628_add_environment_scope_to_clusters.rb deleted file mode 100644 index 39bb8759cc0..00000000000 --- a/db/migrate/20171116135628_add_environment_scope_to_clusters.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddEnvironmentScopeToClusters < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default(:clusters, :environment_scope, :string, default: '*') - end - - def down - remove_column(:clusters, :environment_scope) - end -end diff --git a/db/migrate/20171121144800_ci_pipelines_index_on_project_id_ref_status_id.rb b/db/migrate/20171121144800_ci_pipelines_index_on_project_id_ref_status_id.rb deleted file mode 100644 index a1dcfc70650..00000000000 --- a/db/migrate/20171121144800_ci_pipelines_index_on_project_id_ref_status_id.rb +++ /dev/null @@ -1,35 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CiPipelinesIndexOnProjectIdRefStatusId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - TABLE = :ci_pipelines - OLD_COLUMNS = %i[project_id ref status].freeze - NEW_COLUMNS = %i[project_id ref status id].freeze - - def up - unless index_exists?(TABLE, NEW_COLUMNS) - add_concurrent_index(TABLE, NEW_COLUMNS) - end - - if index_exists?(TABLE, OLD_COLUMNS) - remove_concurrent_index(TABLE, OLD_COLUMNS) - end - end - - def down - unless index_exists?(TABLE, OLD_COLUMNS) - add_concurrent_index(TABLE, OLD_COLUMNS) - end - - if index_exists?(TABLE, NEW_COLUMNS) - remove_concurrent_index(TABLE, NEW_COLUMNS) - end - end -end diff --git a/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb b/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb deleted file mode 100644 index cbcbb5d988a..00000000000 --- a/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb +++ /dev/null @@ -1,18 +0,0 @@ -class AddNewProjectGuidelinesToAppearances < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - # Clears the current Appearance cache otherwise it breaks since - # new_project_guidelines_html would be missing. See - # https://gitlab.com/gitlab-org/gitlab-ce/issues/41041 - # We're not using Appearance#flush_redis_cache on purpose here. - Rails.cache.delete('current_appearance') - - change_table :appearances do |t| - t.text :new_project_guidelines - t.text :new_project_guidelines_html - end - end -end diff --git a/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb b/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb deleted file mode 100644 index 94360c64926..00000000000 --- a/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb +++ /dev/null @@ -1,20 +0,0 @@ -class AddCircuitbreakerCheckIntervalToApplicationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :application_settings, - :circuitbreaker_check_interval, - :integer, - default: 1 - end - - def down - remove_column :application_settings, - :circuitbreaker_check_interval - end -end diff --git a/db/migrate/20171124125042_add_default_values_to_merge_request_states.rb b/db/migrate/20171124125042_add_default_values_to_merge_request_states.rb deleted file mode 100644 index d0d06863777..00000000000 --- a/db/migrate/20171124125042_add_default_values_to_merge_request_states.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddDefaultValuesToMergeRequestStates < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def up - change_column_default :merge_requests, :state, :opened - change_column_default :merge_requests, :merge_status, :unchecked - end - - def down - change_column_default :merge_requests, :state, nil - change_column_default :merge_requests, :merge_status, nil - end -end diff --git a/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb b/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb deleted file mode 100644 index 67444f36e24..00000000000 --- a/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb +++ /dev/null @@ -1,50 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class PopulateMissingMergeRequestStatuses < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - include EachBatch - - self.table_name = 'merge_requests' - end - - def up - say 'Populating missing merge_requests.state values' - - # GitLab.com has no rows where "state" is NULL, and technically this should - # never happen. However it doesn't hurt to be 100% certain. - MergeRequest.where(state: nil).each_batch do |batch| - batch.update_all(state: 'opened') - end - - say 'Populating missing merge_requests.merge_status values. ' \ - 'This will take a few minutes...' - - # GitLab.com has 66 880 rows where "merge_status" is NULL, dating back all - # the way to 2011. - MergeRequest.where(merge_status: nil).each_batch(of: 10_000) do |batch| - batch.update_all(merge_status: 'unchecked') - - # We want to give PostgreSQL some time to vacuum any dead tuples. In - # production we see it takes roughly 1 minute for a vacuuming run to clear - # out 10-20k dead tuples, so we'll wait for 90 seconds between every - # batch. - sleep(90) if sleep? - end - end - - def down - # Reverting this makes no sense. - end - - def sleep? - Rails.env.staging? || Rails.env.production? - end -end diff --git a/db/migrate/20171124132536_make_merge_request_statuses_not_null.rb b/db/migrate/20171124132536_make_merge_request_statuses_not_null.rb deleted file mode 100644 index 49b693c5950..00000000000 --- a/db/migrate/20171124132536_make_merge_request_statuses_not_null.rb +++ /dev/null @@ -1,14 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MakeMergeRequestStatusesNotNull < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - change_column_null :merge_requests, :state, false - change_column_null :merge_requests, :merge_status, false - end -end diff --git a/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb b/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb deleted file mode 100644 index 385de9dd73d..00000000000 --- a/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb +++ /dev/null @@ -1,37 +0,0 @@ -class AddEventsRelatedColumnsToMergeRequestMetrics < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - change_table :merge_request_metrics do |t| - t.references :merged_by, references: :users - t.references :latest_closed_by, references: :users - end - - add_column :merge_request_metrics, :latest_closed_at, :datetime_with_timezone - - add_concurrent_foreign_key :merge_request_metrics, :users, - column: :merged_by_id, - on_delete: :nullify - - add_concurrent_foreign_key :merge_request_metrics, :users, - column: :latest_closed_by_id, - on_delete: :nullify - end - - def down - if foreign_keys_for(:merge_request_metrics, :merged_by_id).any? - remove_foreign_key :merge_request_metrics, column: :merged_by_id - end - - if foreign_keys_for(:merge_request_metrics, :latest_closed_by_id).any? - remove_foreign_key :merge_request_metrics, column: :latest_closed_by_id - end - - remove_columns :merge_request_metrics, - :merged_by_id, :latest_closed_by_id, :latest_closed_at - end -end diff --git a/db/migrate/20171204204233_add_permanent_to_redirect_route.rb b/db/migrate/20171204204233_add_permanent_to_redirect_route.rb deleted file mode 100644 index bc0658035d6..00000000000 --- a/db/migrate/20171204204233_add_permanent_to_redirect_route.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddPermanentToRedirectRoute < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def up - add_column(:redirect_routes, :permanent, :boolean) - end - - def down - remove_column(:redirect_routes, :permanent) - end -end diff --git a/db/migrate/20171206221519_add_permanent_index_to_redirect_route.rb b/db/migrate/20171206221519_add_permanent_index_to_redirect_route.rb deleted file mode 100644 index ba924c4eecc..00000000000 --- a/db/migrate/20171206221519_add_permanent_index_to_redirect_route.rb +++ /dev/null @@ -1,19 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddPermanentIndexToRedirectRoute < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index(:redirect_routes, :permanent) - end - - def down - remove_concurrent_index(:redirect_routes, :permanent) if index_exists?(:redirect_routes, :permanent) - end -end diff --git a/db/migrate/20171207185153_add_merge_request_state_index.rb b/db/migrate/20171207185153_add_merge_request_state_index.rb deleted file mode 100644 index 167470cf7fe..00000000000 --- a/db/migrate/20171207185153_add_merge_request_state_index.rb +++ /dev/null @@ -1,18 +0,0 @@ -class AddMergeRequestStateIndex < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :merge_requests, [:source_project_id, :source_branch], - where: "state = 'opened'", - name: 'index_merge_requests_on_source_project_and_branch_state_opened' - end - - def down - remove_concurrent_index_by_name :merge_requests, - 'index_merge_requests_on_source_project_and_branch_state_opened' - end -end diff --git a/db/migrate/20171211131502_add_external_classification_authorization_settings_to_appliction_settings.rb b/db/migrate/20171211131502_add_external_classification_authorization_settings_to_appliction_settings.rb deleted file mode 100644 index a7dec8732fb..00000000000 --- a/db/migrate/20171211131502_add_external_classification_authorization_settings_to_appliction_settings.rb +++ /dev/null @@ -1,29 +0,0 @@ -class AddExternalClassificationAuthorizationSettingsToApplictionSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :application_settings, - :external_authorization_service_enabled, - :boolean, - default: false - add_column :application_settings, - :external_authorization_service_url, - :string - add_column :application_settings, - :external_authorization_service_default_label, - :string - end - - def down - remove_column :application_settings, - :external_authorization_service_default_label - remove_column :application_settings, - :external_authorization_service_url - remove_column :application_settings, - :external_authorization_service_enabled - end -end diff --git a/db/migrate/20171211145425_add_can_push_to_deploy_keys_projects.rb b/db/migrate/20171211145425_add_can_push_to_deploy_keys_projects.rb deleted file mode 100644 index 63e86b23aad..00000000000 --- a/db/migrate/20171211145425_add_can_push_to_deploy_keys_projects.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddCanPushToDeployKeysProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - disable_ddl_transaction! - - def up - add_column_with_default :deploy_keys_projects, :can_push, :boolean, default: false, allow_null: false - end - - def down - remove_column :deploy_keys_projects, :can_push - end -end diff --git a/db/migrate/20171212203433_create_clusters_applications_prometheus.rb b/db/migrate/20171212203433_create_clusters_applications_prometheus.rb deleted file mode 100644 index 6eb9fec609e..00000000000 --- a/db/migrate/20171212203433_create_clusters_applications_prometheus.rb +++ /dev/null @@ -1,18 +0,0 @@ -class CreateClustersApplicationsPrometheus < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :clusters_applications_prometheus do |t| - t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } - - t.integer :status, null: false - t.string :version, null: false - - t.text :status_reason - - t.timestamps_with_timezone null: false - end - end -end diff --git a/db/migrate/20171214144320_add_store_column_to_uploads.rb b/db/migrate/20171214144320_add_store_column_to_uploads.rb deleted file mode 100644 index 11b3951a3fa..00000000000 --- a/db/migrate/20171214144320_add_store_column_to_uploads.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddStoreColumnToUploads < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column(:uploads, :store, :integer) - end -end diff --git a/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb b/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb deleted file mode 100644 index e2d7879b140..00000000000 --- a/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb +++ /dev/null @@ -1,64 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class PopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - DATABASE_NAME = Gitlab::Database.database_name - - disable_ddl_transaction! - - class DeploysKeyProject < ActiveRecord::Base - include EachBatch - - self.table_name = 'deploy_keys_projects' - end - - def up - DeploysKeyProject.each_batch(of: 10_000) do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first - - if Gitlab::Database.mysql? - execute <<-EOF.strip_heredoc - UPDATE deploy_keys_projects, #{DATABASE_NAME}.keys - SET deploy_keys_projects.can_push = #{DATABASE_NAME}.keys.can_push - WHERE deploy_keys_projects.deploy_key_id = #{DATABASE_NAME}.keys.id - AND deploy_keys_projects.id BETWEEN #{start_id} AND #{end_id} - EOF - else - execute <<-EOF.strip_heredoc - UPDATE deploy_keys_projects - SET can_push = keys.can_push - FROM keys - WHERE deploy_key_id = keys.id - AND deploy_keys_projects.id BETWEEN #{start_id} AND #{end_id} - EOF - end - end - end - - def down - DeploysKeyProject.each_batch(of: 10_000) do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first - - if Gitlab::Database.mysql? - execute <<-EOF.strip_heredoc - UPDATE deploy_keys_projects, #{DATABASE_NAME}.keys - SET #{DATABASE_NAME}.keys.can_push = deploy_keys_projects.can_push - WHERE deploy_keys_projects.deploy_key_id = #{DATABASE_NAME}.keys.id - AND deploy_keys_projects.id BETWEEN #{start_id} AND #{end_id} - EOF - else - execute <<-EOF.strip_heredoc - UPDATE keys - SET can_push = deploy_keys_projects.can_push - FROM deploy_keys_projects - WHERE deploy_keys_projects.deploy_key_id = keys.id - AND deploy_keys_projects.id BETWEEN #{start_id} AND #{end_id} - EOF - end - end - end -end diff --git a/db/migrate/20171216112339_add_foreign_key_for_members.rb b/db/migrate/20171216112339_add_foreign_key_for_members.rb deleted file mode 100644 index 06c2c5068da..00000000000 --- a/db/migrate/20171216112339_add_foreign_key_for_members.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddForeignKeyForMembers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key(:members, - :users, - column: :user_id) - end - - def down - remove_foreign_key(:members, column: :user_id) - end -end diff --git a/db/migrate/20171218140451_add_external_authorization_service_classification_label_to_projects.rb b/db/migrate/20171218140451_add_external_authorization_service_classification_label_to_projects.rb deleted file mode 100644 index 7b83580f025..00000000000 --- a/db/migrate/20171218140451_add_external_authorization_service_classification_label_to_projects.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddExternalAuthorizationServiceClassificationLabelToProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :projects, - :external_authorization_classification_label, - :string - end -end diff --git a/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb b/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb deleted file mode 100644 index 7543e435941..00000000000 --- a/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb +++ /dev/null @@ -1,32 +0,0 @@ -class AddIndexOnNamespacesLowerName < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - INDEX_NAME = 'index_on_namespaces_lower_name' - - disable_ddl_transaction! - - def up - return unless Gitlab::Database.postgresql? - - disable_statement_timeout do - if Gitlab::Database.version.to_f >= 9.5 - # Allow us to hot-patch the index manually ahead of the migration - execute "CREATE INDEX CONCURRENTLY IF NOT EXISTS #{INDEX_NAME} ON namespaces (lower(name));" - else - execute "CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON namespaces (lower(name));" - end - end - end - - def down - return unless Gitlab::Database.postgresql? - - disable_statement_timeout do - if Gitlab::Database.version.to_f >= 9.2 - execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME};" - else - execute "DROP INDEX IF EXISTS #{INDEX_NAME};" - end - end - end -end 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 deleted file mode 100644 index 788a842a3ad..00000000000 --- a/db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddConfidentialNoteEventsToWebHooks < ActiveRecord::Migration[4.2] - 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/20171222183504_add_jobs_cache_index_to_project.rb b/db/migrate/20171222183504_add_jobs_cache_index_to_project.rb deleted file mode 100644 index 78a195c351c..00000000000 --- a/db/migrate/20171222183504_add_jobs_cache_index_to_project.rb +++ /dev/null @@ -1,13 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddJobsCacheIndexToProject < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - add_column :projects, :jobs_cache_index, :integer - end -end diff --git a/db/migrate/20171229225929_change_user_project_limit_not_null_and_remove_default.rb b/db/migrate/20171229225929_change_user_project_limit_not_null_and_remove_default.rb deleted file mode 100644 index b9efdb8bb8f..00000000000 --- a/db/migrate/20171229225929_change_user_project_limit_not_null_and_remove_default.rb +++ /dev/null @@ -1,38 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class ChangeUserProjectLimitNotNullAndRemoveDefault < ActiveRecord::Migration[4.2] - 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 up - # Set Users#projects_limit to NOT NULL and remove the default value - change_column_null :users, :projects_limit, false - change_column_default :users, :projects_limit, nil - end - - def down - change_column_null :users, :projects_limit, true - change_column_default :users, :projects_limit, 10 - end -end diff --git a/db/migrate/20171230123729_add_rebase_commit_sha_to_merge_requests_ce.rb b/db/migrate/20171230123729_add_rebase_commit_sha_to_merge_requests_ce.rb deleted file mode 100644 index 4e1107e1ff5..00000000000 --- a/db/migrate/20171230123729_add_rebase_commit_sha_to_merge_requests_ce.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddRebaseCommitShaToMergeRequestsCe < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - unless column_exists?(:merge_requests, :rebase_commit_sha) - add_column :merge_requests, :rebase_commit_sha, :string - end - end - - def down - if column_exists?(:merge_requests, :rebase_commit_sha) - remove_column :merge_requests, :rebase_commit_sha - end - end -end diff --git a/db/migrate/20171230123729_init_schema.rb b/db/migrate/20171230123729_init_schema.rb new file mode 100644 index 00000000000..ae7541f2475 --- /dev/null +++ b/db/migrate/20171230123729_init_schema.rb @@ -0,0 +1,1854 @@ +# frozen_string_literal: true + +# rubocop:disable Layout/SpaceInsideHashLiteralBraces +# rubocop:disable Layout/SpaceAroundOperators +# rubocop:disable Metrics/AbcSize +# rubocop:disable Migration/AddConcurrentForeignKey +# rubocop:disable Style/WordArray + +class InitSchema < ActiveRecord::Migration[4.2] + DOWNTIME = false + + def up + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + enable_extension "pg_trgm" + create_table "abuse_reports", id: :serial do |t| + t.integer "reporter_id" + t.integer "user_id" + t.text "message" + t.datetime "created_at" + t.datetime "updated_at" + t.text "message_html" + t.integer "cached_markdown_version" + end + create_table "appearances", id: :serial do |t| + t.string "title", null: false + 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.text "description_html" + t.integer "cached_markdown_version" + t.string "favicon" + t.text "new_project_guidelines" + t.text "new_project_guidelines_html" + end + create_table "application_settings", id: :serial do |t| + t.integer "default_projects_limit" + t.boolean "signup_enabled" + t.boolean "gravatar_enabled" + t.text "sign_in_text" + t.datetime "created_at" + t.datetime "updated_at" + t.string "home_page_url" + t.integer "default_branch_protection", default: 2 + t.text "restricted_visibility_levels" + t.boolean "version_check_enabled", default: true + t.integer "max_attachment_size", default: 10, null: false + t.integer "default_project_visibility" + t.integer "default_snippet_visibility" + t.text "domain_whitelist" + t.boolean "user_oauth_applications", default: true + t.string "after_sign_out_path" + t.integer "session_expire_delay", default: 10080, null: false + t.text "import_sources" + t.text "help_page_text" + t.string "admin_notification_email" + t.boolean "shared_runners_enabled", default: true, null: false + t.integer "max_artifacts_size", default: 100, null: false + t.string "runners_registration_token" + t.integer "max_pages_size", default: 100, null: false + t.boolean "require_two_factor_authentication", default: false + t.integer "two_factor_grace_period", default: 48 + t.boolean "metrics_enabled", default: false + t.string "metrics_host", default: "localhost" + t.integer "metrics_pool_size", default: 16 + t.integer "metrics_timeout", default: 10 + t.integer "metrics_method_call_threshold", default: 10 + t.boolean "recaptcha_enabled", default: false + t.string "recaptcha_site_key" + t.string "recaptcha_private_key" + t.integer "metrics_port", default: 8089 + t.boolean "akismet_enabled", default: false + t.string "akismet_api_key" + t.integer "metrics_sample_interval", default: 15 + t.boolean "sentry_enabled", default: false + t.string "sentry_dsn" + t.boolean "email_author_in_body", default: false + t.integer "default_group_visibility" + t.boolean "repository_checks_enabled", default: false + t.text "shared_runners_text" + t.integer "metrics_packet_size", default: 1 + t.text "disabled_oauth_sign_in_sources" + t.string "health_check_access_token" + t.boolean "send_user_confirmation_email", default: false + t.integer "container_registry_token_expire_delay", default: 5 + t.text "after_sign_up_text" + t.boolean "user_default_external", default: false, null: false + t.string "repository_storages", default: "default" + t.string "enabled_git_access_protocol" + t.boolean "domain_blacklist_enabled", default: false + t.text "domain_blacklist" + t.boolean "usage_ping_enabled", default: true, null: false + t.boolean "koding_enabled" + t.string "koding_url" + t.text "sign_in_text_html" + 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 + t.integer "housekeeping_full_repack_period", default: 50, null: false + t.integer "housekeeping_gc_period", default: 200, null: false + t.boolean "sidekiq_throttling_enabled", default: false + t.string "sidekiq_throttling_queues" + t.decimal "sidekiq_throttling_factor" + t.boolean "html_emails_enabled", default: true + t.string "plantuml_url" + t.boolean "plantuml_enabled" + t.integer "terminal_max_session_time", default: 0, null: false + t.integer "unique_ips_limit_per_user" + t.integer "unique_ips_limit_time_window" + t.boolean "unique_ips_limit_enabled", default: false, null: false + t.string "default_artifacts_expire_in", default: "0", null: false + t.string "uuid" + t.decimal "polling_interval_multiplier", default: "1.0", null: false + t.integer "cached_markdown_version" + t.boolean "clientside_sentry_enabled", default: false, null: false + t.string "clientside_sentry_dsn" + t.boolean "prometheus_metrics_enabled", default: false, null: false + t.boolean "authorized_keys_enabled", default: true, 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 "hashed_storage_enabled", default: false, null: false + t.boolean "project_export_enabled", default: true, null: false + t.boolean "auto_devops_enabled", default: false, null: false + t.boolean "throttle_unauthenticated_enabled", default: false, null: false + t.integer "throttle_unauthenticated_requests_per_period", default: 3600, null: false + t.integer "throttle_unauthenticated_period_in_seconds", default: 3600, null: false + t.boolean "throttle_authenticated_api_enabled", default: false, null: false + t.integer "throttle_authenticated_api_requests_per_period", default: 7200, null: false + t.integer "throttle_authenticated_api_period_in_seconds", default: 3600, null: false + t.boolean "throttle_authenticated_web_enabled", default: false, null: false + t.integer "throttle_authenticated_web_requests_per_period", default: 7200, null: false + t.integer "throttle_authenticated_web_period_in_seconds", default: 3600, null: false + t.integer "circuitbreaker_failure_count_threshold", default: 3 + t.integer "circuitbreaker_failure_reset_time", default: 1800 + t.integer "circuitbreaker_storage_timeout", default: 15 + t.integer "circuitbreaker_access_retries", default: 3 + t.integer "gitaly_timeout_default", default: 55, null: false + t.integer "gitaly_timeout_medium", default: 30, null: false + t.integer "gitaly_timeout_fast", default: 10, null: false + t.boolean "password_authentication_enabled_for_web" + t.boolean "password_authentication_enabled_for_git", default: true, null: false + t.integer "circuitbreaker_check_interval", default: 1, null: false + t.boolean "external_authorization_service_enabled", default: false, null: false + t.string "external_authorization_service_url" + t.string "external_authorization_service_default_label" + end + create_table "audit_events", id: :serial do |t| + t.integer "author_id", null: false + t.string "type", null: false + t.integer "entity_id", null: false + t.string "entity_type", null: false + t.text "details" + t.datetime "created_at" + t.datetime "updated_at" + t.index ["entity_id", "entity_type"], name: "index_audit_events_on_entity_id_and_entity_type", using: :btree + end + create_table "award_emoji", id: :serial do |t| + t.string "name" + t.integer "user_id" + t.string "awardable_type" + t.integer "awardable_id" + t.datetime "created_at" + t.datetime "updated_at" + t.index ["awardable_type", "awardable_id"], name: "index_award_emoji_on_awardable_type_and_awardable_id", using: :btree + t.index ["user_id", "name"], name: "index_award_emoji_on_user_id_and_name", using: :btree + end + create_table "boards", id: :serial do |t| + t.integer "project_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["project_id"], name: "index_boards_on_project_id", using: :btree + end + create_table "broadcast_messages", id: :serial do |t| + t.text "message", null: false + t.datetime "starts_at", null: false + t.datetime "ends_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "color" + t.string "font" + t.text "message_html", null: false + t.integer "cached_markdown_version" + t.index ["starts_at", "ends_at", "id"], name: "index_broadcast_messages_on_starts_at_and_ends_at_and_id", using: :btree + end + create_table "chat_names", id: :serial do |t| + t.integer "user_id", null: false + t.integer "service_id", null: false + t.string "team_id", null: false + t.string "team_domain" + t.string "chat_id", null: false + t.string "chat_name" + t.datetime "last_used_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["service_id", "team_id", "chat_id"], name: "index_chat_names_on_service_id_and_team_id_and_chat_id", unique: true, using: :btree + t.index ["user_id", "service_id"], name: "index_chat_names_on_user_id_and_service_id", unique: true, using: :btree + end + create_table "chat_teams", id: :serial do |t| + t.integer "namespace_id", null: false + t.string "team_id" + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["namespace_id"], name: "index_chat_teams_on_namespace_id", unique: true, using: :btree + end + create_table "ci_build_trace_section_names", id: :serial do |t| + t.integer "project_id", null: false + t.string "name", null: false + t.index ["project_id", "name"], name: "index_ci_build_trace_section_names_on_project_id_and_name", unique: true, using: :btree + end + create_table "ci_build_trace_sections", id: :serial do |t| + t.integer "project_id", null: false + t.datetime_with_timezone "date_start", null: false + t.datetime_with_timezone "date_end", null: false + t.bigint "byte_start", null: false + t.bigint "byte_end", null: false + t.integer "build_id", null: false + t.integer "section_name_id", null: false + t.index ["build_id", "section_name_id"], name: "index_ci_build_trace_sections_on_build_id_and_section_name_id", unique: true, using: :btree + t.index ["project_id"], name: "index_ci_build_trace_sections_on_project_id", using: :btree + end + create_table "ci_builds", id: :serial do |t| + t.string "status" + t.datetime "finished_at" + t.text "trace" + t.datetime "created_at" + t.datetime "updated_at" + t.datetime "started_at" + t.integer "runner_id" + t.float "coverage" + t.integer "commit_id" + t.text "commands" + t.string "name" + t.text "options" + t.boolean "allow_failure", default: false, null: false + t.string "stage" + t.integer "trigger_request_id" + t.integer "stage_idx" + t.boolean "tag" + t.string "ref" + t.integer "user_id" + t.string "type" + t.string "target_url" + t.string "description" + t.text "artifacts_file" + t.integer "project_id" + t.text "artifacts_metadata" + t.integer "erased_by_id" + t.datetime "erased_at" + t.datetime "artifacts_expire_at" + t.string "environment" + t.bigint "artifacts_size" + t.string "when" + t.text "yaml_variables" + t.datetime "queued_at" + t.string "token" + t.integer "lock_version" + t.string "coverage_regex" + t.integer "auto_canceled_by_id" + t.boolean "retried" + t.integer "stage_id" + t.integer "artifacts_file_store" + t.integer "artifacts_metadata_store" + t.boolean "protected" + t.integer "failure_reason" + t.index ["auto_canceled_by_id"], name: "index_ci_builds_on_auto_canceled_by_id", using: :btree + t.index ["commit_id", "stage_idx", "created_at"], name: "index_ci_builds_on_commit_id_and_stage_idx_and_created_at", using: :btree + t.index ["commit_id", "status", "type"], name: "index_ci_builds_on_commit_id_and_status_and_type", using: :btree + t.index ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref", using: :btree + t.index ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref", using: :btree + t.index ["project_id", "id"], name: "index_ci_builds_on_project_id_and_id", using: :btree + t.index ["protected"], name: "index_ci_builds_on_protected", using: :btree + t.index ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree + t.index ["stage_id"], name: "index_ci_builds_on_stage_id", using: :btree + t.index ["status", "type", "runner_id"], name: "index_ci_builds_on_status_and_type_and_runner_id", using: :btree + t.index ["status"], name: "index_ci_builds_on_status", using: :btree + t.index ["token"], name: "index_ci_builds_on_token", unique: true, using: :btree + t.index ["updated_at"], name: "index_ci_builds_on_updated_at", using: :btree + t.index ["user_id"], name: "index_ci_builds_on_user_id", using: :btree + end + create_table "ci_group_variables", id: :serial do |t| + t.string "key", null: false + t.text "value" + t.text "encrypted_value" + t.string "encrypted_value_salt" + 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.index ["group_id", "key"], name: "index_ci_group_variables_on_group_id_and_key", unique: true, using: :btree + end + create_table "ci_job_artifacts", id: :serial do |t| + t.integer "project_id", null: false + t.integer "job_id", null: false + t.integer "file_type", null: false + t.bigint "size" + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.datetime_with_timezone "expire_at" + t.string "file" + t.integer "file_store" + t.index ["job_id", "file_type"], name: "index_ci_job_artifacts_on_job_id_and_file_type", unique: true, using: :btree + t.index ["project_id"], name: "index_ci_job_artifacts_on_project_id", using: :btree + end + create_table "ci_pipeline_schedule_variables", id: :serial do |t| + t.string "key", null: false + t.text "value" + t.text "encrypted_value" + 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.index ["pipeline_schedule_id", "key"], name: "index_ci_pipeline_schedule_variables_on_schedule_id_and_key", unique: true, using: :btree + end + create_table "ci_pipeline_schedules", id: :serial do |t| + t.string "description" + t.string "ref" + t.string "cron" + t.string "cron_timezone" + t.datetime "next_run_at" + t.integer "project_id" + t.integer "owner_id" + t.boolean "active", default: true + t.datetime "created_at" + t.datetime "updated_at" + t.index ["next_run_at", "active"], name: "index_ci_pipeline_schedules_on_next_run_at_and_active", using: :btree + t.index ["project_id"], name: "index_ci_pipeline_schedules_on_project_id", using: :btree + end + create_table "ci_pipeline_variables", id: :serial do |t| + t.string "key", null: false + t.text "value" + t.text "encrypted_value" + t.string "encrypted_value_salt" + t.string "encrypted_value_iv" + t.integer "pipeline_id", null: false + t.index ["pipeline_id", "key"], name: "index_ci_pipeline_variables_on_pipeline_id_and_key", unique: true, using: :btree + end + create_table "ci_pipelines", id: :serial do |t| + t.string "ref" + t.string "sha" + t.string "before_sha" + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "tag", default: false + t.text "yaml_errors" + t.datetime "committed_at" + t.integer "project_id" + t.string "status" + t.datetime "started_at" + t.datetime "finished_at" + t.integer "duration" + t.integer "user_id" + t.integer "lock_version" + t.integer "auto_canceled_by_id" + t.integer "pipeline_schedule_id" + t.integer "source" + t.boolean "protected" + t.integer "config_source" + t.integer "failure_reason" + t.index ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree + t.index ["pipeline_schedule_id"], name: "index_ci_pipelines_on_pipeline_schedule_id", using: :btree + t.index ["project_id", "ref", "status", "id"], name: "index_ci_pipelines_on_project_id_and_ref_and_status_and_id", using: :btree + t.index ["project_id", "sha"], name: "index_ci_pipelines_on_project_id_and_sha", using: :btree + t.index ["project_id"], name: "index_ci_pipelines_on_project_id", using: :btree + t.index ["status"], name: "index_ci_pipelines_on_status", using: :btree + t.index ["user_id"], name: "index_ci_pipelines_on_user_id", using: :btree + end + create_table "ci_runner_namespaces", id: :serial do |t| + t.integer "runner_id" + t.integer "namespace_id" + t.index ["namespace_id"], name: "index_ci_runner_namespaces_on_namespace_id", using: :btree + t.index ["runner_id", "namespace_id"], name: "index_ci_runner_namespaces_on_runner_id_and_namespace_id", unique: true, using: :btree + end + create_table "ci_runner_projects", id: :serial do |t| + t.integer "runner_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "project_id" + t.index ["project_id"], name: "index_ci_runner_projects_on_project_id", using: :btree + t.index ["runner_id"], name: "index_ci_runner_projects_on_runner_id", using: :btree + end + create_table "ci_runners", id: :serial do |t| + t.string "token" + t.datetime "created_at" + t.datetime "updated_at" + t.string "description" + t.datetime "contacted_at" + t.boolean "active", default: true, null: false + t.boolean "is_shared", default: false + t.string "name" + t.string "version" + t.string "revision" + t.string "platform" + t.string "architecture" + t.boolean "run_untagged", default: true, null: false + t.boolean "locked", default: false, null: false + t.integer "access_level", default: 0, null: false + t.index ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree + t.index ["is_shared"], name: "index_ci_runners_on_is_shared", using: :btree + t.index ["locked"], name: "index_ci_runners_on_locked", using: :btree + t.index ["token"], name: "index_ci_runners_on_token", using: :btree + end + create_table "ci_stages", id: :serial do |t| + t.integer "project_id" + t.integer "pipeline_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "name" + t.integer "status" + t.integer "lock_version" + t.index ["pipeline_id", "name"], name: "index_ci_stages_on_pipeline_id_and_name", using: :btree + t.index ["pipeline_id"], name: "index_ci_stages_on_pipeline_id", using: :btree + t.index ["project_id"], name: "index_ci_stages_on_project_id", using: :btree + end + create_table "ci_trigger_requests", id: :serial do |t| + t.integer "trigger_id", null: false + t.text "variables" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "commit_id" + t.index ["commit_id"], name: "index_ci_trigger_requests_on_commit_id", using: :btree + end + create_table "ci_triggers", id: :serial do |t| + t.string "token" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "project_id" + t.integer "owner_id" + t.string "description" + t.string "ref" + t.index ["project_id"], name: "index_ci_triggers_on_project_id", using: :btree + end + create_table "ci_variables", id: :serial do |t| + t.string "key", null: false + t.text "value" + t.text "encrypted_value" + t.string "encrypted_value_salt" + t.string "encrypted_value_iv" + t.integer "project_id", null: false + t.boolean "protected", default: false, null: false + t.string "environment_scope", default: "*", null: false + t.index ["project_id", "key", "environment_scope"], name: "index_ci_variables_on_project_id_and_key_and_environment_scope", unique: true, using: :btree + end + create_table "cluster_platforms_kubernetes", id: :serial do |t| + t.integer "cluster_id", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.text "api_url" + t.text "ca_cert" + t.string "namespace" + t.string "username" + t.text "encrypted_password" + t.string "encrypted_password_iv" + t.text "encrypted_token" + t.string "encrypted_token_iv" + t.index ["cluster_id"], name: "index_cluster_platforms_kubernetes_on_cluster_id", unique: true, using: :btree + end + create_table "cluster_projects", id: :serial do |t| + t.integer "project_id", null: false + t.integer "cluster_id", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.index ["cluster_id"], name: "index_cluster_projects_on_cluster_id", using: :btree + t.index ["project_id"], name: "index_cluster_projects_on_project_id", using: :btree + end + create_table "cluster_providers_gcp", id: :serial do |t| + t.integer "cluster_id", null: false + t.integer "status" + t.integer "num_nodes", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.text "status_reason" + t.string "gcp_project_id", null: false + t.string "zone", null: false + t.string "machine_type" + t.string "operation_id" + t.string "endpoint" + t.text "encrypted_access_token" + t.string "encrypted_access_token_iv" + t.index ["cluster_id"], name: "index_cluster_providers_gcp_on_cluster_id", unique: true, using: :btree + end + create_table "clusters", id: :serial do |t| + t.integer "user_id" + t.integer "provider_type" + t.integer "platform_type" + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.boolean "enabled", default: true + t.string "name", null: false + t.string "environment_scope", default: "*", null: false + t.index ["enabled"], name: "index_clusters_on_enabled", using: :btree + t.index ["user_id"], name: "index_clusters_on_user_id", using: :btree + end + create_table "clusters_applications_helm", id: :serial do |t| + t.integer "cluster_id", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.integer "status", null: false + t.string "version", null: false + t.text "status_reason" + end + create_table "clusters_applications_ingress", id: :serial do |t| + t.integer "cluster_id", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.integer "status", null: false + t.integer "ingress_type", null: false + t.string "version", null: false + t.string "cluster_ip" + t.text "status_reason" + end + create_table "clusters_applications_prometheus", id: :serial do |t| + t.integer "cluster_id", null: false + t.integer "status", null: false + t.string "version", null: false + t.text "status_reason" + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + end + create_table "container_repositories", id: :serial do |t| + t.integer "project_id", null: false + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["project_id", "name"], name: "index_container_repositories_on_project_id_and_name", unique: true, using: :btree + t.index ["project_id"], name: "index_container_repositories_on_project_id", using: :btree + end + create_table "conversational_development_index_metrics", id: :serial do |t| + t.float "leader_issues", null: false + t.float "instance_issues", null: false + t.float "leader_notes", null: false + t.float "instance_notes", null: false + t.float "leader_milestones", null: false + t.float "instance_milestones", null: false + t.float "leader_boards", null: false + t.float "instance_boards", null: false + t.float "leader_merge_requests", null: false + t.float "instance_merge_requests", null: false + t.float "leader_ci_pipelines", null: false + t.float "instance_ci_pipelines", null: false + t.float "leader_environments", null: false + t.float "instance_environments", null: false + t.float "leader_deployments", null: false + t.float "instance_deployments", null: false + t.float "leader_projects_prometheus_active", null: false + t.float "instance_projects_prometheus_active", null: false + t.float "leader_service_desk_issues", null: false + t.float "instance_service_desk_issues", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.float "percentage_boards", default: 0.0, null: false + t.float "percentage_ci_pipelines", default: 0.0, null: false + t.float "percentage_deployments", default: 0.0, null: false + t.float "percentage_environments", default: 0.0, null: false + t.float "percentage_issues", default: 0.0, null: false + t.float "percentage_merge_requests", default: 0.0, null: false + t.float "percentage_milestones", default: 0.0, null: false + t.float "percentage_notes", default: 0.0, null: false + t.float "percentage_projects_prometheus_active", default: 0.0, null: false + t.float "percentage_service_desk_issues", default: 0.0, null: false + end + create_table "deploy_keys_projects", id: :serial do |t| + t.integer "deploy_key_id", null: false + t.integer "project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "can_push", default: false, null: false + t.index ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree + end + create_table "deployments", id: :serial do |t| + t.integer "iid", null: false + t.integer "project_id", null: false + t.integer "environment_id", null: false + t.string "ref", null: false + t.boolean "tag", null: false + t.string "sha", null: false + t.integer "user_id" + t.integer "deployable_id" + t.string "deployable_type" + t.datetime "created_at" + t.datetime "updated_at" + t.string "on_stop" + t.index ["created_at"], name: "index_deployments_on_created_at", using: :btree + t.index ["environment_id", "id"], name: "index_deployments_on_environment_id_and_id", using: :btree + t.index ["environment_id", "iid", "project_id"], name: "index_deployments_on_environment_id_and_iid_and_project_id", using: :btree + t.index ["project_id", "iid"], name: "index_deployments_on_project_id_and_iid", unique: true, using: :btree + end + create_table "emails", id: :serial do |t| + t.integer "user_id", null: false + t.string "email", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "confirmation_token" + t.datetime_with_timezone "confirmed_at" + t.datetime_with_timezone "confirmation_sent_at" + t.index ["confirmation_token"], name: "index_emails_on_confirmation_token", unique: true, using: :btree + t.index ["email"], name: "index_emails_on_email", unique: true, using: :btree + t.index ["user_id"], name: "index_emails_on_user_id", using: :btree + end + create_table "environments", id: :serial do |t| + t.integer "project_id", null: false + t.string "name", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "external_url" + t.string "environment_type" + t.string "state", default: "available", null: false + t.string "slug", null: false + t.index ["project_id", "name"], name: "index_environments_on_project_id_and_name", unique: true, using: :btree + t.index ["project_id", "slug"], name: "index_environments_on_project_id_and_slug", unique: true, using: :btree + end + create_table "events", id: :serial do |t| + 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.integer "action", limit: 2, null: false + t.string "target_type" + t.index ["action"], name: "index_events_on_action", using: :btree + t.index ["author_id"], name: "index_events_on_author_id", using: :btree + t.index ["project_id", "id"], name: "index_events_on_project_id_and_id", using: :btree + t.index ["target_type", "target_id"], name: "index_events_on_target_type_and_target_id", using: :btree + end + create_table "feature_gates", id: :serial do |t| + t.string "feature_key", null: false + t.string "key", null: false + t.string "value" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["feature_key", "key", "value"], name: "index_feature_gates_on_feature_key_and_key_and_value", unique: true, using: :btree + end + create_table "features", id: :serial do |t| + t.string "key", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["key"], name: "index_features_on_key", unique: true, using: :btree + end + create_table "fork_network_members", id: :serial do |t| + t.integer "fork_network_id", null: false + t.integer "project_id", null: false + t.integer "forked_from_project_id" + t.index ["fork_network_id"], name: "index_fork_network_members_on_fork_network_id", using: :btree + t.index ["project_id"], name: "index_fork_network_members_on_project_id", unique: true, using: :btree + end + create_table "fork_networks", id: :serial do |t| + t.integer "root_project_id" + t.string "deleted_root_project_name" + t.index ["root_project_id"], name: "index_fork_networks_on_root_project_id", unique: true, using: :btree + end + create_table "forked_project_links", id: :serial do |t| + t.integer "forked_to_project_id", null: false + t.integer "forked_from_project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.index ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree + end + create_table "gcp_clusters", id: :serial do |t| + t.integer "project_id", null: false + t.integer "user_id" + t.integer "service_id" + 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" + t.text "ca_cert" + t.text "encrypted_kubernetes_token" + t.string "encrypted_kubernetes_token_iv" + t.string "username" + t.text "encrypted_password" + t.string "encrypted_password_iv" + t.string "gcp_project_id", null: false + t.string "gcp_cluster_zone", null: false + t.string "gcp_cluster_name", null: false + t.string "gcp_machine_type" + t.string "gcp_operation_id" + t.text "encrypted_gcp_token" + t.string "encrypted_gcp_token_iv" + t.index ["project_id"], name: "index_gcp_clusters_on_project_id", unique: true, using: :btree + end + create_table "gpg_key_subkeys", id: :serial do |t| + t.integer "gpg_key_id", null: false + t.binary "keyid" + t.binary "fingerprint" + t.index ["fingerprint"], name: "index_gpg_key_subkeys_on_fingerprint", unique: true, using: :btree + t.index ["gpg_key_id"], name: "index_gpg_key_subkeys_on_gpg_key_id", using: :btree + t.index ["keyid"], name: "index_gpg_key_subkeys_on_keyid", unique: true, using: :btree + end + create_table "gpg_keys", id: :serial do |t| + 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" + t.text "key" + t.index ["fingerprint"], name: "index_gpg_keys_on_fingerprint", unique: true, using: :btree + t.index ["primary_keyid"], name: "index_gpg_keys_on_primary_keyid", unique: true, using: :btree + t.index ["user_id"], name: "index_gpg_keys_on_user_id", using: :btree + end + create_table "gpg_signatures", id: :serial do |t| + 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" + t.binary "gpg_key_primary_keyid" + 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" + t.index ["commit_sha"], name: "index_gpg_signatures_on_commit_sha", unique: true, using: :btree + t.index ["gpg_key_id"], name: "index_gpg_signatures_on_gpg_key_id", using: :btree + t.index ["gpg_key_primary_keyid"], name: "index_gpg_signatures_on_gpg_key_primary_keyid", using: :btree + t.index ["gpg_key_subkey_id"], name: "index_gpg_signatures_on_gpg_key_subkey_id", using: :btree + t.index ["project_id"], name: "index_gpg_signatures_on_project_id", using: :btree + end + create_table "group_custom_attributes", id: :serial do |t| + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.integer "group_id", null: false + t.string "key", null: false + t.string "value", null: false + t.index ["group_id", "key"], name: "index_group_custom_attributes_on_group_id_and_key", unique: true, using: :btree + t.index ["key", "value"], name: "index_group_custom_attributes_on_key_and_value", using: :btree + end + create_table "identities", id: :serial do |t| + t.string "extern_uid" + t.string "provider" + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + t.index ["user_id"], name: "index_identities_on_user_id", using: :btree + end + create_table "issue_assignees", id: false do |t| + t.integer "user_id", null: false + t.integer "issue_id", null: false + t.index ["issue_id", "user_id"], name: "index_issue_assignees_on_issue_id_and_user_id", unique: true, using: :btree + t.index ["user_id"], name: "index_issue_assignees_on_user_id", using: :btree + end + create_table "issue_metrics", id: :serial do |t| + t.integer "issue_id", null: false + t.datetime "first_mentioned_in_commit_at" + t.datetime "first_associated_with_milestone_at" + t.datetime "first_added_to_board_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["issue_id"], name: "index_issue_metrics", using: :btree + end + create_table "issues", id: :serial do |t| + t.string "title" + t.integer "author_id" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.text "description" + t.integer "milestone_id" + t.string "state" + t.integer "iid" + t.integer "updated_by_id" + t.boolean "confidential", default: false, null: false + t.date "due_date" + t.integer "moved_to_id" + t.integer "lock_version" + t.text "title_html" + t.text "description_html" + t.integer "time_estimate" + t.integer "relative_position" + t.integer "cached_markdown_version" + t.datetime "last_edited_at" + t.integer "last_edited_by_id" + t.boolean "discussion_locked" + t.datetime_with_timezone "closed_at" + t.index ["author_id"], name: "index_issues_on_author_id", using: :btree + t.index ["confidential"], name: "index_issues_on_confidential", using: :btree + t.index ["description"], name: "index_issues_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"} + t.index ["milestone_id"], name: "index_issues_on_milestone_id", using: :btree + t.index ["moved_to_id"], name: "index_issues_on_moved_to_id", where: "(moved_to_id IS NOT NULL)", using: :btree + t.index ["project_id", "created_at", "id", "state"], name: "index_issues_on_project_id_and_created_at_and_id_and_state", using: :btree + t.index ["project_id", "due_date", "id", "state"], name: "idx_issues_on_project_id_and_due_date_and_id_and_state_partial", where: "(due_date IS NOT NULL)", using: :btree + t.index ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree + t.index ["project_id", "updated_at", "id", "state"], name: "index_issues_on_project_id_and_updated_at_and_id_and_state", using: :btree + t.index ["relative_position"], name: "index_issues_on_relative_position", using: :btree + t.index ["state"], name: "index_issues_on_state", using: :btree + t.index ["title"], name: "index_issues_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"} + t.index ["updated_by_id"], name: "index_issues_on_updated_by_id", where: "(updated_by_id IS NOT NULL)", using: :btree + end + create_table "keys", id: :serial do |t| + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + t.text "key" + t.string "title" + t.string "type" + t.string "fingerprint" + t.boolean "public", default: false, null: false + t.datetime "last_used_at" + t.index ["fingerprint"], name: "index_keys_on_fingerprint", unique: true, using: :btree + t.index ["user_id"], name: "index_keys_on_user_id", using: :btree + end + create_table "label_links", id: :serial do |t| + t.integer "label_id" + t.integer "target_id" + t.string "target_type" + t.datetime "created_at" + t.datetime "updated_at" + t.index ["label_id"], name: "index_label_links_on_label_id", using: :btree + t.index ["target_id", "target_type"], name: "index_label_links_on_target_id_and_target_type", using: :btree + end + create_table "label_priorities", id: :serial do |t| + t.integer "project_id", null: false + t.integer "label_id", null: false + t.integer "priority", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["priority"], name: "index_label_priorities_on_priority", using: :btree + t.index ["project_id", "label_id"], name: "index_label_priorities_on_project_id_and_label_id", unique: true, using: :btree + end + create_table "labels", id: :serial do |t| + t.string "title" + t.string "color" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "template", default: false + t.string "description" + t.text "description_html" + t.string "type" + t.integer "group_id" + t.integer "cached_markdown_version" + t.index ["group_id", "project_id", "title"], name: "index_labels_on_group_id_and_project_id_and_title", unique: true, using: :btree + t.index ["project_id"], name: "index_labels_on_project_id", using: :btree + t.index ["template"], name: "index_labels_on_template", where: "template", using: :btree + t.index ["title"], name: "index_labels_on_title", using: :btree + t.index ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree + end + create_table "lfs_objects", id: :serial do |t| + t.string "oid", null: false + t.bigint "size", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "file" + t.integer "file_store" + t.index ["oid"], name: "index_lfs_objects_on_oid", unique: true, using: :btree + end + create_table "lfs_objects_projects", id: :serial do |t| + t.integer "lfs_object_id", null: false + t.integer "project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.index ["project_id"], name: "index_lfs_objects_projects_on_project_id", using: :btree + end + create_table "lists", id: :serial do |t| + t.integer "board_id", null: false + t.integer "label_id" + t.integer "list_type", default: 1, null: false + t.integer "position" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["board_id", "label_id"], name: "index_lists_on_board_id_and_label_id", unique: true, using: :btree + t.index ["label_id"], name: "index_lists_on_label_id", using: :btree + end + create_table "members", id: :serial do |t| + t.integer "access_level", null: false + t.integer "source_id", null: false + t.string "source_type", null: false + t.integer "user_id" + t.integer "notification_level", null: false + t.string "type" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "created_by_id" + t.string "invite_email" + t.string "invite_token" + t.datetime "invite_accepted_at" + t.datetime "requested_at" + t.date "expires_at" + t.index ["access_level"], name: "index_members_on_access_level", using: :btree + t.index ["invite_token"], name: "index_members_on_invite_token", unique: true, using: :btree + t.index ["requested_at"], name: "index_members_on_requested_at", using: :btree + t.index ["source_id", "source_type"], name: "index_members_on_source_id_and_source_type", using: :btree + t.index ["user_id"], name: "index_members_on_user_id", using: :btree + end + create_table "merge_request_diff_commits", id: false do |t| + 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 + t.text "author_name" + t.text "author_email" + t.text "committer_name" + t.text "committer_email" + t.text "message" + t.index ["merge_request_diff_id", "relative_order"], name: "index_merge_request_diff_commits_on_mr_diff_id_and_order", unique: true, using: :btree + t.index ["sha"], name: "index_merge_request_diff_commits_on_sha", using: :btree + end + create_table "merge_request_diff_files", id: false do |t| + t.integer "merge_request_diff_id", null: false + t.integer "relative_order", null: false + t.boolean "new_file", null: false + t.boolean "renamed_file", null: false + t.boolean "deleted_file", null: false + t.boolean "too_large", null: false + t.string "a_mode", null: false + t.string "b_mode", null: false + t.text "new_path", null: false + t.text "old_path", null: false + t.text "diff", null: false + t.boolean "binary" + t.index ["merge_request_diff_id", "relative_order"], name: "index_merge_request_diff_files_on_mr_diff_id_and_order", unique: true, using: :btree + end + create_table "merge_request_diffs", id: :serial do |t| + t.string "state" + t.integer "merge_request_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "base_commit_sha" + t.string "real_size" + t.string "head_commit_sha" + t.string "start_commit_sha" + t.index ["merge_request_id", "id"], name: "index_merge_request_diffs_on_merge_request_id_and_id", using: :btree + end + create_table "merge_request_metrics", id: :serial do |t| + t.integer "merge_request_id", null: false + t.datetime "latest_build_started_at" + t.datetime "latest_build_finished_at" + t.datetime "first_deployed_to_production_at" + t.datetime "merged_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "pipeline_id" + t.integer "merged_by_id" + t.integer "latest_closed_by_id" + t.datetime_with_timezone "latest_closed_at" + t.index ["first_deployed_to_production_at"], name: "index_merge_request_metrics_on_first_deployed_to_production_at", using: :btree + t.index ["merge_request_id"], name: "index_merge_request_metrics", using: :btree + t.index ["pipeline_id"], name: "index_merge_request_metrics_on_pipeline_id", using: :btree + end + create_table "merge_requests", id: :serial do |t| + t.string "target_branch", null: false + t.string "source_branch", null: false + t.integer "source_project_id" + t.integer "author_id" + t.integer "assignee_id" + t.string "title" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "milestone_id" + t.string "state", default: "opened", null: false + t.string "merge_status", default: "unchecked", null: false + t.integer "target_project_id", null: false + t.integer "iid" + t.text "description" + t.integer "updated_by_id" + t.text "merge_error" + t.text "merge_params" + t.boolean "merge_when_pipeline_succeeds", default: false, null: false + t.integer "merge_user_id" + t.string "merge_commit_sha" + t.string "rebase_commit_sha" + t.string "in_progress_merge_commit_sha" + t.integer "lock_version" + t.text "title_html" + t.text "description_html" + t.integer "time_estimate" + t.integer "cached_markdown_version" + t.datetime "last_edited_at" + t.integer "last_edited_by_id" + t.integer "head_pipeline_id" + t.string "merge_jid" + t.boolean "discussion_locked" + t.integer "latest_merge_request_diff_id" + t.index ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree + t.index ["author_id"], name: "index_merge_requests_on_author_id", using: :btree + t.index ["created_at"], name: "index_merge_requests_on_created_at", using: :btree + t.index ["description"], name: "index_merge_requests_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"} + t.index ["head_pipeline_id"], name: "index_merge_requests_on_head_pipeline_id", using: :btree + t.index ["latest_merge_request_diff_id"], name: "index_merge_requests_on_latest_merge_request_diff_id", using: :btree + t.index ["merge_user_id"], name: "index_merge_requests_on_merge_user_id", where: "(merge_user_id IS NOT NULL)", using: :btree + t.index ["milestone_id"], name: "index_merge_requests_on_milestone_id", using: :btree + t.index ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree + t.index ["source_project_id", "source_branch"], name: "index_merge_requests_on_source_project_and_branch_state_opened", where: "((state)::text = 'opened'::text)", using: :btree + t.index ["source_project_id", "source_branch"], name: "index_merge_requests_on_source_project_id_and_source_branch", using: :btree + t.index ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree + t.index ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid", unique: true, using: :btree + t.index ["target_project_id", "merge_commit_sha", "id"], name: "index_merge_requests_on_tp_id_and_merge_commit_sha_and_id", using: :btree + t.index ["title"], name: "index_merge_requests_on_title", using: :btree + t.index ["title"], name: "index_merge_requests_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"} + t.index ["updated_by_id"], name: "index_merge_requests_on_updated_by_id", where: "(updated_by_id IS NOT NULL)", using: :btree + end + create_table "merge_requests_closing_issues", id: :serial do |t| + t.integer "merge_request_id", null: false + t.integer "issue_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["issue_id"], name: "index_merge_requests_closing_issues_on_issue_id", using: :btree + t.index ["merge_request_id"], name: "index_merge_requests_closing_issues_on_merge_request_id", using: :btree + end + create_table "milestones", id: :serial do |t| + t.string "title", null: false + t.integer "project_id" + t.text "description" + t.date "due_date" + t.datetime "created_at" + t.datetime "updated_at" + t.string "state" + t.integer "iid" + t.text "title_html" + t.text "description_html" + t.date "start_date" + t.integer "cached_markdown_version" + t.integer "group_id" + t.index ["description"], name: "index_milestones_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"} + t.index ["due_date"], name: "index_milestones_on_due_date", using: :btree + t.index ["group_id"], name: "index_milestones_on_group_id", using: :btree + t.index ["project_id", "iid"], name: "index_milestones_on_project_id_and_iid", unique: true, using: :btree + t.index ["title"], name: "index_milestones_on_title", using: :btree + t.index ["title"], name: "index_milestones_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"} + end + create_table "namespaces", id: :serial do |t| + t.string "name", null: false + t.string "path", null: false + t.integer "owner_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "type" + t.string "description", default: "", null: false + t.string "avatar" + t.boolean "share_with_group_lock", default: false + t.integer "visibility_level", default: 20, null: false + t.boolean "request_access_enabled", default: false, null: false + t.text "description_html" + t.boolean "lfs_enabled" + t.integer "parent_id" + t.boolean "require_two_factor_authentication", default: false, null: false + t.integer "two_factor_grace_period", default: 48, null: false + t.integer "cached_markdown_version" + t.string "runners_token" + t.index ["created_at"], name: "index_namespaces_on_created_at", using: :btree + t.index ["name", "parent_id"], name: "index_namespaces_on_name_and_parent_id", unique: true, using: :btree + t.index ["name"], name: "index_namespaces_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} + t.index ["owner_id"], name: "index_namespaces_on_owner_id", using: :btree + t.index ["parent_id", "id"], name: "index_namespaces_on_parent_id_and_id", unique: true, using: :btree + t.index ["path"], name: "index_namespaces_on_path", using: :btree + t.index ["path"], name: "index_namespaces_on_path_trigram", using: :gin, opclasses: {"path"=>"gin_trgm_ops"} + t.index ["require_two_factor_authentication"], name: "index_namespaces_on_require_two_factor_authentication", using: :btree + t.index ["type"], name: "index_namespaces_on_type", using: :btree + end + create_table "notes", id: :serial do |t| + t.text "note" + t.string "noteable_type" + t.integer "author_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "project_id" + t.string "attachment" + t.string "line_code" + t.string "commit_id" + t.integer "noteable_id" + t.boolean "system", default: false, null: false + t.text "st_diff" + t.integer "updated_by_id" + t.string "type" + t.text "position" + t.text "original_position" + t.datetime "resolved_at" + t.integer "resolved_by_id" + t.string "discussion_id" + t.text "note_html" + t.integer "cached_markdown_version" + t.text "change_position" + t.boolean "resolved_by_push" + t.index ["author_id"], name: "index_notes_on_author_id", using: :btree + t.index ["commit_id"], name: "index_notes_on_commit_id", using: :btree + t.index ["created_at"], name: "index_notes_on_created_at", using: :btree + t.index ["discussion_id"], name: "index_notes_on_discussion_id", using: :btree + t.index ["line_code"], name: "index_notes_on_line_code", using: :btree + t.index ["note"], name: "index_notes_on_note_trigram", using: :gin, opclasses: {"note"=>"gin_trgm_ops"} + t.index ["noteable_id", "noteable_type"], name: "index_notes_on_noteable_id_and_noteable_type", using: :btree + t.index ["noteable_type"], name: "index_notes_on_noteable_type", using: :btree + t.index ["project_id", "noteable_type"], name: "index_notes_on_project_id_and_noteable_type", using: :btree + t.index ["updated_at"], name: "index_notes_on_updated_at", using: :btree + end + create_table "notification_settings", id: :serial do |t| + t.integer "user_id", null: false + t.string "source_type" + t.integer "source_id" + t.integer "level", default: 0, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "new_note" + t.boolean "new_issue" + t.boolean "reopen_issue" + t.boolean "close_issue" + t.boolean "reassign_issue" + t.boolean "new_merge_request" + t.boolean "reopen_merge_request" + t.boolean "close_merge_request" + t.boolean "reassign_merge_request" + t.boolean "merge_merge_request" + t.boolean "failed_pipeline" + t.boolean "success_pipeline" + t.index ["source_id", "source_type"], name: "index_notification_settings_on_source_id_and_source_type", using: :btree + t.index ["user_id", "source_id", "source_type"], name: "index_notifications_on_user_id_and_source_id_and_source_type", unique: true, using: :btree + t.index ["user_id"], name: "index_notification_settings_on_user_id", using: :btree + end + create_table "oauth_access_grants", id: :serial do |t| + t.integer "resource_owner_id", null: false + t.integer "application_id", null: false + t.string "token", null: false + t.integer "expires_in", null: false + t.text "redirect_uri", null: false + t.datetime "created_at", null: false + t.datetime "revoked_at" + t.string "scopes" + t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree + end + create_table "oauth_access_tokens", id: :serial do |t| + t.integer "resource_owner_id" + t.integer "application_id" + t.string "token", null: false + t.string "refresh_token" + t.integer "expires_in" + t.datetime "revoked_at" + t.datetime "created_at", null: false + t.string "scopes" + t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree + t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", using: :btree + t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree + end + create_table "oauth_applications", id: :serial do |t| + t.string "name", null: false + t.string "uid", null: false + t.string "secret", null: false + t.text "redirect_uri", null: false + t.string "scopes", default: "", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "owner_id" + t.string "owner_type" + t.boolean "trusted", default: false, null: false + t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree + t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree + end + create_table "oauth_openid_requests", id: :serial do |t| + t.integer "access_grant_id", null: false + t.string "nonce", null: false + end + create_table "pages_domains", id: :serial do |t| + t.integer "project_id" + t.text "certificate" + t.text "encrypted_key" + t.string "encrypted_key_iv" + t.string "encrypted_key_salt" + t.string "domain" + t.index ["domain"], name: "index_pages_domains_on_domain", unique: true, using: :btree + t.index ["project_id"], name: "index_pages_domains_on_project_id", using: :btree + end + create_table "personal_access_tokens", id: :serial do |t| + t.integer "user_id", null: false + t.string "token", null: false + t.string "name", null: false + t.boolean "revoked", default: false + t.date "expires_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "scopes", default: "--- []\n", null: false + t.boolean "impersonation", default: false, null: false + t.index ["token"], name: "index_personal_access_tokens_on_token", unique: true, using: :btree + t.index ["user_id"], name: "index_personal_access_tokens_on_user_id", using: :btree + end + create_table "project_authorizations", id: false do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "access_level" + t.index ["project_id"], name: "index_project_authorizations_on_project_id", using: :btree + t.index ["user_id", "project_id", "access_level"], name: "index_project_authorizations_on_user_id_project_id_access_level", unique: true, using: :btree + end + create_table "project_auto_devops", id: :serial 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.boolean "enabled" + t.string "domain" + t.index ["project_id"], name: "index_project_auto_devops_on_project_id", unique: true, using: :btree + end + create_table "project_custom_attributes", id: :serial do |t| + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.integer "project_id", null: false + t.string "key", null: false + t.string "value", null: false + t.index ["key", "value"], name: "index_project_custom_attributes_on_key_and_value", using: :btree + t.index ["project_id", "key"], name: "index_project_custom_attributes_on_project_id_and_key", unique: true, using: :btree + end + create_table "project_features", id: :serial do |t| + t.integer "project_id" + t.integer "merge_requests_access_level" + t.integer "issues_access_level" + t.integer "wiki_access_level" + t.integer "snippets_access_level" + t.integer "builds_access_level" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "repository_access_level", default: 20, null: false + t.index ["project_id"], name: "index_project_features_on_project_id", using: :btree + end + create_table "project_group_links", id: :serial do |t| + t.integer "project_id", null: false + t.integer "group_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "group_access", default: 30, null: false + t.date "expires_at" + t.index ["group_id"], name: "index_project_group_links_on_group_id", using: :btree + t.index ["project_id"], name: "index_project_group_links_on_project_id", using: :btree + end + create_table "project_import_data", id: :serial do |t| + t.integer "project_id" + t.text "data" + t.text "encrypted_credentials" + t.string "encrypted_credentials_iv" + t.string "encrypted_credentials_salt" + t.index ["project_id"], name: "index_project_import_data_on_project_id", using: :btree + end + create_table "project_statistics", id: :serial do |t| + t.integer "project_id", null: false + t.integer "namespace_id", null: false + t.bigint "commit_count", default: 0, null: false + t.bigint "storage_size", default: 0, null: false + t.bigint "repository_size", default: 0, null: false + t.bigint "lfs_objects_size", default: 0, null: false + t.bigint "build_artifacts_size", default: 0, null: false + t.index ["namespace_id"], name: "index_project_statistics_on_namespace_id", using: :btree + t.index ["project_id"], name: "index_project_statistics_on_project_id", unique: true, using: :btree + end + create_table "projects", id: :serial do |t| + t.string "name" + t.string "path" + t.text "description" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "creator_id" + t.integer "namespace_id" + t.datetime "last_activity_at" + t.string "import_url" + t.integer "visibility_level", default: 0, null: false + t.boolean "archived", default: false, null: false + t.string "avatar" + t.string "import_status" + t.integer "star_count", default: 0, null: false + t.boolean "merge_requests_rebase_enabled", default: false, null: false + t.string "import_type" + t.string "import_source" + t.boolean "merge_requests_ff_only_enabled", default: false, null: false + t.text "import_error" + t.integer "ci_id" + t.boolean "shared_runners_enabled", default: true, null: false + t.string "runners_token" + t.string "build_coverage_regex" + t.boolean "build_allow_git_fetch", default: true, null: false + t.integer "build_timeout", default: 3600, null: false + t.boolean "pending_delete", default: false + t.boolean "public_builds", default: true, null: false + t.boolean "last_repository_check_failed" + t.datetime "last_repository_check_at" + t.boolean "container_registry_enabled" + t.boolean "only_allow_merge_if_pipeline_succeeds", default: false, null: false + t.boolean "has_external_issue_tracker" + t.string "repository_storage", default: "default", null: false + t.boolean "repository_read_only" + 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" + t.boolean "printing_merge_request_link_enabled", default: true, null: false + 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.integer "storage_version", limit: 2 + t.boolean "resolve_outdated_diff_discussions" + t.string "external_authorization_classification_label" + t.integer "jobs_cache_index" + t.index ["ci_id"], name: "index_projects_on_ci_id", using: :btree + t.index ["created_at"], name: "index_projects_on_created_at", using: :btree + t.index ["creator_id"], name: "index_projects_on_creator_id", using: :btree + t.index ["description"], name: "index_projects_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"} + t.index ["last_activity_at"], name: "index_projects_on_last_activity_at", using: :btree + t.index ["last_repository_check_failed"], name: "index_projects_on_last_repository_check_failed", using: :btree + t.index ["last_repository_updated_at"], name: "index_projects_on_last_repository_updated_at", using: :btree + t.index ["name"], name: "index_projects_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} + t.index ["namespace_id"], name: "index_projects_on_namespace_id", using: :btree + t.index ["path"], name: "index_projects_on_path", using: :btree + t.index ["path"], name: "index_projects_on_path_trigram", using: :gin, opclasses: {"path"=>"gin_trgm_ops"} + t.index ["pending_delete"], name: "index_projects_on_pending_delete", using: :btree + t.index ["repository_storage"], name: "index_projects_on_repository_storage", using: :btree + t.index ["runners_token"], name: "index_projects_on_runners_token", using: :btree + t.index ["star_count"], name: "index_projects_on_star_count", using: :btree + t.index ["visibility_level"], name: "index_projects_on_visibility_level", using: :btree + end + create_table "protected_branch_merge_access_levels", id: :serial do |t| + t.integer "protected_branch_id", null: false + t.integer "access_level", default: 40, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["protected_branch_id"], name: "index_protected_branch_merge_access", using: :btree + end + create_table "protected_branch_push_access_levels", id: :serial do |t| + t.integer "protected_branch_id", null: false + t.integer "access_level", default: 40, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["protected_branch_id"], name: "index_protected_branch_push_access", using: :btree + end + create_table "protected_branches", id: :serial do |t| + t.integer "project_id", null: false + t.string "name", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.index ["project_id"], name: "index_protected_branches_on_project_id", using: :btree + end + create_table "protected_tag_create_access_levels", id: :serial do |t| + t.integer "protected_tag_id", null: false + t.integer "access_level", default: 40 + t.integer "user_id" + t.integer "group_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["protected_tag_id"], name: "index_protected_tag_create_access", using: :btree + t.index ["user_id"], name: "index_protected_tag_create_access_levels_on_user_id", using: :btree + end + create_table "protected_tags", id: :serial do |t| + t.integer "project_id", null: false + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["project_id"], name: "index_protected_tags_on_project_id", using: :btree + end + create_table "push_event_payloads", id: false do |t| + t.bigint "commit_count", null: false + t.integer "event_id", null: false + t.integer "action", limit: 2, null: false + t.integer "ref_type", limit: 2, null: false + t.binary "commit_from" + t.binary "commit_to" + t.text "ref" + t.string "commit_title", limit: 70 + t.index ["event_id"], name: "index_push_event_payloads_on_event_id", unique: true, using: :btree + end + create_table "redirect_routes", id: :serial do |t| + t.integer "source_id", null: false + t.string "source_type", null: false + t.string "path", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "permanent" + t.index ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree + t.index ["path"], name: "index_redirect_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"} + t.index ["permanent"], name: "index_redirect_routes_on_permanent", using: :btree + t.index ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree + end + create_table "releases", id: :serial do |t| + t.string "tag" + t.text "description" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.text "description_html" + t.integer "cached_markdown_version" + t.index ["project_id", "tag"], name: "index_releases_on_project_id_and_tag", using: :btree + t.index ["project_id"], name: "index_releases_on_project_id", using: :btree + end + create_table "routes", id: :serial do |t| + t.integer "source_id", null: false + t.string "source_type", null: false + t.string "path", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "name" + t.index ["path"], name: "index_routes_on_path", unique: true, using: :btree + t.index ["path"], name: "index_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"} + t.index ["source_type", "source_id"], name: "index_routes_on_source_type_and_source_id", unique: true, using: :btree + end + create_table "sent_notifications", id: :serial do |t| + t.integer "project_id" + t.string "noteable_type" + t.integer "noteable_id" + t.integer "recipient_id" + t.string "commit_id" + t.string "reply_key", null: false + t.string "line_code" + t.string "note_type" + t.text "position" + t.string "in_reply_to_discussion_id" + t.index ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree + end + create_table "services", id: :serial do |t| + t.string "type" + t.string "title" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "active", default: false, null: false + t.text "properties" + t.boolean "template", default: false + t.boolean "push_events", default: true + t.boolean "issues_events", default: true + t.boolean "merge_requests_events", default: true + t.boolean "tag_push_events", default: true + t.boolean "note_events", default: true, null: false + t.string "category", default: "common", null: false + t.boolean "default", default: false + t.boolean "wiki_page_events", default: true + t.boolean "pipeline_events", default: false, null: false + 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.index ["project_id"], name: "index_services_on_project_id", using: :btree + t.index ["template"], name: "index_services_on_template", using: :btree + end + create_table "snippets", id: :serial do |t| + t.string "title" + t.text "content" + t.integer "author_id", null: false + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "file_name" + t.string "type" + t.integer "visibility_level", default: 0, null: false + t.text "title_html" + t.text "content_html" + t.integer "cached_markdown_version" + t.text "description" + t.text "description_html" + t.index ["author_id"], name: "index_snippets_on_author_id", using: :btree + t.index ["file_name"], name: "index_snippets_on_file_name_trigram", using: :gin, opclasses: {"file_name"=>"gin_trgm_ops"} + t.index ["project_id"], name: "index_snippets_on_project_id", using: :btree + t.index ["title"], name: "index_snippets_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"} + t.index ["updated_at"], name: "index_snippets_on_updated_at", using: :btree + t.index ["visibility_level"], name: "index_snippets_on_visibility_level", using: :btree + end + create_table "spam_logs", id: :serial do |t| + t.integer "user_id" + t.string "source_ip" + t.string "user_agent" + t.boolean "via_api" + t.string "noteable_type" + t.string "title" + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "submitted_as_ham", default: false, null: false + t.boolean "recaptcha_verified", default: false, null: false + end + create_table "subscriptions", id: :serial do |t| + t.integer "user_id" + t.string "subscribable_type" + t.integer "subscribable_id" + t.boolean "subscribed" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "project_id" + t.index ["subscribable_id", "subscribable_type", "user_id", "project_id"], name: "index_subscriptions_on_subscribable_and_user_id_and_project_id", unique: true, using: :btree + end + create_table "system_note_metadata", id: :serial do |t| + t.integer "note_id", null: false + t.integer "commit_count" + t.string "action" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["note_id"], name: "index_system_note_metadata_on_note_id", unique: true, using: :btree + end + create_table "taggings", id: :serial 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" + t.datetime "created_at" + t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree + t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree + end + create_table "tags", id: :serial do |t| + t.string "name" + t.integer "taggings_count", default: 0 + t.index ["name"], name: "index_tags_on_name", unique: true, using: :btree + end + create_table "timelogs", id: :serial do |t| + t.integer "time_spent", null: false + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "issue_id" + t.integer "merge_request_id" + t.datetime_with_timezone "spent_at" + t.index ["issue_id"], name: "index_timelogs_on_issue_id", using: :btree + t.index ["merge_request_id"], name: "index_timelogs_on_merge_request_id", using: :btree + t.index ["user_id"], name: "index_timelogs_on_user_id", using: :btree + end + create_table "todos", id: :serial do |t| + t.integer "user_id", null: false + t.integer "project_id", null: false + t.string "target_type", null: false + t.integer "target_id" + t.integer "author_id" + t.integer "action", null: false + t.string "state", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "note_id" + t.string "commit_id" + t.index ["author_id"], name: "index_todos_on_author_id", using: :btree + t.index ["commit_id"], name: "index_todos_on_commit_id", using: :btree + t.index ["note_id"], name: "index_todos_on_note_id", using: :btree + t.index ["project_id"], name: "index_todos_on_project_id", using: :btree + t.index ["target_type", "target_id"], name: "index_todos_on_target_type_and_target_id", using: :btree + t.index ["user_id"], name: "index_todos_on_user_id", using: :btree + end + create_table "trending_projects", id: :serial do |t| + t.integer "project_id", null: false + t.index ["project_id"], name: "index_trending_projects_on_project_id", using: :btree + end + create_table "u2f_registrations", id: :serial do |t| + t.text "certificate" + t.string "key_handle" + t.string "public_key" + t.integer "counter" + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "name" + t.index ["key_handle"], name: "index_u2f_registrations_on_key_handle", using: :btree + t.index ["user_id"], name: "index_u2f_registrations_on_user_id", using: :btree + end + create_table "uploads", id: :serial do |t| + t.bigint "size", null: false + t.string "path", limit: 511, null: false + t.string "checksum", limit: 64 + t.string "model_type" + t.integer "model_id" + t.string "uploader", null: false + t.datetime "created_at", null: false + t.integer "store" + t.index ["checksum"], name: "index_uploads_on_checksum", using: :btree + t.index ["model_id", "model_type"], name: "index_uploads_on_model_id_and_model_type", using: :btree + t.index ["path"], name: "index_uploads_on_path", using: :btree + end + create_table "user_agent_details", id: :serial do |t| + t.string "user_agent", null: false + t.string "ip_address", null: false + t.integer "subject_id", null: false + t.string "subject_type", null: false + t.boolean "submitted", default: false, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["subject_id", "subject_type"], name: "index_user_agent_details_on_subject_id_and_subject_type", using: :btree + end + create_table "user_custom_attributes", id: :serial do |t| + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.integer "user_id", null: false + t.string "key", null: false + t.string "value", null: false + t.index ["key", "value"], name: "index_user_custom_attributes_on_key_and_value", using: :btree + t.index ["user_id", "key"], name: "index_user_custom_attributes_on_user_id_and_key", unique: true, using: :btree + end + create_table "user_synced_attributes_metadata", id: :serial do |t| + t.boolean "name_synced", default: false + t.boolean "email_synced", default: false + t.boolean "location_synced", default: false + t.integer "user_id", null: false + t.string "provider" + t.index ["user_id"], name: "index_user_synced_attributes_metadata_on_user_id", unique: true, using: :btree + end + create_table "users", id: :serial do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", default: 0 + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.datetime "created_at" + t.datetime "updated_at" + t.string "name" + t.boolean "admin", default: false, null: false + t.integer "projects_limit", null: false + t.string "skype", default: "", null: false + t.string "linkedin", default: "", null: false + t.string "twitter", default: "", null: false + t.string "bio" + t.integer "failed_attempts", default: 0 + t.datetime "locked_at" + t.string "username" + t.boolean "can_create_group", default: true, null: false + t.boolean "can_create_team", default: true, null: false + t.string "state" + t.integer "color_scheme_id", default: 1, null: false + t.datetime "password_expires_at" + t.integer "created_by_id" + t.datetime "last_credential_check_at" + t.string "avatar" + t.string "confirmation_token" + t.datetime "confirmed_at" + t.datetime "confirmation_sent_at" + t.string "unconfirmed_email" + t.boolean "hide_no_ssh_key", default: false + t.string "website_url", default: "", null: false + t.string "notification_email" + t.boolean "hide_no_password", default: false + t.boolean "password_automatically_set", default: false + t.string "location" + t.string "encrypted_otp_secret" + t.string "encrypted_otp_secret_iv" + t.string "encrypted_otp_secret_salt" + t.boolean "otp_required_for_login", default: false, null: false + t.text "otp_backup_codes" + t.string "public_email", default: "", null: false + t.integer "dashboard", default: 0 + t.integer "project_view", default: 0 + t.integer "consumed_timestep" + t.integer "layout", default: 0 + t.boolean "hide_project_limit", default: false + t.string "unlock_token" + t.datetime "otp_grace_period_started_at" + t.boolean "external", default: false + t.string "incoming_email_token" + t.string "organization" + t.boolean "require_two_factor_authentication_from_group", default: false, null: false + t.integer "two_factor_grace_period", default: 48, null: false + t.boolean "ghost" + t.date "last_activity_on" + t.boolean "notified_of_own_activity" + t.string "preferred_language" + t.string "rss_token" + t.integer "theme_id", limit: 2 + t.index ["admin"], name: "index_users_on_admin", using: :btree + t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree + t.index ["created_at"], name: "index_users_on_created_at", using: :btree + t.index ["email"], name: "index_users_on_email", unique: true, using: :btree + t.index ["email"], name: "index_users_on_email_trigram", using: :gin, opclasses: {"email"=>"gin_trgm_ops"} + t.index ["ghost"], name: "index_users_on_ghost", using: :btree + t.index ["incoming_email_token"], name: "index_users_on_incoming_email_token", using: :btree + t.index ["name"], name: "index_users_on_name", using: :btree + t.index ["name"], name: "index_users_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} + t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + t.index ["rss_token"], name: "index_users_on_rss_token", using: :btree + t.index ["state"], name: "index_users_on_state", using: :btree + t.index ["username"], name: "index_users_on_username", using: :btree + t.index ["username"], name: "index_users_on_username_trigram", using: :gin, opclasses: {"username"=>"gin_trgm_ops"} + end + create_table "users_star_projects", id: :serial do |t| + t.integer "project_id", null: false + t.integer "user_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.index ["project_id"], name: "index_users_star_projects_on_project_id", using: :btree + t.index ["user_id", "project_id"], name: "index_users_star_projects_on_user_id_and_project_id", unique: true, using: :btree + end + create_table "web_hook_logs", id: :serial do |t| + t.integer "web_hook_id", null: false + t.string "trigger" + t.string "url" + t.text "request_headers" + t.text "request_data" + t.text "response_headers" + t.text "response_body" + t.string "response_status" + t.float "execution_duration" + t.string "internal_error_message" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["web_hook_id"], name: "index_web_hook_logs_on_web_hook_id", using: :btree + end + create_table "web_hooks", id: :serial do |t| + t.string "url", limit: 2000 + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "type", default: "ProjectHook" + t.integer "service_id" + t.boolean "push_events", default: true, null: false + t.boolean "issues_events", default: false, null: false + t.boolean "merge_requests_events", default: false, null: false + t.boolean "tag_push_events", default: false + t.boolean "note_events", default: false, null: false + t.boolean "enable_ssl_verification", default: true + t.boolean "wiki_page_events", default: false, null: false + t.string "token" + t.boolean "pipeline_events", default: false, null: false + 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" + t.index ["project_id"], name: "index_web_hooks_on_project_id", using: :btree + t.index ["type"], name: "index_web_hooks_on_type", using: :btree + end + add_foreign_key "boards", "projects", name: "fk_f15266b5f9", on_delete: :cascade + add_foreign_key "chat_teams", "namespaces", on_delete: :cascade + add_foreign_key "ci_build_trace_section_names", "projects", on_delete: :cascade + add_foreign_key "ci_build_trace_sections", "ci_build_trace_section_names", column: "section_name_id", name: "fk_264e112c66", on_delete: :cascade + add_foreign_key "ci_build_trace_sections", "ci_builds", column: "build_id", name: "fk_4ebe41f502", on_delete: :cascade + add_foreign_key "ci_build_trace_sections", "projects", on_delete: :cascade + 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_group_variables", "namespaces", column: "group_id", name: "fk_33ae4d58d8", on_delete: :cascade + add_foreign_key "ci_job_artifacts", "ci_builds", column: "job_id", on_delete: :cascade + add_foreign_key "ci_job_artifacts", "projects", 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 + add_foreign_key "ci_pipeline_schedules", "users", column: "owner_id", name: "fk_9ea99f58d2", on_delete: :nullify + add_foreign_key "ci_pipeline_variables", "ci_pipelines", column: "pipeline_id", name: "fk_f29c5f4380", on_delete: :cascade + add_foreign_key "ci_pipelines", "ci_pipeline_schedules", column: "pipeline_schedule_id", name: "fk_3d34ab2e06", on_delete: :nullify + add_foreign_key "ci_pipelines", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_262d4c2d19", on_delete: :nullify + add_foreign_key "ci_pipelines", "projects", name: "fk_86635dbd80", on_delete: :cascade + add_foreign_key "ci_runner_namespaces", "ci_runners", column: "runner_id", on_delete: :cascade + add_foreign_key "ci_runner_namespaces", "namespaces", on_delete: :cascade + add_foreign_key "ci_runner_projects", "projects", name: "fk_4478a6f1e4", on_delete: :cascade + add_foreign_key "ci_stages", "ci_pipelines", column: "pipeline_id", name: "fk_fb57e6cc56", on_delete: :cascade + add_foreign_key "ci_stages", "projects", name: "fk_2360681d1d", on_delete: :cascade + add_foreign_key "ci_trigger_requests", "ci_triggers", column: "trigger_id", name: "fk_b8ec8b7245", on_delete: :cascade + add_foreign_key "ci_triggers", "projects", name: "fk_e3e63f966e", on_delete: :cascade + add_foreign_key "ci_triggers", "users", column: "owner_id", name: "fk_e8e10d1964", on_delete: :cascade + add_foreign_key "ci_variables", "projects", name: "fk_ada5eb64b3", on_delete: :cascade + add_foreign_key "cluster_platforms_kubernetes", "clusters", on_delete: :cascade + add_foreign_key "cluster_projects", "clusters", on_delete: :cascade + add_foreign_key "cluster_projects", "projects", on_delete: :cascade + add_foreign_key "cluster_providers_gcp", "clusters", on_delete: :cascade + add_foreign_key "clusters", "users", on_delete: :nullify + add_foreign_key "clusters_applications_helm", "clusters", on_delete: :cascade + add_foreign_key "clusters_applications_ingress", "clusters", on_delete: :cascade + add_foreign_key "clusters_applications_prometheus", "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 "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 + add_foreign_key "events", "users", column: "author_id", name: "fk_edfd187b6f", on_delete: :cascade + add_foreign_key "fork_network_members", "fork_networks", on_delete: :cascade + add_foreign_key "fork_network_members", "projects", column: "forked_from_project_id", name: "fk_b01280dae4", on_delete: :nullify + add_foreign_key "fork_network_members", "projects", on_delete: :cascade + add_foreign_key "fork_networks", "projects", column: "root_project_id", name: "fk_e7b436b2b5", on_delete: :nullify + 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", on_delete: :nullify + add_foreign_key "gcp_clusters", "users", on_delete: :nullify + 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 "group_custom_attributes", "namespaces", column: "group_id", on_delete: :cascade + add_foreign_key "issue_assignees", "issues", name: "fk_b7d881734a", on_delete: :cascade + add_foreign_key "issue_assignees", "users", name: "fk_5e0c8d9154", on_delete: :cascade + add_foreign_key "issue_metrics", "issues", on_delete: :cascade + add_foreign_key "issues", "issues", column: "moved_to_id", name: "fk_a194299be1", on_delete: :nullify + 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: "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 + add_foreign_key "labels", "namespaces", column: "group_id", on_delete: :cascade + add_foreign_key "labels", "projects", name: "fk_7de4989a69", on_delete: :cascade + add_foreign_key "lists", "boards", name: "fk_0d3f677137", on_delete: :cascade + add_foreign_key "lists", "labels", name: "fk_7a5553d60f", on_delete: :cascade + add_foreign_key "members", "users", name: "fk_2e88fb7ce9", on_delete: :cascade + add_foreign_key "merge_request_diff_commits", "merge_request_diffs", on_delete: :cascade + add_foreign_key "merge_request_diff_files", "merge_request_diffs", on_delete: :cascade + add_foreign_key "merge_request_diffs", "merge_requests", name: "fk_8483f3258f", 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_request_metrics", "users", column: "latest_closed_by_id", name: "fk_ae440388cc", on_delete: :nullify + add_foreign_key "merge_request_metrics", "users", column: "merged_by_id", name: "fk_7f28d925f3", on_delete: :nullify + add_foreign_key "merge_requests", "ci_pipelines", column: "head_pipeline_id", name: "fk_fd82eae0b9", on_delete: :nullify + add_foreign_key "merge_requests", "merge_request_diffs", column: "latest_merge_request_diff_id", name: "fk_06067f5644", on_delete: :nullify + add_foreign_key "merge_requests", "milestones", name: "fk_6a5165a692", on_delete: :nullify + add_foreign_key "merge_requests", "projects", column: "source_project_id", name: "fk_3308fe130c", on_delete: :nullify + add_foreign_key "merge_requests", "projects", column: "target_project_id", name: "fk_a6963e8447", on_delete: :cascade + add_foreign_key "merge_requests", "users", column: "assignee_id", name: "fk_6149611a04", on_delete: :nullify + add_foreign_key "merge_requests", "users", column: "author_id", name: "fk_e719a85f8a", on_delete: :nullify + add_foreign_key "merge_requests", "users", column: "merge_user_id", name: "fk_ad525e1f87", on_delete: :nullify + add_foreign_key "merge_requests", "users", column: "updated_by_id", name: "fk_641731faff", on_delete: :nullify + add_foreign_key "merge_requests_closing_issues", "issues", on_delete: :cascade + add_foreign_key "merge_requests_closing_issues", "merge_requests", on_delete: :cascade + add_foreign_key "milestones", "namespaces", column: "group_id", name: "fk_95650a40d4", on_delete: :cascade + add_foreign_key "milestones", "projects", name: "fk_9bd0a0c791", on_delete: :cascade + add_foreign_key "notes", "projects", name: "fk_99e097b079", on_delete: :cascade + add_foreign_key "oauth_openid_requests", "oauth_access_grants", column: "access_grant_id", name: "fk_oauth_openid_requests_oauth_access_grants_access_grant_id" + add_foreign_key "pages_domains", "projects", name: "fk_ea2f6dfc6f", on_delete: :cascade + add_foreign_key "personal_access_tokens", "users" + add_foreign_key "project_authorizations", "projects", on_delete: :cascade + 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_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 + add_foreign_key "project_statistics", "projects", on_delete: :cascade + add_foreign_key "protected_branch_merge_access_levels", "protected_branches", name: "fk_8a3072ccb3", on_delete: :cascade + add_foreign_key "protected_branch_push_access_levels", "protected_branches", name: "fk_9ffc86a3d9", on_delete: :cascade + add_foreign_key "protected_branches", "projects", name: "fk_7a9c6d93e7", on_delete: :cascade + add_foreign_key "protected_tag_create_access_levels", "namespaces", column: "group_id" + add_foreign_key "protected_tag_create_access_levels", "protected_tags", name: "fk_f7dfda8c51", on_delete: :cascade + add_foreign_key "protected_tag_create_access_levels", "users" + add_foreign_key "protected_tags", "projects", name: "fk_8e4af87648", on_delete: :cascade + add_foreign_key "push_event_payloads", "events", name: "fk_36c74129da", on_delete: :cascade + add_foreign_key "releases", "projects", name: "fk_47fe2a0596", on_delete: :cascade + add_foreign_key "services", "projects", name: "fk_71cce407f9", on_delete: :cascade + add_foreign_key "snippets", "projects", name: "fk_be41fd4bb7", on_delete: :cascade + add_foreign_key "subscriptions", "projects", on_delete: :cascade + add_foreign_key "system_note_metadata", "notes", name: "fk_d83a918cb1", on_delete: :cascade + add_foreign_key "timelogs", "issues", name: "fk_timelogs_issues_issue_id", on_delete: :cascade + add_foreign_key "timelogs", "merge_requests", name: "fk_timelogs_merge_requests_merge_request_id", on_delete: :cascade + add_foreign_key "todos", "projects", name: "fk_45054f9c45", on_delete: :cascade + add_foreign_key "trending_projects", "projects", on_delete: :cascade + add_foreign_key "u2f_registrations", "users" + add_foreign_key "user_custom_attributes", "users", on_delete: :cascade + add_foreign_key "user_synced_attributes_metadata", "users", on_delete: :cascade + add_foreign_key "users_star_projects", "projects", name: "fk_22cd27ddfc", on_delete: :cascade + add_foreign_key "web_hook_logs", "web_hooks", on_delete: :cascade + add_foreign_key "web_hooks", "projects", name: "fk_0c8ca6d9d1", on_delete: :cascade + end + + def down + raise ActiveRecord::IrreversibleMigration, "The initial migration is not revertable" + end +end diff --git a/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb b/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb deleted file mode 100644 index 099814d7556..00000000000 --- a/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb +++ /dev/null @@ -1,19 +0,0 @@ -# The default needs to be `[]`, but all existing access tokens need to have `scopes` set to `['api']`. -# It's easier to achieve this by adding the column with the `['api']` default (regular migration), and -# then changing the default to `[]` (in this post-migration). -# -# Details: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5951#note_19721973 - -class ChangePersonalAccessTokensDefaultBackToEmptyArray < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - change_column_default :personal_access_tokens, :scopes, [].to_yaml - end - - def down - change_column_default :personal_access_tokens, :scopes, ['api'].to_yaml - end -end diff --git a/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb b/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb deleted file mode 100644 index bf3aee99418..00000000000 --- a/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb +++ /dev/null @@ -1,10 +0,0 @@ -class RemoveInactiveJiraServiceProperties < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = true - DOWNTIME_REASON = "Removes all inactive jira_service properties" - - def up - execute("UPDATE services SET properties = '{}' WHERE services.type = 'JiraService' and services.active = false") - end -end diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb deleted file mode 100644 index 6d9c7e4ed72..00000000000 --- a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb +++ /dev/null @@ -1,49 +0,0 @@ -class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - BATCH_SIZE = 500 - DOWNTIME = false - - # This migration is idempotent and there's no sense in throwing away the - # partial result if it's interrupted - disable_ddl_transaction! - - def up - projects = Arel::Table.new(:projects) - namespaces = Arel::Table.new(:namespaces) - - finder_sql = - projects - .join(namespaces, Arel::Nodes::InnerJoin) - .on(projects[:namespace_id].eq(namespaces[:id])) - .where(projects[:visibility_level].gt(namespaces[:visibility_level])) - .project(projects[:id], namespaces[:visibility_level]) - .take(BATCH_SIZE) - .to_sql - - # Update matching rows in batches. Each batch can cause up to 3 UPDATE - # statements, in addition to the SELECT: one per visibility_level - loop do - to_update = connection.exec_query(finder_sql) - break if to_update.rows.count == 0 - - # row[0] is projects.id, row[1] is namespaces.visibility_level - updates = to_update.rows.each_with_object(Hash.new {|h, k| h[k] = [] }) do |row, obj| - obj[row[1]] << row[0] - end - - updates.each do |visibility_level, project_ids| - updater = Arel::UpdateManager.new - .table(projects) - .set(projects[:visibility_level] => visibility_level) - .where(projects[:id].in(project_ids)) - - ActiveRecord::Base.connection.exec_update(updater.to_sql, self.class.name, []) - end - end - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20161128170531_drop_user_activities_table.rb b/db/post_migrate/20161128170531_drop_user_activities_table.rb deleted file mode 100644 index d8b1e0731f3..00000000000 --- a/db/post_migrate/20161128170531_drop_user_activities_table.rb +++ /dev/null @@ -1,33 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. -class DropUserActivitiesTable < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def up - drop_table :user_activities if table_exists?(:user_activities) - end - - def down - unless table_exists?(:user_activities) - create_table "user_activities", force: :cascade do |t| - t.integer "user_id" - t.datetime "last_activity_at", null: false - end - - add_index "user_activities", ["user_id"], name: "index_user_activities_on_user_id", unique: true, using: :btree - end - end -end diff --git a/db/post_migrate/20161221140236_remove_unneeded_services.rb b/db/post_migrate/20161221140236_remove_unneeded_services.rb deleted file mode 100644 index 31f24263877..00000000000 --- a/db/post_migrate/20161221140236_remove_unneeded_services.rb +++ /dev/null @@ -1,15 +0,0 @@ -class RemoveUnneededServices < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - disable_statement_timeout - - execute("DELETE FROM services WHERE active = false AND properties = '{}';") - end - - def down - # noop - end -end diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb deleted file mode 100644 index 32579256299..00000000000 --- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb +++ /dev/null @@ -1,137 +0,0 @@ -class RenameReservedProjectNames < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - THREAD_COUNT = 8 - - KNOWN_PATHS = %w(.well-known - all - blame - blob - commits - create - create_dir - edit - files - find_file - groups - hooks - issues - logs_tree - merge_requests - new - preview - projects - raw - repository - robots.txt - s - snippets - teams - tree - u - unsubscribes - update - users - wikis).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 - end - - start = true - - threads.each(&:join) - end - - def down - # nothing to do here - end - - private - - def reserved_projects - Project.unscoped - .includes(:namespace) - .where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)') - .where('projects.path' => KNOWN_PATHS) - end - - def route_exists?(full_path) - quoted_path = ActiveRecord::Base.connection.quote_string(full_path) - - ActiveRecord::Base.connection - .select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? - end - - # Adds number to the end of the path that is not taken by other route - def rename_path(namespace_path, path_was) - counter = 0 - path = "#{path_was}#{counter}" - - while route_exists?("#{namespace_path}/#{path}") - counter += 1 - path = "#{path_was}#{counter}" - end - - path - end - - def rename_projects(projects) - projects.each do |project| - id = project.id - path_was = project.path - namespace_path = project.namespace.path - path = rename_path(namespace_path, path_was) - - begin - # Because project path update is quite complex operation we can't safely - # copy-paste all code from GitLab. As exception we use Rails code here - if rename_project_row(project, path) - after_rename_service(project, path_was, namespace_path).execute - end - rescue Exception => e # rubocop: disable Lint/RescueException - Rails.logger.error "Exception when renaming project #{id}: #{e.message}" - end - end - end - - def rename_project_row(project, path) - project.respond_to?(:update_attributes) && - project.update(path: path) && - defined?(Projects::AfterRenameService) - end - - def after_rename_service(project, path_was, namespace_path) - AfterRenameService.new( - project, - path_before: path_was, - full_path_before: "#{namespace_path}/#{path_was}" - ).execute - end -end diff --git a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb deleted file mode 100644 index f567accb051..00000000000 --- a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb +++ /dev/null @@ -1,49 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RequeuePendingDeleteProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - admin = User.find_by(admin: true) - return unless admin - - @offset = 0 - - loop do - ids = pending_delete_batch - - break if ids.rows.count.zero? - - args = ids.map { |id| [id['id'], admin.id, {}] } - - Sidekiq::Client.push_bulk('class' => "ProjectDestroyWorker", 'args' => args) - - @offset += 1 - end - end - - def down - # noop - end - - private - - def pending_delete_batch - connection.exec_query(find_batch) - end - - BATCH_SIZE = 5000 - - def find_batch - projects = Arel::Table.new(:projects) - projects.project(projects[:id]) - .where(projects[:pending_delete].eq(true)) - .where(projects[:namespace_id].not_eq(nil)) - .skip(@offset * BATCH_SIZE) - .take(BATCH_SIZE) - .to_sql - end -end diff --git a/db/post_migrate/20170106142508_fill_authorized_projects.rb b/db/post_migrate/20170106142508_fill_authorized_projects.rb deleted file mode 100644 index 1f1dd0f47f0..00000000000 --- a/db/post_migrate/20170106142508_fill_authorized_projects.rb +++ /dev/null @@ -1,30 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class FillAuthorizedProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - class User < ActiveRecord::Base - self.table_name = 'users' - end - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - # We're not inserting any data so we don't need to start a transaction. - disable_ddl_transaction! - - def up - relation = User.select(:id) - .where('authorized_projects_populated IS NOT TRUE') - - relation.find_in_batches(batch_size: 1_000) do |rows| - args = rows.map { |row| [row.id] } - - Sidekiq::Client.push_bulk('class' => 'AuthorizedProjectsWorker', 'args' => args) - end - end - - def down - end -end diff --git a/db/post_migrate/20170106172224_remove_project_authorizations_id_column.rb b/db/post_migrate/20170106172224_remove_project_authorizations_id_column.rb deleted file mode 100644 index 893af23465a..00000000000 --- a/db/post_migrate/20170106172224_remove_project_authorizations_id_column.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveProjectAuthorizationsIdColumn < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - remove_column :project_authorizations, :id, :primary_key - end -end diff --git a/db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb b/db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb deleted file mode 100644 index 055a14ad729..00000000000 --- a/db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb +++ /dev/null @@ -1,18 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -# rubocop:disable Migration/UpdateColumnInBatches -class ResetUsersAuthorizedProjectsPopulated < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - # This ensures we don't lock all users for the duration of the migration. - update_column_in_batches(:users, :authorized_projects_populated, nil) - end - - def down - # noop - end -end diff --git a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb deleted file mode 100644 index f221dac8e20..00000000000 --- a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb +++ /dev/null @@ -1,41 +0,0 @@ -class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - Gitlab::Database.with_connection_pool(2) do |pool| - threads = [] - - threads << Thread.new do - pool.with_connection do |connection| - connection.execute <<-SQL.strip_heredoc - DELETE FROM services - WHERE type = 'BuildsEmailService' - AND active IS FALSE - AND properties = '{"notify_only_broken_builds":true}'; - SQL - end - end - - threads << Thread.new do - pool.with_connection do |connection| - connection.execute <<-SQL.strip_heredoc - DELETE FROM services - WHERE type = 'PipelinesEmailService' - AND active IS FALSE - AND properties = '{"notify_only_broken_pipelines":true}'; - SQL - end - end - - threads.each(&:join) - end - end - - def down - # Nothing can be done to restore the records - 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 deleted file mode 100644 index 14f5d0d4add..00000000000 --- a/db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb +++ /dev/null @@ -1,24 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveTrackableColumnsFromTimelogs < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - remove_column :timelogs, :trackable_id, :integer - remove_column :timelogs, :trackable_type, :string - end -end diff --git a/db/post_migrate/20170206101030_validate_foreign_keys_on_timelogs.rb b/db/post_migrate/20170206101030_validate_foreign_keys_on_timelogs.rb deleted file mode 100644 index b5a5c0f06c7..00000000000 --- a/db/post_migrate/20170206101030_validate_foreign_keys_on_timelogs.rb +++ /dev/null @@ -1,32 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class ValidateForeignKeysOnTimelogs < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - disable_ddl_transaction! - - def up - if Gitlab::Database.postgresql? - execute <<-EOF - ALTER TABLE timelogs VALIDATE CONSTRAINT "fk_timelogs_issues_issue_id"; - ALTER TABLE timelogs VALIDATE CONSTRAINT "fk_timelogs_merge_requests_merge_request_id"; - EOF - end - end - - def down - # noop - end -end diff --git a/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb b/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb deleted file mode 100644 index 81ac4cf1373..00000000000 --- a/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb +++ /dev/null @@ -1,20 +0,0 @@ -class ValidateForeignKeysOnOauthOpenidRequests < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - if Gitlab::Database.postgresql? - execute %q{ - ALTER TABLE "oauth_openid_requests" - VALIDATE CONSTRAINT "fk_oauth_openid_requests_oauth_access_grants_access_grant_id"; - } - end - end - - def down - # noop - end -end diff --git a/db/post_migrate/20170211073944_disable_invalid_service_templates.rb b/db/post_migrate/20170211073944_disable_invalid_service_templates.rb deleted file mode 100644 index 31234e5b086..00000000000 --- a/db/post_migrate/20170211073944_disable_invalid_service_templates.rb +++ /dev/null @@ -1,13 +0,0 @@ -class DisableInvalidServiceTemplates < ActiveRecord::Migration[4.2] - DOWNTIME = false - - class Service < ActiveRecord::Base - self.inheritance_column = nil - end - - def up - Service.where(template: true, active: true).each do |template| - template.update(active: false) unless template.valid? - end - end -end diff --git a/db/post_migrate/20170214111112_delete_deprecated_gitlab_ci_service.rb b/db/post_migrate/20170214111112_delete_deprecated_gitlab_ci_service.rb deleted file mode 100644 index c273060f8b0..00000000000 --- a/db/post_migrate/20170214111112_delete_deprecated_gitlab_ci_service.rb +++ /dev/null @@ -1,15 +0,0 @@ -class DeleteDeprecatedGitlabCiService < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - disable_statement_timeout - - execute("DELETE FROM services WHERE type = 'GitlabCiService';") - end - - def down - # noop - end -end diff --git a/db/post_migrate/20170215200045_remove_theme_id_from_users.rb b/db/post_migrate/20170215200045_remove_theme_id_from_users.rb deleted file mode 100644 index 937fe3f57af..00000000000 --- a/db/post_migrate/20170215200045_remove_theme_id_from_users.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RemoveThemeIdFromUsers < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - remove_column :users, :theme_id, :integer - 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 deleted file mode 100644 index c2d28d79491..00000000000 --- a/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb +++ /dev/null @@ -1,86 +0,0 @@ -class MigrateBuildEventsToPipelineEvents < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - 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 deleted file mode 100644 index aa12e8ac3da..00000000000 --- a/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb +++ /dev/null @@ -1,23 +0,0 @@ -class MigrateLegacyManualActions < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - 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'; - EOS - 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'; - EOS - end -end diff --git a/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb b/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb deleted file mode 100644 index 2cf4cf61d8f..00000000000 --- a/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb +++ /dev/null @@ -1,19 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -# rubocop:disable Migration/UpdateColumnInBatches -class ResetRelativePositionForIssue < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - update_column_in_batches(:issues, :relative_position, nil) do |table, query| - query.where(table[:relative_position].not_eq(nil)) - end - end - - def down - # noop - end -end diff --git a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb deleted file mode 100644 index 85c97e3687e..00000000000 --- a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb +++ /dev/null @@ -1,79 +0,0 @@ -class RenameMoreReservedProjectNames < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - KNOWN_PATHS = %w(artifacts graphs refs badges).freeze - - def up - reserved_projects.each_slice(100) do |slice| - rename_projects(slice) - end - end - - def down - # nothing to do here - end - - private - - def reserved_projects - Project.unscoped - .includes(:namespace) - .where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)') - .where('projects.path' => KNOWN_PATHS) - end - - def route_exists?(full_path) - quoted_path = ActiveRecord::Base.connection.quote_string(full_path) - - ActiveRecord::Base.connection - .select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? - end - - # Adds number to the end of the path that is not taken by other route - def rename_path(namespace_path, path_was) - counter = 0 - path = "#{path_was}#{counter}" - - while route_exists?("#{namespace_path}/#{path}") - counter += 1 - path = "#{path_was}#{counter}" - end - - path - end - - def rename_projects(projects) - projects.each do |project| - id = project.id - path_was = project.path - namespace_path = project.namespace.path - path = rename_path(namespace_path, path_was) - - begin - # Because project path update is quite complex operation we can't safely - # copy-paste all code from GitLab. As exception we use Rails code here - if rename_project_row(project, path) - after_rename_service(project, path_was, namespace_path).execute - end - rescue Exception => e # rubocop: disable Lint/RescueException - Rails.logger.error "Exception when renaming project #{id}: #{e.message}" - end - end - end - - def rename_project_row(project, path) - project.respond_to?(:update_attributes) && - project.update(path: path) && - defined?(Projects::AfterRenameService) - end - - def after_rename_service(project, path_was, namespace_path) - AfterRenameService.new( - project, - path_before: path_was, - full_path_before: "#{namespace_path}/#{path_was}" - ).execute - end -end diff --git a/db/post_migrate/20170317162059_update_upload_paths_to_system.rb b/db/post_migrate/20170317162059_update_upload_paths_to_system.rb deleted file mode 100644 index 99cdca465e2..00000000000 --- a/db/post_migrate/20170317162059_update_upload_paths_to_system.rb +++ /dev/null @@ -1,57 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class UpdateUploadPathsToSystem < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - AFFECTED_MODELS = %w(User Project Note Namespace Appearance) - - disable_ddl_transaction! - - def up - update_column_in_batches(:uploads, :path, replace_sql(arel_table[:path], base_directory, new_upload_dir)) do |_table, query| - query.where(uploads_to_switch_to_new_path) - end - end - - def down - update_column_in_batches(:uploads, :path, replace_sql(arel_table[:path], new_upload_dir, base_directory)) do |_table, query| - query.where(uploads_to_switch_to_old_path) - end - end - - # "SELECT \"uploads\".* FROM \"uploads\" WHERE \"uploads\".\"model_type\" IN ('User', 'Project', 'Note', 'Namespace', 'Appearance') AND (\"uploads\".\"path\" ILIKE 'uploads/%' AND NOT (\"uploads\".\"path\" ILIKE 'uploads/system/%'))" - def uploads_to_switch_to_new_path - affected_uploads.and(starting_with_base_directory).and(starting_with_new_upload_directory.not) - end - - # "SELECT \"uploads\".* FROM \"uploads\" WHERE \"uploads\".\"model_type\" IN ('User', 'Project', 'Note', 'Namespace', 'Appearance') AND (\"uploads\".\"path\" ILIKE 'uploads/%' AND \"uploads\".\"path\" ILIKE 'uploads/system/%')" - def uploads_to_switch_to_old_path - affected_uploads.and(starting_with_new_upload_directory) - end - - def starting_with_base_directory - arel_table[:path].matches("#{base_directory}/%") - end - - def starting_with_new_upload_directory - arel_table[:path].matches("#{new_upload_dir}/%") - end - - def affected_uploads - arel_table[:model_type].in(AFFECTED_MODELS) - end - - def base_directory - "uploads" - end - - def new_upload_dir - File.join(base_directory, "-", "system") - end - - def arel_table - Arel::Table.new(:uploads) - end -end diff --git a/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb b/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb deleted file mode 100644 index 61a5c364b2f..00000000000 --- a/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb +++ /dev/null @@ -1,88 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - USER_ACTIVITY_SET_KEY = 'user/activities'.freeze - ACTIVITIES_PER_PAGE = 100 - TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED = Time.utc(2016, 12, 1) - - def up - return if activities_count(TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED, Time.now).zero? - - day = Time.at(activities(TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED, Time.now).first.second) - - transaction do - while day <= Time.now.utc.tomorrow - persist_last_activity_on(day: day) - day = day.tomorrow - end - end - end - - def down - # This ensures we don't lock all users for the duration of the migration. - update_column_in_batches(:users, :last_activity_on, nil) do |table, query| - query.where(table[:last_activity_on].not_eq(nil)) - end - end - - private - - def persist_last_activity_on(day:, page: 1) - activities_count = activities_count(day.at_beginning_of_day, day.at_end_of_day) - - return if activities_count.zero? - - activities = activities(day.at_beginning_of_day, day.at_end_of_day, page: page) - - update_sql = - Arel::UpdateManager.new - .table(users_table) - .set(users_table[:last_activity_on] => day.to_date) - .where(users_table[:username].in(activities.map(&:first))) - .to_sql - - connection.exec_update(update_sql, self.class.name, []) - - unless last_page?(page, activities_count) - persist_last_activity_on(day: day, page: page + 1) - end - end - - def users_table - @users_table ||= Arel::Table.new(:users) - end - - def activities(from, to, page: 1) - Gitlab::Redis::SharedState.with do |redis| - redis.zrangebyscore(USER_ACTIVITY_SET_KEY, from.to_i, to.to_i, - with_scores: true, - limit: limit(page)) - end - end - - def activities_count(from, to) - Gitlab::Redis::SharedState.with do |redis| - redis.zcount(USER_ACTIVITY_SET_KEY, from.to_i, to.to_i) - end - end - - def limit(page) - [offset(page), ACTIVITIES_PER_PAGE] - end - - def total_pages(count) - (count.to_f / ACTIVITIES_PER_PAGE).ceil - end - - def last_page?(page, count) - page >= total_pages(count) - end - - def offset(page) - (page - 1) * ACTIVITIES_PER_PAGE - end -end diff --git a/db/post_migrate/20170404170532_remove_notes_original_discussion_id.rb b/db/post_migrate/20170404170532_remove_notes_original_discussion_id.rb deleted file mode 100644 index 334742f04e4..00000000000 --- a/db/post_migrate/20170404170532_remove_notes_original_discussion_id.rb +++ /dev/null @@ -1,23 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveNotesOriginalDiscussionId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - # When using the methods "add_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" make sure that this - # method 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 fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - - def change - remove_column :notes, :original_discussion_id, :string - end -end diff --git a/db/post_migrate/20170406111121_clean_upload_symlinks.rb b/db/post_migrate/20170406111121_clean_upload_symlinks.rb deleted file mode 100644 index 5fec00aa198..00000000000 --- a/db/post_migrate/20170406111121_clean_upload_symlinks.rb +++ /dev/null @@ -1,53 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CleanUploadSymlinks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - DIRECTORIES_TO_MOVE = %w(user project note group appearance) - - def up - return unless file_storage? - - DIRECTORIES_TO_MOVE.each do |dir| - symlink_location = File.join(old_upload_dir, dir) - next unless File.symlink?(symlink_location) - - say "removing symlink: #{symlink_location}" - FileUtils.rm(symlink_location) - end - end - - def down - return unless file_storage? - - DIRECTORIES_TO_MOVE.each do |dir| - symlink = File.join(old_upload_dir, dir) - destination = File.join(new_upload_dir, dir) - - next if File.directory?(symlink) - next unless File.directory?(destination) - - say "Creating symlink #{symlink} -> #{destination}" - FileUtils.ln_s(destination, symlink) - end - end - - def file_storage? - CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File - end - - def base_directory - Rails.root - end - - def old_upload_dir - File.join(base_directory, "public", "uploads") - end - - def new_upload_dir - File.join(base_directory, "public", "uploads", "-", "system") - end -end diff --git a/db/post_migrate/20170406142253_migrate_user_project_view.rb b/db/post_migrate/20170406142253_migrate_user_project_view.rb deleted file mode 100644 index 3601baba787..00000000000 --- a/db/post_migrate/20170406142253_migrate_user_project_view.rb +++ /dev/null @@ -1,22 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MigrateUserProjectView < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - update_column_in_batches(:users, :project_view, 2) do |table, query| - query.where(table[:project_view].eq(0)) - end - end - - def down - # Nothing can be done to restore old values - end -end diff --git a/db/post_migrate/20170408033905_remove_old_cache_directories.rb b/db/post_migrate/20170408033905_remove_old_cache_directories.rb deleted file mode 100644 index 22bc5b9db7b..00000000000 --- a/db/post_migrate/20170408033905_remove_old_cache_directories.rb +++ /dev/null @@ -1,23 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -# Remove all files from old custom carrierwave's cache directories. -# See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9466 - -class RemoveOldCacheDirectories < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - # FileUploader cache. - FileUtils.rm_rf(Dir[Rails.root.join('public', 'uploads', 'tmp', '*')]) - end - - def down - # Old cache is not supposed to be recoverable. - # So the down method is empty. - end -end diff --git a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb deleted file mode 100644 index c9ff91b0401..00000000000 --- a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb +++ /dev/null @@ -1,62 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameReservedDynamicPaths < ActiveRecord::Migration[4.2] - include Gitlab::Database::RenameReservedPathsMigration::V1 - - DOWNTIME = false - - disable_ddl_transaction! - - DISALLOWED_ROOT_PATHS = %w[ - - - abuse_reports - api - autocomplete - explore - health_check - import - invites - jwt - koding - member - notification_settings - oauth - sent_notifications - unicorn_test - uploads - users - ] - - DISALLOWED_WILDCARD_PATHS = %w[ - environments/folders - gitlab-lfs/objects - info/lfs/objects - ] - - DISSALLOWED_GROUP_PATHS = %w[ - activity - analytics - audit_events - avatar - group_members - hooks - labels - ldap - ldap_group_links - milestones - notification_setting - pipeline_quota - subgroups - ] - - def up - rename_root_paths(DISALLOWED_ROOT_PATHS) - rename_wildcard_paths(DISALLOWED_WILDCARD_PATHS) - rename_child_paths(DISSALLOWED_GROUP_PATHS) - end - - def down - # nothing to do - end -end diff --git a/db/post_migrate/20170425121605_migrate_trigger_schedules_to_pipeline_schedules.rb b/db/post_migrate/20170425121605_migrate_trigger_schedules_to_pipeline_schedules.rb deleted file mode 100644 index 99ded277277..00000000000 --- a/db/post_migrate/20170425121605_migrate_trigger_schedules_to_pipeline_schedules.rb +++ /dev/null @@ -1,48 +0,0 @@ -class MigrateTriggerSchedulesToPipelineSchedules < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - connection.execute <<~SQL - DELETE FROM ci_trigger_schedules WHERE NOT EXISTS - (SELECT true FROM projects - WHERE ci_trigger_schedules.project_id = projects.id - ) - SQL - - connection.execute <<-SQL - INSERT INTO ci_pipeline_schedules ( - project_id, - created_at, - updated_at, - deleted_at, - cron, - cron_timezone, - next_run_at, - ref, - active, - owner_id, - description - ) - SELECT - ci_trigger_schedules.project_id, - ci_trigger_schedules.created_at, - ci_trigger_schedules.updated_at, - ci_trigger_schedules.deleted_at, - ci_trigger_schedules.cron, - ci_trigger_schedules.cron_timezone, - ci_trigger_schedules.next_run_at, - ci_trigger_schedules.ref, - ci_trigger_schedules.active, - ci_triggers.owner_id, - ci_triggers.description - FROM ci_trigger_schedules - INNER JOIN ci_triggers ON ci_trigger_schedules.trigger_id=ci_triggers.id; - SQL - end - - def down - # no op as the data has been removed - end -end diff --git a/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb b/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb deleted file mode 100644 index 9d515aca8b4..00000000000 --- a/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb +++ /dev/null @@ -1,32 +0,0 @@ -class DropCiTriggerSchedulesTable < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - drop_table :ci_trigger_schedules - end - - def down - create_table "ci_trigger_schedules", force: :cascade do |t| - t.integer "project_id" - t.integer "trigger_id", null: false - t.datetime "deleted_at" - t.datetime "created_at" - t.datetime "updated_at" - t.string "cron" - t.string "cron_timezone" - t.datetime "next_run_at" - t.string "ref" - t.boolean "active" - end - - add_index "ci_trigger_schedules", %w(active next_run_at), name: "index_ci_trigger_schedules_on_active_and_next_run_at", using: :btree - add_index "ci_trigger_schedules", ["project_id"], name: "index_ci_trigger_schedules_on_project_id", using: :btree - add_index "ci_trigger_schedules", ["next_run_at"], name: "index_ci_trigger_schedules_on_next_run_at" - - add_concurrent_foreign_key "ci_trigger_schedules", "ci_triggers", column: :trigger_id, on_delete: :cascade - end -end diff --git a/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb b/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb deleted file mode 100644 index 4d091d7f275..00000000000 --- a/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb +++ /dev/null @@ -1,19 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -# rubocop:disable Migration/UpdateColumnInBatches -class EnableAutoCancelPendingPipelinesForAll < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - - def up - disable_statement_timeout do - update_column_in_batches(:projects, :auto_cancel_pending_pipelines, 1) - end - end - - def down - # Nothing we can do! - end -end diff --git a/db/post_migrate/20170503004427_update_retried_for_ci_build.rb b/db/post_migrate/20170503004427_update_retried_for_ci_build.rb deleted file mode 100644 index 596f8593308..00000000000 --- a/db/post_migrate/20170503004427_update_retried_for_ci_build.rb +++ /dev/null @@ -1,69 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class UpdateRetriedForCiBuild < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - if Gitlab::Database.mysql? - up_mysql - else - disable_statement_timeout do - up_postgres - end - end - end - - def down - end - - private - - def up_mysql - # This is a trick to overcome MySQL limitation: - # Mysql2::Error: Table 'ci_builds' is specified twice, both as a target for 'UPDATE' and as a separate source for data - # However, this leads to create a temporary table from `max(ci_builds.id)` which is slow and do full database update - execute <<-SQL.strip_heredoc - UPDATE ci_builds SET retried= - (id NOT IN ( - SELECT * FROM (SELECT MAX(ci_builds.id) FROM ci_builds GROUP BY commit_id, name) AS latest_jobs - )) - WHERE retried IS NULL - SQL - end - - def up_postgres - with_temporary_partial_index do - latest_id = <<-SQL.strip_heredoc - SELECT MAX(ci_builds2.id) - FROM ci_builds ci_builds2 - WHERE ci_builds.commit_id=ci_builds2.commit_id - AND ci_builds.name=ci_builds2.name - SQL - - # This is slow update as it does single-row query - # This is designed to be run as idle, or a post deployment migration - is_retried = Arel.sql("((#{latest_id}) != ci_builds.id)") - - update_column_in_batches(:ci_builds, :retried, is_retried) do |table, query| - query.where(table[:retried].eq(nil)) - end - end - end - - def with_temporary_partial_index - if Gitlab::Database.postgresql? - unless index_exists?(:ci_builds, :id, name: :index_for_ci_builds_retried_migration) - execute 'CREATE INDEX CONCURRENTLY index_for_ci_builds_retried_migration ON ci_builds (id) WHERE retried IS NULL;' - end - end - - yield - - if Gitlab::Database.postgresql? && index_exists?(:ci_builds, :id, name: :index_for_ci_builds_retried_migration) - execute 'DROP INDEX CONCURRENTLY index_for_ci_builds_retried_migration' - end - end -end diff --git a/db/post_migrate/20170503120310_remove_users_authorized_projects_populated.rb b/db/post_migrate/20170503120310_remove_users_authorized_projects_populated.rb deleted file mode 100644 index 891ce44f60a..00000000000 --- a/db/post_migrate/20170503120310_remove_users_authorized_projects_populated.rb +++ /dev/null @@ -1,15 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveUsersAuthorizedProjectsPopulated < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def change - remove_column :users, :authorized_projects_populated, :boolean - end -end diff --git a/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb b/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb deleted file mode 100644 index 6e7365f4c56..00000000000 --- a/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb +++ /dev/null @@ -1,28 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class AddHeadPipelineForEachMergeRequest < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - pipelines = Arel::Table.new(:ci_pipelines) - merge_requests = Arel::Table.new(:merge_requests) - - disable_statement_timeout do - head_id = pipelines - .project(Arel::Nodes::NamedFunction.new('max', [pipelines[:id]])) - .from(pipelines) - .where(pipelines[:ref].eq(merge_requests[:source_branch])) - .where(pipelines[:project_id].eq(merge_requests[:source_project_id])) - - sub_query = Arel::Nodes::SqlLiteral.new(Arel::Nodes::Grouping.new(head_id).to_sql) - - update_column_in_batches(:merge_requests, :head_pipeline_id, sub_query) - end - end - - def down - end -end diff --git a/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb b/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb deleted file mode 100644 index 85586aecd54..00000000000 --- a/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb +++ /dev/null @@ -1,35 +0,0 @@ -class AddForeignKeyOnPipelineScheduleOwner < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - execute <<-SQL - UPDATE ci_pipeline_schedules - SET owner_id = NULL - WHERE NOT EXISTS ( - SELECT true - FROM users - WHERE ci_pipeline_schedules.owner_id = users.id - ) - SQL - - add_concurrent_foreign_key(:ci_pipeline_schedules, :users, column: :owner_id, on_delete: on_delete) - end - - def down - remove_foreign_key(:ci_pipeline_schedules, column: :owner_id) - end - - private - - def on_delete - if Gitlab::Database.mysql? - :nullify - else - 'SET NULL' - end - end -end diff --git a/db/post_migrate/20170511100900_cleanup_rename_web_hooks_build_events_to_job_events.rb b/db/post_migrate/20170511100900_cleanup_rename_web_hooks_build_events_to_job_events.rb deleted file mode 100644 index b4a3db65607..00000000000 --- a/db/post_migrate/20170511100900_cleanup_rename_web_hooks_build_events_to_job_events.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CleanupRenameWebHooksBuildEventsToJobEvents < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :web_hooks, :build_events, :job_events - end - - def down - rename_column_concurrently :web_hooks, :job_events, :build_events - end -end diff --git a/db/post_migrate/20170511101000_cleanup_rename_services_build_events_to_job_events.rb b/db/post_migrate/20170511101000_cleanup_rename_services_build_events_to_job_events.rb deleted file mode 100644 index 65342747321..00000000000 --- a/db/post_migrate/20170511101000_cleanup_rename_services_build_events_to_job_events.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CleanupRenameServicesBuildEventsToJobEvents < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :services, :build_events, :job_events - end - - def down - rename_column_concurrently :services, :job_events, :build_events - end -end diff --git a/db/post_migrate/20170516165238_cleanup_trigger_for_issues.rb b/db/post_migrate/20170516165238_cleanup_trigger_for_issues.rb deleted file mode 100644 index affeba52250..00000000000 --- a/db/post_migrate/20170516165238_cleanup_trigger_for_issues.rb +++ /dev/null @@ -1,39 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CleanupTriggerForIssues < ActiveRecord::Migration[4.2] - 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 up - if Gitlab::Database.postgresql? - execute <<-EOF - DROP TRIGGER IF EXISTS replicate_assignee_id ON issues; - DROP FUNCTION IF EXISTS replicate_assignee_id(); - EOF - end - end - - def down - end -end diff --git a/db/post_migrate/20170516181025_add_constraints_to_issue_assignees_table.rb b/db/post_migrate/20170516181025_add_constraints_to_issue_assignees_table.rb deleted file mode 100644 index 03456a31b0d..00000000000 --- a/db/post_migrate/20170516181025_add_constraints_to_issue_assignees_table.rb +++ /dev/null @@ -1,37 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddConstraintsToIssueAssigneesTable < ActiveRecord::Migration[4.2] - 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 up - change_column_null :issue_assignees, :issue_id, false - change_column_null :issue_assignees, :user_id, false - end - - def down - change_column_null :issue_assignees, :issue_id, true - change_column_null :issue_assignees, :user_id, true - end -end diff --git a/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb b/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb deleted file mode 100644 index 4ba78727cc3..00000000000 --- a/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb +++ /dev/null @@ -1,51 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameUsersWithRenamedNamespace < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - DISALLOWED_ROOT_PATHS = %w[ - abuse_reports - api - autocomplete - explore - health_check - import - invites - jwt - koding - member - notification_settings - oauth - sent_notifications - unicorn_test - uploads - users - ] - - def up - DISALLOWED_ROOT_PATHS.each do |path| - users = Arel::Table.new(:users) - namespaces = Arel::Table.new(:namespaces) - predicate = namespaces[:owner_id].eq(users[:id]) - .and(namespaces[:type].eq(nil)) - .and(users[:username].matches(path)) - - update_sql = if Gitlab::Database.postgresql? - "UPDATE users SET username = namespaces.path "\ - "FROM namespaces WHERE #{predicate.to_sql}" - else - "UPDATE users INNER JOIN namespaces "\ - "ON namespaces.owner_id = users.id "\ - "SET username = namespaces.path "\ - "WHERE #{predicate.to_sql}" - end - - connection.execute(update_sql) - end - end - - def down - end -end diff --git a/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb b/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb deleted file mode 100644 index 28a2a2e01bf..00000000000 --- a/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb +++ /dev/null @@ -1,105 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class FixWronglyRenamedRoutes < ActiveRecord::Migration[4.2] - include Gitlab::Database::RenameReservedPathsMigration::V1 - - DOWNTIME = false - - disable_ddl_transaction! - - DISALLOWED_ROOT_PATHS = %w[ - - - abuse_reports - api - autocomplete - explore - health_check - import - invites - jwt - koding - member - notification_settings - oauth - sent_notifications - unicorn_test - uploads - users - ] - - FIXED_PATHS = DISALLOWED_ROOT_PATHS.map { |p| "#{p}0" } - - class Route < Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Route - self.table_name = 'routes' - end - - def routes - @routes ||= Route.arel_table - end - - def namespaces - @namespaces ||= Arel::Table.new(:namespaces) - end - - def wildcard_collection(collection) - collection.map { |word| "#{word}%" } - end - - # The routes that got incorrectly renamed before, still have a namespace that - # contains the correct path. - # This query fetches all rows from the `routes` table that meet the following - # conditions using `api` as an example: - # - route.path ILIKE `api0%` - # - route.source_type = `Namespace` - # - namespace.parent_id IS NULL - # - namespace.path ILIKE `api%` - # - NOT(namespace.path ILIKE `api0%`) - # This gives us all root-routes, that were renamed, but their namespace was not. - # - def wrongly_renamed - Route.joins("INNER JOIN namespaces ON routes.source_id = namespaces.id") - .where( - routes[:source_type].eq('Namespace') - .and(namespaces[:parent_id].eq(nil)) - ) - .where(namespaces[:path].matches_any(wildcard_collection(DISALLOWED_ROOT_PATHS))) - .where.not(namespaces[:path].matches_any(wildcard_collection(FIXED_PATHS))) - .where(routes[:path].matches_any(wildcard_collection(FIXED_PATHS))) - end - - # Using the query above, we just fetch the `route.path` & the `namespace.path` - # `route.path` is the part of the route that is now incorrect - # `namespace.path` is what it should be - # We can use `route.path` to find all the namespaces that need to be fixed - # And we can use `namespace.path` to apply the correct name. - # - def paths_and_corrections - connection.select_all( - wrongly_renamed.select(routes[:path], namespaces[:path].as('namespace_path')).to_sql - ) - end - - # This can be used to limit the `update_in_batches` call to all routes for a - # single namespace, note the `/` that's what went wrong in the initial migration. - # - def routes_in_namespace_query(namespace) - routes[:path].matches_any([namespace, "#{namespace}/%"]) - end - - def up - paths_and_corrections.each do |root_namespace| - wrong_path = root_namespace['path'] - correct_path = root_namespace['namespace_path'] - replace_statement = replace_sql(Route.arel_table[:path], wrong_path, correct_path) - - update_column_in_batches(:routes, :path, replace_statement) do |table, query| - query.where(routes_in_namespace_query(wrong_path)) - end - end - end - - def down - end -end diff --git a/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb b/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb deleted file mode 100644 index d75bbb2f612..00000000000 --- a/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb +++ /dev/null @@ -1,48 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveAssigneeIdFromIssue < ActiveRecord::Migration[4.2] - 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! - - class Issue < ActiveRecord::Base - self.table_name = 'issues' - - include ::EachBatch - end - - def up - remove_column :issues, :assignee_id - end - - def down - add_column :issues, :assignee_id, :integer - add_concurrent_index :issues, :assignee_id - - update_value = Arel.sql('(SELECT user_id FROM issue_assignees WHERE issue_assignees.issue_id = issues.id LIMIT 1)') - - # This is only used in the down step, so we can ignore the RuboCop warning - # about large tables, as this is very unlikely to be run on GitLab.com - update_column_in_batches(:issues, :assignee_id, update_value) # rubocop:disable Migration/UpdateLargeTable - end -end diff --git a/db/post_migrate/20170523083112_migrate_old_artifacts.rb b/db/post_migrate/20170523083112_migrate_old_artifacts.rb deleted file mode 100644 index 55e155c7619..00000000000 --- a/db/post_migrate/20170523083112_migrate_old_artifacts.rb +++ /dev/null @@ -1,72 +0,0 @@ -class MigrateOldArtifacts < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - # This uses special heuristic to find potential candidates for data migration - # Read more about this here: https://gitlab.com/gitlab-org/gitlab-ce/issues/32036#note_30422345 - - def up - builds_with_artifacts.find_each do |build| - build.migrate_artifacts! - end - end - - def down - end - - private - - def builds_with_artifacts - Build.with_artifacts - .joins('JOIN projects ON projects.id = ci_builds.project_id') - .where('ci_builds.id < ?', min_id) - .where('projects.ci_id IS NOT NULL') - .select('id', 'created_at', 'project_id', 'projects.ci_id AS ci_id') - end - - def min_id - Build.joins('JOIN projects ON projects.id = ci_builds.project_id') - .where('projects.ci_id IS NULL') - .pluck('coalesce(min(ci_builds.id), 0)') - .first - end - - class Build < ActiveRecord::Base - self.table_name = 'ci_builds' - - scope :with_artifacts, -> { where.not(artifacts_file: [nil, '']) } - - def migrate_artifacts! - return unless File.exist?(source_artifacts_path) - return if File.exist?(target_artifacts_path) - - ensure_target_path - - FileUtils.move(source_artifacts_path, target_artifacts_path) - end - - private - - def source_artifacts_path - @source_artifacts_path ||= - File.join(Gitlab.config.artifacts.path, - created_at.utc.strftime('%Y_%m'), - ci_id.to_s, id.to_s) - end - - def target_artifacts_path - @target_artifacts_path ||= - File.join(Gitlab.config.artifacts.path, - created_at.utc.strftime('%Y_%m'), - project_id.to_s, id.to_s) - end - - def ensure_target_path - directory = File.dirname(target_artifacts_path) - FileUtils.mkdir_p(directory) unless Dir.exist?(directory) - end - end -end diff --git a/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb b/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb deleted file mode 100644 index 59b8daaffdf..00000000000 --- a/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb +++ /dev/null @@ -1,102 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameAllReservedPathsAgain < ActiveRecord::Migration[4.2] - include Gitlab::Database::RenameReservedPathsMigration::V1 - - DOWNTIME = false - - disable_ddl_transaction! - - TOP_LEVEL_ROUTES = %w[ - - - .well-known - abuse_reports - admin - api - assets - autocomplete - ci - dashboard - explore - files - groups - health_check - help - import - invites - jwt - koding - notification_settings - oauth - profile - projects - public - robots.txt - s - search - sent_notifications - snippets - u - unicorn_test - unsubscribes - uploads - users - ].freeze - - PROJECT_WILDCARD_ROUTES = %w[ - badges - blame - blob - builds - commits - create - create_dir - edit - environments/folders - files - find_file - gitlab-lfs/objects - info/lfs/objects - new - preview - raw - refs - tree - update - wikis - ].freeze - - GROUP_ROUTES = %w[ - activity - analytics - audit_events - avatar - edit - group_members - hooks - issues - labels - ldap - ldap_group_links - merge_requests - milestones - notification_setting - pipeline_quota - projects - ].freeze - - def up - disable_statement_timeout do - TOP_LEVEL_ROUTES.each { |route| rename_root_paths(route) } - PROJECT_WILDCARD_ROUTES.each { |route| rename_wildcard_paths(route) } - GROUP_ROUTES.each { |route| rename_child_paths(route) } - end - end - - def down - disable_statement_timeout do - revert_renames - end - end -end diff --git a/db/post_migrate/20170526185842_migrate_pipeline_stages.rb b/db/post_migrate/20170526185842_migrate_pipeline_stages.rb deleted file mode 100644 index 53743fc16e6..00000000000 --- a/db/post_migrate/20170526185842_migrate_pipeline_stages.rb +++ /dev/null @@ -1,22 +0,0 @@ -class MigratePipelineStages < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - disable_statement_timeout do - execute <<-SQL.strip_heredoc - INSERT INTO ci_stages (project_id, pipeline_id, name) - SELECT project_id, commit_id, stage FROM ci_builds - WHERE stage IS NOT NULL - AND stage_id IS NULL - AND EXISTS (SELECT 1 FROM projects WHERE projects.id = ci_builds.project_id) - AND EXISTS (SELECT 1 FROM ci_pipelines WHERE ci_pipelines.id = ci_builds.commit_id) - GROUP BY project_id, commit_id, stage - ORDER BY MAX(stage_idx) - SQL - end - end -end diff --git a/db/post_migrate/20170526185858_create_index_in_pipeline_stages.rb b/db/post_migrate/20170526185858_create_index_in_pipeline_stages.rb deleted file mode 100644 index dc7b1d6d026..00000000000 --- a/db/post_migrate/20170526185858_create_index_in_pipeline_stages.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateIndexInPipelineStages < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index(:ci_stages, [:pipeline_id, :name]) - end - - def down - remove_concurrent_index(:ci_stages, [:pipeline_id, :name]) - end -end diff --git a/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb b/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb deleted file mode 100644 index de473e7bb91..00000000000 --- a/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb +++ /dev/null @@ -1,18 +0,0 @@ -class RemoveStageIdIndexFromBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - if index_exists?(:ci_builds, :stage_id) - remove_foreign_key(:ci_builds, column: :stage_id) - remove_concurrent_index(:ci_builds, :stage_id) - end - end - - def down - # noop - end -end diff --git a/db/post_migrate/20170526185921_migrate_build_stage_reference.rb b/db/post_migrate/20170526185921_migrate_build_stage_reference.rb deleted file mode 100644 index a9b392314fa..00000000000 --- a/db/post_migrate/20170526185921_migrate_build_stage_reference.rb +++ /dev/null @@ -1,19 +0,0 @@ -class MigrateBuildStageReference < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - ## - # This is an empty migration, content has been moved to a new one: - # post migrate 20170526190000 MigrateBuildStageReferenceAgain - # - # See gitlab-org/gitlab-ce!12337 for more details. - - def up - # noop - end - - def down - # noop - end -end diff --git a/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb b/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb deleted file mode 100644 index 01b6cf3a158..00000000000 --- a/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb +++ /dev/null @@ -1,28 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class MigrateBuildStageReferenceAgain < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - stage_id = Arel.sql <<-SQL.strip_heredoc - (SELECT id FROM ci_stages - WHERE ci_stages.pipeline_id = ci_builds.commit_id - AND ci_stages.name = ci_builds.stage) - SQL - - disable_statement_timeout do - update_column_in_batches(:ci_builds, :stage_id, stage_id) do |table, query| - query.where(table[:stage_id].eq(nil)) - end - end - end - - def down - disable_statement_timeout do - update_column_in_batches(:ci_builds, :stage_id, nil) - end - end -end diff --git a/db/post_migrate/20170531203055_cleanup_users_ldap_email_rename.rb b/db/post_migrate/20170531203055_cleanup_users_ldap_email_rename.rb deleted file mode 100644 index 3d75c7e3eaf..00000000000 --- a/db/post_migrate/20170531203055_cleanup_users_ldap_email_rename.rb +++ /dev/null @@ -1,16 +0,0 @@ -class CleanupUsersLdapEmailRename < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :users, :ldap_email, :external_email - end - - def down - # rubocop:disable Migration/UpdateLargeTable - rename_column_concurrently :users, :external_email, :ldap_email - end -end diff --git a/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb b/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb deleted file mode 100644 index fb9ac8d6daf..00000000000 --- a/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb +++ /dev/null @@ -1,57 +0,0 @@ -class MoveAppearanceToSystemDir < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - DIRECTORY_TO_MOVE = 'appearance'.freeze - - def up - source = File.join(old_upload_dir, DIRECTORY_TO_MOVE) - destination = File.join(new_upload_dir, DIRECTORY_TO_MOVE) - - move_directory(source, destination) - end - - def down - source = File.join(new_upload_dir, DIRECTORY_TO_MOVE) - destination = File.join(old_upload_dir, DIRECTORY_TO_MOVE) - - move_directory(source, destination) - end - - def move_directory(source, destination) - unless file_storage? - say 'Not using file storage, skipping' - return - end - - unless File.directory?(source) - say "#{source} did not exist, skipping" - return - end - - if File.directory?(destination) - say "#{destination} already existed, skipping" - return - end - - say "Moving #{source} -> #{destination}" - FileUtils.mv(source, destination) - end - - def file_storage? - CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File - end - - def base_directory - Rails.root - end - - def old_upload_dir - File.join(base_directory, "public", "uploads") - end - - def new_upload_dir - File.join(base_directory, "public", "uploads", "-", "system") - end -end diff --git a/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb b/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb deleted file mode 100644 index 8ff26130cba..00000000000 --- a/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb +++ /dev/null @@ -1,55 +0,0 @@ -class ConvertCustomNotificationSettingsToColumns < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class NotificationSetting < ActiveRecord::Base - self.table_name = 'notification_settings' - - store :events, coder: JSON - end - - EMAIL_EVENTS = [ - :new_note, - :new_issue, - :reopen_issue, - :close_issue, - :reassign_issue, - :new_merge_request, - :reopen_merge_request, - :close_merge_request, - :reassign_merge_request, - :merge_merge_request, - :failed_pipeline, - :success_pipeline - ] - - # We only need to migrate (up or down) rows where at least one of these - # settings is set. - def up - NotificationSetting.where("events LIKE '%true%'").find_each do |notification_setting| - EMAIL_EVENTS.each do |event| - notification_setting[event] = notification_setting.events[event] - end - - notification_setting[:events] = nil - notification_setting.save! - end - end - - def down - NotificationSetting.where(EMAIL_EVENTS.join(' OR ')).find_each do |notification_setting| - events = {} - - EMAIL_EVENTS.each do |event| - events[event] = !!notification_setting.public_send(event) - notification_setting[event] = nil - end - - notification_setting[:events] = events - notification_setting.save! - end - end -end diff --git a/db/post_migrate/20170609183112_remove_position_from_issuables.rb b/db/post_migrate/20170609183112_remove_position_from_issuables.rb deleted file mode 100644 index edad0a502b4..00000000000 --- a/db/post_migrate/20170609183112_remove_position_from_issuables.rb +++ /dev/null @@ -1,8 +0,0 @@ -class RemovePositionFromIssuables < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def change - remove_column :issues, :position, :integer - remove_column :merge_requests, :position, :integer - end -end diff --git a/db/post_migrate/20170612071012_move_personal_snippets_files.rb b/db/post_migrate/20170612071012_move_personal_snippets_files.rb deleted file mode 100644 index d32d92637fa..00000000000 --- a/db/post_migrate/20170612071012_move_personal_snippets_files.rb +++ /dev/null @@ -1,92 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. -class MovePersonalSnippetsFiles < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - return unless file_storage? - - @source_relative_location = File.join('/uploads', 'personal_snippet') - @destination_relative_location = File.join('/uploads', '-', 'system', 'personal_snippet') - - move_personal_snippet_files - end - - def down - return unless file_storage? - - @source_relative_location = File.join('/uploads', '-', 'system', 'personal_snippet') - @destination_relative_location = File.join('/uploads', 'personal_snippet') - - move_personal_snippet_files - end - - def move_personal_snippet_files - query = "SELECT uploads.path, uploads.model_id, snippets.description FROM uploads "\ - "INNER JOIN snippets ON snippets.id = uploads.model_id WHERE uploader = 'PersonalFileUploader'" - select_all(query).each do |upload| - secret = upload['path'].split('/')[0] - file_name = upload['path'].split('/')[1] - - next unless move_file(upload['model_id'], secret, file_name) - - update_markdown(upload['model_id'], secret, file_name, upload['description']) - end - end - - def move_file(snippet_id, secret, file_name) - source_dir = File.join(base_directory, @source_relative_location, snippet_id.to_s, secret) - destination_dir = File.join(base_directory, @destination_relative_location, snippet_id.to_s, secret) - - source_file_path = File.join(source_dir, file_name) - destination_file_path = File.join(destination_dir, file_name) - - unless File.exist?(source_file_path) - say "Source file `#{source_file_path}` doesn't exist. Skipping." - return - end - - say "Moving file #{source_file_path} -> #{destination_file_path}" - - FileUtils.mkdir_p(destination_dir) - FileUtils.move(source_file_path, destination_file_path) - - true - end - - def update_markdown(snippet_id, secret, file_name, description) - source_markdown_path = File.join(@source_relative_location, snippet_id.to_s, secret, file_name) - destination_markdown_path = File.join(@destination_relative_location, snippet_id.to_s, secret, file_name) - - source_markdown = "](#{source_markdown_path})" - destination_markdown = "](#{destination_markdown_path})" - - if description.present? - description = description.gsub(source_markdown, destination_markdown) - quoted_description = quote_string(description) - - execute("UPDATE snippets SET description = '#{quoted_description}', description_html = NULL "\ - "WHERE id = #{snippet_id}") - end - - query = "SELECT id, note FROM notes WHERE noteable_id = #{snippet_id} "\ - "AND noteable_type = 'Snippet' AND note IS NOT NULL" - select_all(query).each do |note| - text = note['note'].gsub(source_markdown, destination_markdown) - quoted_text = quote_string(text) - - execute("UPDATE notes SET note = '#{quoted_text}', note_html = NULL WHERE id = #{note['id']}") - end - end - - def base_directory - File.join(Rails.root, 'public') - end - - def file_storage? - CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File - end -end diff --git a/db/post_migrate/20170613111224_clean_appearance_symlinks.rb b/db/post_migrate/20170613111224_clean_appearance_symlinks.rb deleted file mode 100644 index 14511bff3db..00000000000 --- a/db/post_migrate/20170613111224_clean_appearance_symlinks.rb +++ /dev/null @@ -1,53 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CleanAppearanceSymlinks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - return unless file_storage? - - symlink_location = File.join(old_upload_dir, dir) - - return unless File.symlink?(symlink_location) - - say "removing symlink: #{symlink_location}" - FileUtils.rm(symlink_location) - end - - def down - return unless file_storage? - - symlink = File.join(old_upload_dir, dir) - destination = File.join(new_upload_dir, dir) - - return if File.directory?(symlink) - return unless File.directory?(destination) - - say "Creating symlink #{symlink} -> #{destination}" - FileUtils.ln_s(destination, symlink) - end - - def file_storage? - CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File - end - - def dir - 'appearance' - end - - def base_directory - Rails.root - end - - def old_upload_dir - File.join(base_directory, "public", "uploads") - end - - def new_upload_dir - File.join(base_directory, "public", "uploads", "system") - end -end diff --git a/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb b/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb deleted file mode 100644 index cca9b488547..00000000000 --- a/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddStageIdIndexToBuilds < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - ## - # Improved in 20170703102400_add_stage_id_foreign_key_to_builds.rb - # - - def up - # noop - end - - def down - # noop - end -end diff --git a/db/post_migrate/20170627101016_schedule_event_migrations.rb b/db/post_migrate/20170627101016_schedule_event_migrations.rb deleted file mode 100644 index f026a86bc0f..00000000000 --- a/db/post_migrate/20170627101016_schedule_event_migrations.rb +++ /dev/null @@ -1,40 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class ScheduleEventMigrations < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - BUFFER_SIZE = 1000 - - disable_ddl_transaction! - - class Event < ActiveRecord::Base - include EachBatch - - self.table_name = 'events' - end - - def up - jobs = [] - - Event.each_batch(of: 1000) do |relation| - min, max = relation.pluck('MIN(id), MAX(id)').first - - if jobs.length == BUFFER_SIZE - # We push multiple jobs at a time to reduce the time spent in - # Sidekiq/Redis operations. We're using this buffer based approach so we - # don't need to run additional queries for every range. - BackgroundMigrationWorker.bulk_perform_async(jobs) - jobs.clear - end - - jobs << ['MigrateEventsToPushEventPayloads', [min, max]] - end - - BackgroundMigrationWorker.bulk_perform_async(jobs) unless jobs.empty? - end - - def down - end -end diff --git a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb deleted file mode 100644 index 36aac3df071..00000000000 --- a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb +++ /dev/null @@ -1,33 +0,0 @@ -class MigrateStageIdReferenceInBackground < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - BATCH_SIZE = 10000 - RANGE_SIZE = 1000 - MIGRATION = 'MigrateBuildStageIdReference'.freeze - - disable_ddl_transaction! - - class Build < ActiveRecord::Base - self.table_name = 'ci_builds' - include ::EachBatch - end - - ## - # It will take around 3 days to process 20M ci_builds. - # - def up - Build.where(stage_id: nil).each_batch(of: BATCH_SIZE) do |relation, index| - relation.each_batch(of: RANGE_SIZE) do |relation| - range = relation.pluck('MIN(id)', 'MAX(id)').first - - BackgroundMigrationWorker - .perform_in(index * 2.minutes, MIGRATION, range) - end - end - end - - def down - # noop - end -end diff --git a/db/post_migrate/20170629180131_cleanup_application_settings_signin_enabled_rename.rb b/db/post_migrate/20170629180131_cleanup_application_settings_signin_enabled_rename.rb deleted file mode 100644 index 87268fb4b31..00000000000 --- a/db/post_migrate/20170629180131_cleanup_application_settings_signin_enabled_rename.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CleanupApplicationSettingsSigninEnabledRename < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :application_settings, :signin_enabled, :password_authentication_enabled - end - - def down - rename_column_concurrently :application_settings, :password_authentication_enabled, :signin_enabled - end -end diff --git a/db/post_migrate/20170711145558_migrate_stages_statuses.rb b/db/post_migrate/20170711145558_migrate_stages_statuses.rb deleted file mode 100644 index 8ba69ea4dce..00000000000 --- a/db/post_migrate/20170711145558_migrate_stages_statuses.rb +++ /dev/null @@ -1,34 +0,0 @@ -class MigrateStagesStatuses < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - BATCH_SIZE = 10000 - RANGE_SIZE = 100 - MIGRATION = 'MigrateStageStatus'.freeze - - class Stage < ActiveRecord::Base - self.table_name = 'ci_stages' - include ::EachBatch - end - - def up - Stage.where(status: nil).each_batch(of: BATCH_SIZE) do |relation, index| - relation.each_batch(of: RANGE_SIZE) do |batch| - range = batch.pluck('MIN(id)', 'MAX(id)').first - delay = index * 5.minutes - - BackgroundMigrationWorker.perform_in(delay, MIGRATION, range) - end - end - end - - def down - disable_statement_timeout do - # rubocop:disable Migration/UpdateLargeTable - update_column_in_batches(:ci_stages, :status, nil) - end - end -end diff --git a/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb b/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb deleted file mode 100644 index 392c4f71532..00000000000 --- a/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb +++ /dev/null @@ -1,40 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CleanupMoveSystemUploadFolderSymlink < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - if File.symlink?(old_directory) - say "Removing #{old_directory} -> #{new_directory} symlink" - FileUtils.rm(old_directory) - else - say "Symlink #{old_directory} non existent, nothing to do." - end - end - - def down - if File.directory?(new_directory) - say "Symlinking #{old_directory} -> #{new_directory}" - FileUtils.ln_s(new_directory, old_directory) unless File.exist?(old_directory) - else - say "#{new_directory} doesn't exist, skipping." - end - end - - def new_directory - File.join(base_directory, '-', 'system') - end - - def old_directory - File.join(base_directory, 'system') - end - - def base_directory - File.join(Rails.root, 'public', 'uploads') - end -end diff --git a/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb b/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb deleted file mode 100644 index fdd990ae2e5..00000000000 --- a/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb +++ /dev/null @@ -1,20 +0,0 @@ -class EnqueueMigrateSystemUploadsToNewFolder < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - OLD_FOLDER = 'uploads/system/' - NEW_FOLDER = 'uploads/-/system/' - - disable_ddl_transaction! - - def up - BackgroundMigrationWorker.perform_async('MigrateSystemUploadsToNewFolder', - [OLD_FOLDER, NEW_FOLDER]) - end - - def down - BackgroundMigrationWorker.perform_async('MigrateSystemUploadsToNewFolder', - [NEW_FOLDER, OLD_FOLDER]) - end -end diff --git a/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb b/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb deleted file mode 100644 index 7af1d04f0cc..00000000000 --- a/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb +++ /dev/null @@ -1,32 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MergeIssuableReopenedIntoOpenedState < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class Issue < ActiveRecord::Base - self.table_name = 'issues' - - include EachBatch - end - - class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' - - include EachBatch - end - - def up - [Issue, MergeRequest].each do |model| - say "Changing #{model.table_name}.state from 'reopened' to 'opened'" - - model.where(state: 'reopened').each_batch do |batch| - batch.update_all(state: 'opened') - end - end - end -end diff --git a/db/post_migrate/20170728101014_remove_events_from_notification_settings.rb b/db/post_migrate/20170728101014_remove_events_from_notification_settings.rb deleted file mode 100644 index f1b0a1daec5..00000000000 --- a/db/post_migrate/20170728101014_remove_events_from_notification_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RemoveEventsFromNotificationSettings < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - remove_column :notification_settings, :events, :text - end -end diff --git a/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb deleted file mode 100644 index a148586ca89..00000000000 --- a/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb +++ /dev/null @@ -1,30 +0,0 @@ -class CalculateConvDevIndexPercentages < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - class ConversationalDevelopmentIndexMetric < ActiveRecord::Base - self.table_name = 'conversational_development_index_metrics' - - METRICS = %w[boards ci_pipelines deployments environments issues merge_requests milestones notes - projects_prometheus_active service_desk_issues] - end - - def up - ConversationalDevelopmentIndexMetric.find_each do |conv_dev_index| - update = [] - - ConversationalDevelopmentIndexMetric::METRICS.each do |metric| - instance_score = conv_dev_index["instance_#{metric}"].to_f - leader_score = conv_dev_index["leader_#{metric}"].to_f - - percentage = leader_score.zero? ? 0.0 : (instance_score / leader_score) * 100 - update << "percentage_#{metric} = '#{percentage}'" - end - - execute("UPDATE conversational_development_index_metrics SET #{update.join(',')} WHERE id = #{conv_dev_index.id}") - end - end - - def down - end -end diff --git a/db/post_migrate/20170807160457_remove_locked_at_column_from_merge_requests.rb b/db/post_migrate/20170807160457_remove_locked_at_column_from_merge_requests.rb deleted file mode 100644 index 6dc49211e5a..00000000000 --- a/db/post_migrate/20170807160457_remove_locked_at_column_from_merge_requests.rb +++ /dev/null @@ -1,11 +0,0 @@ -class RemoveLockedAtColumnFromMergeRequests < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - remove_column :merge_requests, :locked_at - end - - def down - add_column :merge_requests, :locked_at, :datetime_with_timezone - end -end diff --git a/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb b/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb deleted file mode 100644 index 8341ac39c25..00000000000 --- a/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MovePersonalSnippetFilesIntoCorrectFolder < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - NEW_DIRECTORY = File.join('/uploads', '-', 'system', 'personal_snippet') - OLD_DIRECTORY = File.join('/uploads', 'system', 'personal_snippet') - - def up - return unless file_storage? - - BackgroundMigrationWorker.perform_async('MovePersonalSnippetFiles', - [OLD_DIRECTORY, NEW_DIRECTORY]) - end - - def down - return unless file_storage? - - BackgroundMigrationWorker.perform_async('MovePersonalSnippetFiles', - [NEW_DIRECTORY, OLD_DIRECTORY]) - end - - def file_storage? - CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File - end -end diff --git a/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb b/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb deleted file mode 100644 index fdc126b8fd6..00000000000 --- a/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb +++ /dev/null @@ -1,26 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveDuplicateMrEvents < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - class Event < ActiveRecord::Base - self.table_name = 'events' - end - - def up - base_condition = "action = 1 AND target_type = 'MergeRequest' AND created_at > '2017-08-13'" - Event.select('target_id, count(*)') - .where(base_condition) - .group('target_id').having('count(*) > 1').each do |event| - duplicates = Event.where("#{base_condition} AND target_id = #{event.target_id}").pluck(:id) - duplicates.shift - - Event.where(id: duplicates).delete_all - end - end - - def down - end -end diff --git a/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb b/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb deleted file mode 100644 index 27656fd926d..00000000000 --- a/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb +++ /dev/null @@ -1,54 +0,0 @@ -# Follow up of CleanupNamespacelessPendingDeleteProjects and it cleans -# all projects with `pending_delete = true` and for which the -# namespace no longer exists. -class CleanupNonexistingNamespacePendingDeleteProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class Project < ActiveRecord::Base - self.table_name = 'projects' - - include ::EachBatch - end - - class Namespace < ActiveRecord::Base - self.table_name = 'namespaces' - end - - def up - find_projects.each_batch do |batch| - args = batch.pluck(:id).map { |id| [id] } - - NamespacelessProjectDestroyWorker.bulk_perform_async(args) - end - end - - def down - # NOOP - end - - private - - def find_projects - projects = Project.arel_table - namespaces = Namespace.arel_table - - namespace_query = namespaces.project(1) - .where(namespaces[:id].eq(projects[:namespace_id])) - .exists.not - - # SELECT "projects"."id" - # FROM "projects" - # WHERE "projects"."pending_delete" = 't' - # AND (NOT (EXISTS - # (SELECT 1 - # FROM "namespaces" - # WHERE "namespaces"."id" = "projects"."namespace_id"))) - Project.where(projects[:pending_delete].eq(true)) - .where(namespace_query) - .select(:id) - end -end diff --git a/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb b/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb deleted file mode 100644 index 825bc9250bd..00000000000 --- a/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb +++ /dev/null @@ -1,17 +0,0 @@ -class MigratePipelineSidekiqQueues < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - sidekiq_queue_migrate 'build', to: 'pipeline_default' - sidekiq_queue_migrate 'pipeline', to: 'pipeline_default' - end - - def down - sidekiq_queue_migrate 'pipeline_default', to: 'pipeline' - sidekiq_queue_migrate 'pipeline_processing', to: 'pipeline' - sidekiq_queue_migrate 'pipeline_hooks', to: 'pipeline' - sidekiq_queue_migrate 'pipeline_cache', to: 'pipeline' - end -end diff --git a/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb b/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb deleted file mode 100644 index 533155aeb7a..00000000000 --- a/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb +++ /dev/null @@ -1,57 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class PostDeployMigrateUserExternalMailData < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class User < ActiveRecord::Base - self.table_name = 'users' - - include EachBatch - end - - class UserSyncedAttributesMetadata < ActiveRecord::Base - self.table_name = 'user_synced_attributes_metadata' - - include EachBatch - end - - def up - User.each_batch do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first - - execute <<-EOF - INSERT INTO user_synced_attributes_metadata (user_id, provider, email_synced) - SELECT id, email_provider, external_email - FROM users - WHERE external_email = TRUE - AND NOT EXISTS ( - SELECT true - FROM user_synced_attributes_metadata - WHERE user_id = users.id - AND (provider = users.email_provider OR (provider IS NULL AND users.email_provider IS NULL)) - ) - AND id BETWEEN #{start_id} AND #{end_id} - EOF - end - end - - def down - UserSyncedAttributesMetadata.each_batch do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first - - execute <<-EOF - UPDATE users - SET users.email_provider = metadata.provider, users.external_email = metadata.email_synced - FROM user_synced_attributes_metadata as metadata, users - WHERE metadata.email_synced = TRUE - AND metadata.user_id = users.id - AND id BETWEEN #{start_id} AND #{end_id} - EOF - end - end -end diff --git a/db/post_migrate/20170828170513_remove_user_email_provider_column.rb b/db/post_migrate/20170828170513_remove_user_email_provider_column.rb deleted file mode 100644 index bfc8aede540..00000000000 --- a/db/post_migrate/20170828170513_remove_user_email_provider_column.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveUserEmailProviderColumn < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - remove_column :users, :email_provider, :string - end -end diff --git a/db/post_migrate/20170828170516_remove_user_external_mail_columns.rb b/db/post_migrate/20170828170516_remove_user_external_mail_columns.rb deleted file mode 100644 index 0104955e5c8..00000000000 --- a/db/post_migrate/20170828170516_remove_user_external_mail_columns.rb +++ /dev/null @@ -1,12 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveUserExternalMailColumns < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - remove_column :users, :external_email, :boolean - end -end diff --git a/db/post_migrate/20170830084744_destroy_gpg_signatures.rb b/db/post_migrate/20170830084744_destroy_gpg_signatures.rb deleted file mode 100644 index 2945eb9fde6..00000000000 --- a/db/post_migrate/20170830084744_destroy_gpg_signatures.rb +++ /dev/null @@ -1,10 +0,0 @@ -class DestroyGpgSignatures < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - truncate(:gpg_signatures) - end - - def down - end -end diff --git a/db/post_migrate/20170830150306_drop_events_for_migration_table.rb b/db/post_migrate/20170830150306_drop_events_for_migration_table.rb deleted file mode 100644 index 3538b52b004..00000000000 --- a/db/post_migrate/20170830150306_drop_events_for_migration_table.rb +++ /dev/null @@ -1,47 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class DropEventsForMigrationTable < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class Event < ActiveRecord::Base - include EachBatch - end - - def up - transaction do - drop_table :events_for_migration - end - end - - def down - create_table :events_for_migration do |t| - t.string :target_type, index: true - t.integer :target_id, index: true - t.string :title - t.text :data - t.integer :project_id - t.datetime :created_at, index: true - t.datetime :updated_at - t.integer :action, index: true - t.integer :author_id, index: true - - t.index [:project_id, :id] - end - - Event.all.each_batch do |relation| - start_id, stop_id = relation.pluck('MIN(id), MAX(id)').first - - execute <<-EOF.strip_heredoc - INSERT INTO events_for_migration (target_type, target_id, project_id, created_at, updated_at, action, author_id) - SELECT target_type, target_id, project_id, created_at, updated_at, action, author_id - FROM events - WHERE id BETWEEN #{start_id} AND #{stop_id} - EOF - end - end -end diff --git a/db/post_migrate/20170831195038_remove_valid_signature_from_gpg_signatures.rb b/db/post_migrate/20170831195038_remove_valid_signature_from_gpg_signatures.rb deleted file mode 100644 index 8e264c1ab41..00000000000 --- a/db/post_migrate/20170831195038_remove_valid_signature_from_gpg_signatures.rb +++ /dev/null @@ -1,11 +0,0 @@ -class RemoveValidSignatureFromGpgSignatures < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - remove_column :gpg_signatures, :valid_signature - end - - def down - add_column :gpg_signatures, :valid_signature, :boolean - end -end diff --git a/db/post_migrate/20170907170235_delete_conflicting_redirect_routes.rb b/db/post_migrate/20170907170235_delete_conflicting_redirect_routes.rb deleted file mode 100644 index 95abf2474dd..00000000000 --- a/db/post_migrate/20170907170235_delete_conflicting_redirect_routes.rb +++ /dev/null @@ -1,13 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class DeleteConflictingRedirectRoutes < ActiveRecord::Migration[4.2] - def up - # No-op. - # See https://gitlab.com/gitlab-com/infrastructure/issues/3460#note_53223252 - end - - def down - # nothing - end -end diff --git a/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb b/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb deleted file mode 100644 index bbc624ac7c0..00000000000 --- a/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb +++ /dev/null @@ -1,33 +0,0 @@ -class FixProjectsWithoutProjectFeature < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - # Deletes corrupted project features - sql = "DELETE FROM project_features WHERE project_id IS NULL" - execute(sql) - - # Creates missing project features with private visibility - sql = - %Q{ - INSERT INTO project_features(project_id, repository_access_level, issues_access_level, merge_requests_access_level, wiki_access_level, - builds_access_level, snippets_access_level, created_at, updated_at) - SELECT projects.id as project_id, - 10 as repository_access_level, - 10 as issues_access_level, - 10 as merge_requests_access_level, - 10 as wiki_access_level, - 10 as builds_access_level , - 10 as snippets_access_level, - projects.created_at, - projects.updated_at - FROM projects - LEFT OUTER JOIN project_features ON project_features.project_id = projects.id - WHERE (project_features.id IS NULL) - } - - execute(sql) - end - - def down - end -end diff --git a/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb b/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb deleted file mode 100644 index 9080acee1d6..00000000000 --- a/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class NormalizeLdapExternUids < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - MIGRATION = 'NormalizeLdapExternUidsRange'.freeze - DELAY_INTERVAL = 10.seconds - - disable_ddl_transaction! - - class Identity < ActiveRecord::Base - include EachBatch - - self.table_name = 'identities' - end - - def up - ldap_identities = Identity.where("provider like 'ldap%'") - - if ldap_identities.any? - queue_background_migration_jobs_by_range_at_intervals(Identity, MIGRATION, DELAY_INTERVAL) - end - end - - def down - end -end diff --git a/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb b/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb deleted file mode 100644 index 83c21c203e0..00000000000 --- a/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class UpdateLegacyDiffNotesTypeForImport < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - update_column_in_batches(:notes, :type, 'LegacyDiffNote') do |table, query| - query.where(table[:type].eq('Github::Import::LegacyDiffNote')) - end - end - - def down - end -end diff --git a/db/post_migrate/20170927112319_update_notes_type_for_import.rb b/db/post_migrate/20170927112319_update_notes_type_for_import.rb deleted file mode 100644 index 8c691de3192..00000000000 --- a/db/post_migrate/20170927112319_update_notes_type_for_import.rb +++ /dev/null @@ -1,17 +0,0 @@ -# rubocop:disable Migration/UpdateLargeTable -class UpdateNotesTypeForImport < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - update_column_in_batches(:notes, :type, 'Note') do |table, query| - query.where(table[:type].eq('Github::Import::Note')) - end - end - - def down - end -end diff --git a/db/post_migrate/20171012150314_remove_user_authentication_token.rb b/db/post_migrate/20171012150314_remove_user_authentication_token.rb deleted file mode 100644 index 9313986ce85..00000000000 --- a/db/post_migrate/20171012150314_remove_user_authentication_token.rb +++ /dev/null @@ -1,20 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveUserAuthenticationToken < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - remove_column :users, :authentication_token - end - - def down - add_column :users, :authentication_token, :string - - add_concurrent_index :users, :authentication_token, unique: true - end -end diff --git a/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb b/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb deleted file mode 100644 index 9c90aa611a4..00000000000 --- a/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb +++ /dev/null @@ -1,98 +0,0 @@ -class MigrateGcpClustersToNewClustersArchitectures < ActiveRecord::Migration[4.2] - DOWNTIME = false - - class GcpCluster < ActiveRecord::Base - self.table_name = 'gcp_clusters' - - belongs_to :project, class_name: 'Project' - - include EachBatch - end - - class Cluster < ActiveRecord::Base - self.table_name = 'clusters' - - has_many :cluster_projects, class_name: 'ClustersProject' - has_many :projects, through: :cluster_projects, class_name: 'Project' - has_one :provider_gcp, class_name: 'ProvidersGcp' - has_one :platform_kubernetes, class_name: 'PlatformsKubernetes' - - accepts_nested_attributes_for :provider_gcp - accepts_nested_attributes_for :platform_kubernetes - - enum platform_type: { - kubernetes: 1 - } - - enum provider_type: { - user: 0, - gcp: 1 - } - end - - class Project < ActiveRecord::Base - self.table_name = 'projects' - - has_one :cluster_project, class_name: 'ClustersProject' - has_one :cluster, through: :cluster_project, class_name: 'Cluster' - end - - class ClustersProject < ActiveRecord::Base - self.table_name = 'cluster_projects' - - belongs_to :cluster, class_name: 'Cluster' - belongs_to :project, class_name: 'Project' - end - - class ProvidersGcp < ActiveRecord::Base - self.table_name = 'cluster_providers_gcp' - end - - class PlatformsKubernetes < ActiveRecord::Base - self.table_name = 'cluster_platforms_kubernetes' - end - - def up - GcpCluster.all.find_each(batch_size: 1) do |gcp_cluster| - Cluster.create( - enabled: gcp_cluster.enabled, - user_id: gcp_cluster.user_id, - name: gcp_cluster.gcp_cluster_name, - provider_type: Cluster.provider_types[:gcp], - platform_type: Cluster.platform_types[:kubernetes], - projects: [gcp_cluster.project], - provider_gcp_attributes: { - status: gcp_cluster.status, - status_reason: gcp_cluster.status_reason, - gcp_project_id: gcp_cluster.gcp_project_id, - zone: gcp_cluster.gcp_cluster_zone, - num_nodes: gcp_cluster.gcp_cluster_size, - machine_type: gcp_cluster.gcp_machine_type, - operation_id: gcp_cluster.gcp_operation_id, - endpoint: gcp_cluster.endpoint, - encrypted_access_token: gcp_cluster.encrypted_gcp_token, - encrypted_access_token_iv: gcp_cluster.encrypted_gcp_token_iv - }, - platform_kubernetes_attributes: { - api_url: api_url(gcp_cluster.endpoint), - ca_cert: gcp_cluster.ca_cert, - namespace: gcp_cluster.project_namespace, - username: gcp_cluster.username, - encrypted_password: gcp_cluster.encrypted_password, - encrypted_password_iv: gcp_cluster.encrypted_password_iv, - encrypted_token: gcp_cluster.encrypted_kubernetes_token, - encrypted_token_iv: gcp_cluster.encrypted_kubernetes_token_iv - } ) - end - end - - def down - execute('DELETE FROM clusters') - end - - private - - def api_url(endpoint) - endpoint ? 'https://' + endpoint : nil - end -end diff --git a/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb b/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb deleted file mode 100644 index 764561de997..00000000000 --- a/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb +++ /dev/null @@ -1,29 +0,0 @@ -class ScheduleMergeRequestLatestMergeRequestDiffIdMigrations < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - BATCH_SIZE = 50_000 - MIGRATION = 'PopulateMergeRequestsLatestMergeRequestDiffId' - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' - - include ::EachBatch - end - - # On GitLab.com, we saw that we generated about 500,000 dead tuples over 5 minutes. - # To keep replication lag from ballooning, we'll aim for 50,000 updates over 5 minutes. - # - # Assuming that there are 5 million rows affected (which is more than on - # GitLab.com), and that each batch of 50,000 rows takes up to 5 minutes, then - # we can migrate all the rows in 8.5 hours. - def up - MergeRequest.where(latest_merge_request_diff_id: nil).each_batch(of: BATCH_SIZE) do |relation, index| - range = relation.pluck('MIN(id)', 'MAX(id)').first - - BackgroundMigrationWorker.perform_in(index * 5.minutes, MIGRATION, range) - end - end -end diff --git a/db/post_migrate/20171101134435_remove_ref_fetched_from_merge_requests.rb b/db/post_migrate/20171101134435_remove_ref_fetched_from_merge_requests.rb deleted file mode 100644 index e6a5ffc8649..00000000000 --- a/db/post_migrate/20171101134435_remove_ref_fetched_from_merge_requests.rb +++ /dev/null @@ -1,14 +0,0 @@ -class RemoveRefFetchedFromMergeRequests < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - # We don't need to cache this anymore: the refs are now created - # upon save/update and there is no more use for this flag - # - # See https://gitlab.com/gitlab-org/gitlab-ce/issues/36061 - def change - remove_column :merge_requests, :ref_fetched, :boolean - end -end diff --git a/db/post_migrate/20171103140253_track_untracked_uploads.rb b/db/post_migrate/20171103140253_track_untracked_uploads.rb deleted file mode 100644 index 6891ef5ba12..00000000000 --- a/db/post_migrate/20171103140253_track_untracked_uploads.rb +++ /dev/null @@ -1,21 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class TrackUntrackedUploads < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - MIGRATION = 'PrepareUntrackedUploads' - - def up - BackgroundMigrationWorker.perform_async(MIGRATION) - end - - def down - if table_exists?(:untracked_files_for_uploads) - drop_table :untracked_files_for_uploads - end - end -end diff --git a/db/post_migrate/20171106133144_cleanup_application_settings_password_authentication_enabled_rename.rb b/db/post_migrate/20171106133144_cleanup_application_settings_password_authentication_enabled_rename.rb deleted file mode 100644 index 4a01bf75f50..00000000000 --- a/db/post_migrate/20171106133144_cleanup_application_settings_password_authentication_enabled_rename.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CleanupApplicationSettingsPasswordAuthenticationEnabledRename < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :application_settings, :password_authentication_enabled, :password_authentication_enabled_for_web - end - - def down - rename_column_concurrently :application_settings, :password_authentication_enabled_for_web, :password_authentication_enabled - end -end diff --git a/db/post_migrate/20171106154015_remove_issues_branch_name.rb b/db/post_migrate/20171106154015_remove_issues_branch_name.rb deleted file mode 100644 index 4e71aa2f163..00000000000 --- a/db/post_migrate/20171106154015_remove_issues_branch_name.rb +++ /dev/null @@ -1,13 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveIssuesBranchName < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - remove_column :issues, :branch_name, :string - end -end diff --git a/db/post_migrate/20171106180641_cleanup_add_timezone_to_issues_closed_at.rb b/db/post_migrate/20171106180641_cleanup_add_timezone_to_issues_closed_at.rb deleted file mode 100644 index 8187d3971fc..00000000000 --- a/db/post_migrate/20171106180641_cleanup_add_timezone_to_issues_closed_at.rb +++ /dev/null @@ -1,20 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CleanupAddTimezoneToIssuesClosedAt < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - cleanup_concurrent_column_type_change(:issues, :closed_at) - end - - # rubocop:disable Migration/Datetime - # rubocop:disable Migration/UpdateLargeTable - def down - change_column_type_concurrently(:issues, :closed_at, :datetime) - end -end diff --git a/db/post_migrate/20171114104051_remove_empty_fork_networks.rb b/db/post_migrate/20171114104051_remove_empty_fork_networks.rb deleted file mode 100644 index 76862cccf60..00000000000 --- a/db/post_migrate/20171114104051_remove_empty_fork_networks.rb +++ /dev/null @@ -1,36 +0,0 @@ -class RemoveEmptyForkNetworks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - BATCH_SIZE = 10_000 - - class MigrationForkNetwork < ActiveRecord::Base - include EachBatch - - self.table_name = 'fork_networks' - end - - class MigrationForkNetworkMembers < ActiveRecord::Base - self.table_name = 'fork_network_members' - end - - disable_ddl_transaction! - - def up - say 'Deleting empty ForkNetworks in batches' - - has_members = MigrationForkNetworkMembers - .where('fork_network_members.fork_network_id = fork_networks.id') - .select(1) - MigrationForkNetwork.where('NOT EXISTS (?)', has_members) - .each_batch(of: BATCH_SIZE) do |networks| - deleted = networks.delete_all - - say "Deleted #{deleted} rows in batch" - end - end - - def down - # nothing - end -end diff --git a/db/post_migrate/20171121160421_remove_merge_request_diff_st_commits_and_st_diffs.rb b/db/post_migrate/20171121160421_remove_merge_request_diff_st_commits_and_st_diffs.rb deleted file mode 100644 index 93a97993f1f..00000000000 --- a/db/post_migrate/20171121160421_remove_merge_request_diff_st_commits_and_st_diffs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class RemoveMergeRequestDiffStCommitsAndStDiffs < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - remove_column :merge_request_diffs, :st_commits, :text - remove_column :merge_request_diffs, :st_diffs, :text - end -end diff --git a/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb b/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb deleted file mode 100644 index ae954289291..00000000000 --- a/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb +++ /dev/null @@ -1,34 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class UpdateCircuitbreakerDefaults < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - class ApplicationSetting < ActiveRecord::Base; end - - def up - change_column_default :application_settings, - :circuitbreaker_failure_count_threshold, - 3 - change_column_default :application_settings, - :circuitbreaker_storage_timeout, - 15 - - ApplicationSetting.update_all(circuitbreaker_failure_count_threshold: 3, - circuitbreaker_storage_timeout: 15) - end - - def down - change_column_default :application_settings, - :circuitbreaker_failure_count_threshold, - 160 - change_column_default :application_settings, - :circuitbreaker_storage_timeout, - 30 - - ApplicationSetting.update_all(circuitbreaker_failure_count_threshold: 160, - circuitbreaker_storage_timeout: 30) - end -end diff --git a/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb b/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb deleted file mode 100644 index 3f2c1b2170a..00000000000 --- a/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb +++ /dev/null @@ -1,26 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveOldCircuitbreakerConfig < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - remove_column :application_settings, - :circuitbreaker_backoff_threshold - remove_column :application_settings, - :circuitbreaker_failure_wait_time - end - - def down - add_column :application_settings, - :circuitbreaker_backoff_threshold, - :integer, - default: 80 - add_column :application_settings, - :circuitbreaker_failure_wait_time, - :integer, - default: 30 - end -end diff --git a/db/post_migrate/20171124095655_add_index_on_merge_request_diffs_merge_request_id_and_id.rb b/db/post_migrate/20171124095655_add_index_on_merge_request_diffs_merge_request_id_and_id.rb deleted file mode 100644 index 2c65a4ae4f5..00000000000 --- a/db/post_migrate/20171124095655_add_index_on_merge_request_diffs_merge_request_id_and_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddIndexOnMergeRequestDiffsMergeRequestIdAndId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index(:merge_request_diffs, [:merge_request_id, :id]) - end - - def down - if index_exists?(:merge_request_diffs, [:merge_request_id, :id]) - remove_concurrent_index(:merge_request_diffs, [:merge_request_id, :id]) - end - end -end diff --git a/db/post_migrate/20171124100152_remove_index_on_merge_request_diffs_merge_request_diff_id.rb b/db/post_migrate/20171124100152_remove_index_on_merge_request_diffs_merge_request_diff_id.rb deleted file mode 100644 index efd3714d668..00000000000 --- a/db/post_migrate/20171124100152_remove_index_on_merge_request_diffs_merge_request_diff_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -class RemoveIndexOnMergeRequestDiffsMergeRequestDiffId < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - if index_exists?(:merge_request_diffs, :merge_request_id) - remove_concurrent_index(:merge_request_diffs, :merge_request_id) - end - end - - def down - add_concurrent_index(:merge_request_diffs, :merge_request_id) - end -end diff --git a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb deleted file mode 100644 index 58ceefe3c97..00000000000 --- a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb +++ /dev/null @@ -1,151 +0,0 @@ -class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME = 'KubernetesService'.freeze - - disable_ddl_transaction! - - class Project < ActiveRecord::Base - self.table_name = 'projects' - - has_many :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject' - has_many :clusters, through: :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' - has_many :services, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Service' - has_one :kubernetes_service, -> { where(category: 'deployment', type: 'KubernetesService') }, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Service', inverse_of: :project, foreign_key: :project_id - end - - class Cluster < ActiveRecord::Base - self.table_name = 'clusters' - - has_many :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject' - has_many :projects, through: :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project' - has_one :platform_kubernetes, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::PlatformsKubernetes' - - accepts_nested_attributes_for :platform_kubernetes - - enum platform_type: { - kubernetes: 1 - } - - enum provider_type: { - user: 0, - gcp: 1 - } - end - - class ClustersProject < ActiveRecord::Base - self.table_name = 'cluster_projects' - - belongs_to :cluster, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' - belongs_to :project, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project' - end - - class PlatformsKubernetes < ActiveRecord::Base - self.table_name = 'cluster_platforms_kubernetes' - - belongs_to :cluster, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' - - attr_encrypted :token, - mode: :per_attribute_iv, - key: Settings.attr_encrypted_db_key_base_truncated, - algorithm: 'aes-256-cbc' - end - - class Service < ActiveRecord::Base - include EachBatch - - self.table_name = 'services' - self.inheritance_column = :_type_disabled # Disable STI, otherwise KubernetesModel will be looked up - - belongs_to :project, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project', foreign_key: :project_id - - scope :unmanaged_kubernetes_service, -> do - joins('LEFT JOIN projects ON projects.id = services.project_id') - .joins('LEFT JOIN cluster_projects ON cluster_projects.project_id = projects.id') - .joins('LEFT JOIN cluster_platforms_kubernetes ON cluster_platforms_kubernetes.cluster_id = cluster_projects.cluster_id') - .where(category: 'deployment', type: 'KubernetesService', template: false) - .where("services.properties LIKE '%api_url%'") - .where("(services.properties NOT LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')) OR cluster_platforms_kubernetes.api_url IS NULL") - .group(:id) - .order(id: :asc) - end - - scope :kubernetes_service_without_template, -> do - where(category: 'deployment', type: 'KubernetesService', template: false) - end - - def api_url - parsed_properties['api_url'] - end - - def ca_pem - parsed_properties['ca_pem'] - end - - def namespace - parsed_properties['namespace'] - end - - def token - parsed_properties['token'] - end - - private - - def parsed_properties - @parsed_properties ||= JSON.parse(self.properties) - end - end - - def find_dedicated_environement_scope(project) - environment_scopes = project.clusters.map(&:environment_scope) - - return '*' if environment_scopes.exclude?('*') # KubernetesService should be added as a default cluster (environment_scope: '*') at first place - return 'migrated/*' if environment_scopes.exclude?('migrated/*') # If it's conflicted, the KubernetesService added as a migrated cluster - - unique_iid = 0 - - # If it's still conflicted, finding an unique environment scope incrementaly - loop do - candidate = "migrated#{unique_iid}/*" - return candidate if environment_scopes.exclude?(candidate) - - unique_iid += 1 - end - end - - def up - ActiveRecord::Base.transaction do - MigrateKubernetesServiceToNewClustersArchitectures::Service - .unmanaged_kubernetes_service.find_each(batch_size: 1) do |kubernetes_service| - MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create( - enabled: kubernetes_service.active, - user_id: nil, # KubernetesService doesn't have - name: DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME, - provider_type: MigrateKubernetesServiceToNewClustersArchitectures::Cluster.provider_types[:user], - platform_type: MigrateKubernetesServiceToNewClustersArchitectures::Cluster.platform_types[:kubernetes], - projects: [kubernetes_service.project], - environment_scope: find_dedicated_environement_scope(kubernetes_service.project), - platform_kubernetes_attributes: { - api_url: kubernetes_service.api_url, - ca_cert: kubernetes_service.ca_pem, - namespace: kubernetes_service.namespace, - username: nil, # KubernetesService doesn't have - encrypted_password: nil, # KubernetesService doesn't have - encrypted_password_iv: nil, # KubernetesService doesn't have - token: kubernetes_service.token # encrypted_token and encrypted_token_iv - } ) - end - end - - MigrateKubernetesServiceToNewClustersArchitectures::Service - .kubernetes_service_without_template.each_batch(of: 100) do |kubernetes_service| - kubernetes_service.update_all(active: false) - end - end - - def down - # noop - end -end diff --git a/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb b/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb deleted file mode 100644 index 8e320ea9e8d..00000000000 --- a/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb +++ /dev/null @@ -1,13 +0,0 @@ -class RescheduleForkNetworkCreation < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - say 'Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller' - end - - def down - # nothing - end -end diff --git a/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb b/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb deleted file mode 100644 index 058f3a40817..00000000000 --- a/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb +++ /dev/null @@ -1,27 +0,0 @@ -class RescheduleForkNetworkCreationCaller < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - MIGRATION = 'PopulateForkNetworksRange'.freeze - BATCH_SIZE = 100 - DELAY_INTERVAL = 15.seconds - - disable_ddl_transaction! - - class ForkedProjectLink < ActiveRecord::Base - include EachBatch - - self.table_name = 'forked_project_links' - end - - def up - say 'Populating the `fork_networks` based on existing `forked_project_links`' - - queue_background_migration_jobs_by_range_at_intervals(ForkedProjectLink, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) - end - - def down - # nothing - end -end diff --git a/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb b/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb deleted file mode 100644 index 44273cebc9d..00000000000 --- a/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Copy of 20180202111106 - this one should run before 20171207150343 to fix issues related to -# the removal of groups with labels. - -class RemoveProjectLabelsGroupIdCopy < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - # rubocop:disable Migration/UpdateColumnInBatches - update_column_in_batches(:labels, :group_id, nil) do |table, query| - query.where(table[:type].eq('ProjectLabel').and(table[:group_id].not_eq(nil))) - end - # rubocop:enable Migration/UpdateColumnInBatches - end - - def down - end -end diff --git a/db/post_migrate/20171207150344_remove_deleted_at_columns.rb b/db/post_migrate/20171207150344_remove_deleted_at_columns.rb deleted file mode 100644 index 5f1c70a2797..00000000000 --- a/db/post_migrate/20171207150344_remove_deleted_at_columns.rb +++ /dev/null @@ -1,31 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveDeletedAtColumns < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - TABLES = %i[issues merge_requests namespaces ci_pipeline_schedules ci_triggers].freeze - COLUMN = :deleted_at - - def up - TABLES.each do |table| - remove_column(table, COLUMN) if column_exists?(table, COLUMN) - end - end - - def down - TABLES.each do |table| - unless column_exists?(table, COLUMN) - add_column(table, COLUMN, :datetime_with_timezone) - end - - unless index_exists?(table, COLUMN) - add_concurrent_index(table, COLUMN) - end - end - end -end diff --git a/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb b/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb deleted file mode 100644 index 088c4b5d46b..00000000000 --- a/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb +++ /dev/null @@ -1,16 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MigrateGithubImporterAdvanceStageSidekiqQueue < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - sidekiq_queue_migrate 'github_importer_advance_stage', to: 'github_import_advance_stage' - end - - def down - sidekiq_queue_migrate 'github_import_advance_stage', to: 'github_importer_advance_stage' - end -end diff --git a/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb b/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb deleted file mode 100644 index 1c81e56db55..00000000000 --- a/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb +++ /dev/null @@ -1,63 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class PostPopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - DATABASE_NAME = Gitlab::Database.database_name - - disable_ddl_transaction! - - class DeploysKeyProject < ActiveRecord::Base - include EachBatch - - self.table_name = 'deploy_keys_projects' - end - - def up - DeploysKeyProject.each_batch(of: 10_000) do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first - - if Gitlab::Database.mysql? - execute <<-EOF.strip_heredoc - UPDATE deploy_keys_projects, #{DATABASE_NAME}.keys - SET deploy_keys_projects.can_push = #{DATABASE_NAME}.keys.can_push - WHERE deploy_keys_projects.deploy_key_id = #{DATABASE_NAME}.keys.id - AND deploy_keys_projects.id BETWEEN #{start_id} AND #{end_id} - EOF - else - execute <<-EOF.strip_heredoc - UPDATE deploy_keys_projects - SET can_push = keys.can_push - FROM keys - WHERE deploy_key_id = keys.id - AND deploy_keys_projects.id BETWEEN #{start_id} AND #{end_id} - EOF - end - end - end - - def down - DeploysKeyProject.each_batch(of: 10_000) do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first - - if Gitlab::Database.mysql? - execute <<-EOF.strip_heredoc - UPDATE deploy_keys_projects, #{DATABASE_NAME}.keys - SET #{DATABASE_NAME}.keys.can_push = deploy_keys_projects.can_push - WHERE deploy_keys_projects.deploy_key_id = #{DATABASE_NAME}.keys.id - AND deploy_keys_projects.id BETWEEN #{start_id} AND #{end_id} - EOF - else - execute <<-EOF.strip_heredoc - UPDATE keys - SET can_push = deploy_keys_projects.can_push - FROM deploy_keys_projects - WHERE deploy_keys_projects.deploy_key_id = keys.id - AND deploy_keys_projects.id BETWEEN #{start_id} AND #{end_id} - EOF - end - end - end -end diff --git a/db/post_migrate/20171215121259_remove_can_push_from_keys.rb b/db/post_migrate/20171215121259_remove_can_push_from_keys.rb deleted file mode 100644 index fc4045a383d..00000000000 --- a/db/post_migrate/20171215121259_remove_can_push_from_keys.rb +++ /dev/null @@ -1,17 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveCanPushFromKeys < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - disable_ddl_transaction! - - def up - remove_column :keys, :can_push - end - - def down - add_column_with_default :keys, :can_push, :boolean, default: false, allow_null: false - end -end diff --git a/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb b/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb deleted file mode 100644 index 45ef75fdb98..00000000000 --- a/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class NormalizeExternUidFromIdentities < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - MIGRATION = 'NormalizeLdapExternUidsRange'.freeze - DELAY_INTERVAL = 10.seconds - - disable_ddl_transaction! - - class Identity < ActiveRecord::Base - include EachBatch - - self.table_name = 'identities' - end - - def up - ldap_identities = Identity.where("provider like 'ldap%'") - - if ldap_identities.any? - queue_background_migration_jobs_by_range_at_intervals(Identity, MIGRATION, DELAY_INTERVAL) - end - end - - def down - end -end diff --git a/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb b/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb deleted file mode 100644 index 6b5e6202688..00000000000 --- a/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb +++ /dev/null @@ -1,45 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. -# rubocop:disable Migration/Datetime -class ScheduleIssuesClosedAtTypeChange < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class Issue < ActiveRecord::Base - self.table_name = 'issues' - include EachBatch - - def self.to_migrate - where('closed_at IS NOT NULL') - end - end - - def up - return unless migrate_column_type? - - change_column_type_using_background_migration( - Issue.to_migrate, - :closed_at, - :datetime_with_timezone - ) - end - - def down - return if migrate_column_type? - - change_column_type_using_background_migration( - Issue.to_migrate, - :closed_at, - :datetime - ) - end - - def migrate_column_type? - # Some environments may have already executed the previous version of this - # migration, thus we don't need to migrate those environments again. - column_for('issues', 'closed_at').type == :datetime - end -end diff --git a/lib/gitlab/background_migration/create_fork_network_memberships_range.rb b/lib/gitlab/background_migration/create_fork_network_memberships_range.rb deleted file mode 100644 index ccd1f9b4dba..00000000000 --- a/lib/gitlab/background_migration/create_fork_network_memberships_range.rb +++ /dev/null @@ -1,85 +0,0 @@ -# frozen_string_literal: true -# rubocop:disable Style/Documentation - -module Gitlab - module BackgroundMigration - class CreateForkNetworkMembershipsRange - RESCHEDULE_DELAY = 15 - - class ForkedProjectLink < ActiveRecord::Base - self.table_name = 'forked_project_links' - end - - def perform(start_id, end_id) - log("Creating memberships for forks: #{start_id} - #{end_id}") - - insert_members(start_id, end_id) - - if missing_members?(start_id, end_id) - BackgroundMigrationWorker.perform_in(RESCHEDULE_DELAY, "CreateForkNetworkMembershipsRange", [start_id, end_id]) - end - end - - def insert_members(start_id, end_id) - ActiveRecord::Base.connection.execute <<~INSERT_MEMBERS - INSERT INTO fork_network_members (fork_network_id, project_id, forked_from_project_id) - - SELECT fork_network_members.fork_network_id, - forked_project_links.forked_to_project_id, - forked_project_links.forked_from_project_id - - FROM forked_project_links - - INNER JOIN fork_network_members - ON forked_project_links.forked_from_project_id = fork_network_members.project_id - - WHERE forked_project_links.id BETWEEN #{start_id} AND #{end_id} - AND NOT EXISTS ( - SELECT true - FROM fork_network_members existing_members - WHERE existing_members.project_id = forked_project_links.forked_to_project_id - ) - INSERT_MEMBERS - rescue ActiveRecord::RecordNotUnique => e - # `fork_network_member` was created concurrently in another migration - log(e.message) - end - - def missing_members?(start_id, end_id) - count_sql = <<~MISSING_MEMBERS - SELECT COUNT(*) - - FROM forked_project_links - - WHERE NOT EXISTS ( - SELECT true - FROM fork_network_members - WHERE fork_network_members.project_id = forked_project_links.forked_to_project_id - ) - AND EXISTS ( - SELECT true - FROM projects - WHERE forked_project_links.forked_from_project_id = projects.id - ) - AND NOT EXISTS ( - SELECT true - FROM forked_project_links AS parent_links - WHERE parent_links.forked_to_project_id = forked_project_links.forked_from_project_id - AND NOT EXISTS ( - SELECT true - FROM projects - WHERE parent_links.forked_from_project_id = projects.id - ) - ) - AND forked_project_links.id BETWEEN #{start_id} AND #{end_id} - MISSING_MEMBERS - - ForkedProjectLink.count_by_sql(count_sql) > 0 - end - - def log(message) - Rails.logger.info("#{self.class.name} - #{message}") - end - end - end -end diff --git a/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb b/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb deleted file mode 100644 index 21b626dde56..00000000000 --- a/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true -# rubocop:disable Style/Documentation - -module Gitlab - module BackgroundMigration - class DeleteConflictingRedirectRoutesRange - def perform(start_id, end_id) - # No-op. - # See https://gitlab.com/gitlab-com/infrastructure/issues/3460#note_53223252 - end - end - end -end diff --git a/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb b/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb deleted file mode 100644 index 42fcaa87e66..00000000000 --- a/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb +++ /dev/null @@ -1,179 +0,0 @@ -# frozen_string_literal: true -# rubocop:disable Style/Documentation - -module Gitlab - module BackgroundMigration - # Class that migrates events for the new push event payloads setup. All - # events are copied to a shadow table, and push events will also have a row - # created in the push_event_payloads table. - class MigrateEventsToPushEventPayloads - class Event < ActiveRecord::Base - self.table_name = 'events' - - serialize :data - - BLANK_REF = ('0' * 40).freeze - TAG_REF_PREFIX = 'refs/tags/'.freeze - MAX_INDEX = 69 - PUSHED = 5 - - def push_event? - action == PUSHED && data.present? - end - - def commit_title - commit = commits.last - - return unless commit && commit[:message] - - index = commit[:message].index("\n") - message = index ? commit[:message][0..index] : commit[:message] - - message.strip.truncate(70) - end - - def commit_from_sha - if create? - nil - else - data[:before] - end - end - - def commit_to_sha - if remove? - nil - else - data[:after] - end - end - - def data - super || {} - end - - def commits - data[:commits] || [] - end - - def commit_count - data[:total_commits_count] || 0 - end - - def ref - data[:ref] - end - - def trimmed_ref_name - if ref_type == :tag - ref[10..-1] - else - ref[11..-1] - end - end - - def create? - data[:before] == BLANK_REF - end - - def remove? - data[:after] == BLANK_REF - end - - def push_action - if create? - :created - elsif remove? - :removed - else - :pushed - end - end - - def ref_type - if ref.start_with?(TAG_REF_PREFIX) - :tag - else - :branch - end - end - end - - class EventForMigration < ActiveRecord::Base - self.table_name = 'events_for_migration' - end - - class PushEventPayload < ActiveRecord::Base - self.table_name = 'push_event_payloads' - - enum action: { - created: 0, - removed: 1, - pushed: 2 - } - - enum ref_type: { - branch: 0, - tag: 1 - } - end - - # start_id - The start ID of the range of events to process - # end_id - The end ID of the range to process. - def perform(start_id, end_id) - return unless migrate? - - find_events(start_id, end_id).each { |event| process_event(event) } - end - - def process_event(event) - ActiveRecord::Base.transaction do - replicate_event(event) - create_push_event_payload(event) if event.push_event? - end - rescue ActiveRecord::InvalidForeignKey => e - # A foreign key error means the associated event was removed. In this - # case we'll just skip migrating the event. - Rails.logger.error("Unable to migrate event #{event.id}: #{e}") - end - - def replicate_event(event) - new_attributes = event.attributes - .with_indifferent_access.except(:title, :data) - - EventForMigration.create!(new_attributes) - end - - def create_push_event_payload(event) - commit_from = pack(event.commit_from_sha) - commit_to = pack(event.commit_to_sha) - - PushEventPayload.create!( - event_id: event.id, - commit_count: event.commit_count, - ref_type: event.ref_type, - action: event.push_action, - commit_from: commit_from, - commit_to: commit_to, - ref: event.trimmed_ref_name, - commit_title: event.commit_title - ) - end - - def find_events(start_id, end_id) - Event - .where('NOT EXISTS (SELECT true FROM events_for_migration WHERE events_for_migration.id = events.id)') - .where(id: start_id..end_id) - end - - def migrate? - Event.table_exists? && PushEventPayload.table_exists? && - EventForMigration.table_exists? - end - - def pack(value) - value ? [value].pack('H*') : nil - end - end - end -end diff --git a/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb b/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb deleted file mode 100644 index 48aa369705f..00000000000 --- a/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb +++ /dev/null @@ -1,319 +0,0 @@ -# frozen_string_literal: true -# rubocop:disable Metrics/MethodLength -# rubocop:disable Metrics/ClassLength -# rubocop:disable Metrics/BlockLength -# rubocop:disable Style/Documentation - -module Gitlab - module BackgroundMigration - class NormalizeLdapExternUidsRange - class Identity < ActiveRecord::Base - self.table_name = 'identities' - end - - # Copied this class to make this migration resilient to future code changes. - # And if the normalize behavior is changed in the future, it must be - # accompanied by another migration. - module Gitlab - module Auth - module LDAP - class DN - FormatError = Class.new(StandardError) - MalformedError = Class.new(FormatError) - UnsupportedError = Class.new(FormatError) - - def self.normalize_value(given_value) - dummy_dn = "placeholder=#{given_value}" - normalized_dn = new(*dummy_dn).to_normalized_s - normalized_dn.sub(/\Aplaceholder=/, '') - end - - ## - # Initialize a DN, escaping as required. Pass in attributes in name/value - # pairs. If there is a left over argument, it will be appended to the dn - # without escaping (useful for a base string). - # - # Most uses of this class will be to escape a DN, rather than to parse it, - # so storing the dn as an escaped String and parsing parts as required - # with a state machine seems sensible. - def initialize(*args) - if args.length > 1 - initialize_array(args) - else - initialize_string(args[0]) - end - end - - ## - # Parse a DN into key value pairs using ASN from - # http://tools.ietf.org/html/rfc2253 section 3. - # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/CyclomaticComplexity - # rubocop:disable Metrics/PerceivedComplexity - def each_pair - state = :key - key = StringIO.new - value = StringIO.new - hex_buffer = "" - - @dn.each_char.with_index do |char, dn_index| - case state - when :key then - case char - when 'a'..'z', 'A'..'Z' then - state = :key_normal - key << char - when '0'..'9' then - state = :key_oid - key << char - when ' ' then state = :key - else raise(MalformedError, "Unrecognized first character of an RDN attribute type name \"#{char}\"") - end - when :key_normal then - case char - when '=' then state = :value - when 'a'..'z', 'A'..'Z', '0'..'9', '-', ' ' then key << char - else raise(MalformedError, "Unrecognized RDN attribute type name character \"#{char}\"") - end - when :key_oid then - case char - when '=' then state = :value - when '0'..'9', '.', ' ' then key << char - else raise(MalformedError, "Unrecognized RDN OID attribute type name character \"#{char}\"") - end - when :value then - case char - when '\\' then state = :value_normal_escape - when '"' then state = :value_quoted - when ' ' then state = :value - when '#' then - state = :value_hexstring - value << char - when ',' then - state = :key - yield key.string.strip, rstrip_except_escaped(value.string, dn_index) - key = StringIO.new - value = StringIO.new - else - state = :value_normal - value << char - end - when :value_normal then - case char - when '\\' then state = :value_normal_escape - when ',' then - state = :key - yield key.string.strip, rstrip_except_escaped(value.string, dn_index) - key = StringIO.new - value = StringIO.new - when '+' then raise(UnsupportedError, "Multivalued RDNs are not supported") - else value << char - end - when :value_normal_escape then - case char - when '0'..'9', 'a'..'f', 'A'..'F' then - state = :value_normal_escape_hex - hex_buffer = char - else - state = :value_normal - value << char - end - when :value_normal_escape_hex then - case char - when '0'..'9', 'a'..'f', 'A'..'F' then - state = :value_normal - value << "#{hex_buffer}#{char}".to_i(16).chr - else raise(MalformedError, "Invalid escaped hex code \"\\#{hex_buffer}#{char}\"") - end - when :value_quoted then - case char - when '\\' then state = :value_quoted_escape - when '"' then state = :value_end - else value << char - end - when :value_quoted_escape then - case char - when '0'..'9', 'a'..'f', 'A'..'F' then - state = :value_quoted_escape_hex - hex_buffer = char - else - state = :value_quoted - value << char - end - when :value_quoted_escape_hex then - case char - when '0'..'9', 'a'..'f', 'A'..'F' then - state = :value_quoted - value << "#{hex_buffer}#{char}".to_i(16).chr - else raise(MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"#{char}\"") - end - when :value_hexstring then - case char - when '0'..'9', 'a'..'f', 'A'..'F' then - state = :value_hexstring_hex - value << char - when ' ' then state = :value_end - when ',' then - state = :key - yield key.string.strip, rstrip_except_escaped(value.string, dn_index) - key = StringIO.new - value = StringIO.new - else raise(MalformedError, "Expected the first character of a hex pair, but got \"#{char}\"") - end - when :value_hexstring_hex then - case char - when '0'..'9', 'a'..'f', 'A'..'F' then - state = :value_hexstring - value << char - else raise(MalformedError, "Expected the second character of a hex pair, but got \"#{char}\"") - end - when :value_end then - case char - when ' ' then state = :value_end - when ',' then - state = :key - yield key.string.strip, rstrip_except_escaped(value.string, dn_index) - key = StringIO.new - value = StringIO.new - else raise(MalformedError, "Expected the end of an attribute value, but got \"#{char}\"") - end - else raise "Fell out of state machine" - end - end - - # Last pair - raise(MalformedError, 'DN string ended unexpectedly') unless - [:value, :value_normal, :value_hexstring, :value_end].include? state - - yield key.string.strip, rstrip_except_escaped(value.string, @dn.length) - end - - def rstrip_except_escaped(str, dn_index) - str_ends_with_whitespace = str.match(/\s\z/) - - if str_ends_with_whitespace - dn_part_ends_with_escaped_whitespace = @dn[0, dn_index].match(/\\(\s+)\z/) - - if dn_part_ends_with_escaped_whitespace - dn_part_rwhitespace = dn_part_ends_with_escaped_whitespace[1] - num_chars_to_remove = dn_part_rwhitespace.length - 1 - str = str[0, str.length - num_chars_to_remove] - else - str.rstrip! - end - end - - str - end - - ## - # Returns the DN as an array in the form expected by the constructor. - def to_a - a = [] - self.each_pair { |key, value| a << key << value } unless @dn.empty? - a - end - - ## - # Return the DN as an escaped string. - def to_s - @dn - end - - ## - # Return the DN as an escaped and normalized string. - def to_normalized_s - self.class.new(*to_a).to_s.downcase - end - - # https://tools.ietf.org/html/rfc4514 section 2.4 lists these exceptions - # for DN values. All of the following must be escaped in any normal string - # using a single backslash ('\') as escape. The space character is left - # out here because in a "normalized" string, spaces should only be escaped - # if necessary (i.e. leading or trailing space). - NORMAL_ESCAPES = [',', '+', '"', '\\', '<', '>', ';', '='].freeze - - # The following must be represented as escaped hex - HEX_ESCAPES = { - "\n" => '\0a', - "\r" => '\0d' - }.freeze - - # Compiled character class regexp using the keys from the above hash, and - # checking for a space or # at the start, or space at the end, of the - # string. - ESCAPE_RE = Regexp.new("(^ |^#| $|[" + - NORMAL_ESCAPES.map { |e| Regexp.escape(e) }.join + - "])") - - HEX_ESCAPE_RE = Regexp.new("([" + - HEX_ESCAPES.keys.map { |e| Regexp.escape(e) }.join + - "])") - - ## - # Escape a string for use in a DN value - def self.escape(string) - escaped = string.gsub(ESCAPE_RE) { |char| "\\" + char } - escaped.gsub(HEX_ESCAPE_RE) { |char| HEX_ESCAPES[char] } - end - - private - - def initialize_array(args) - buffer = StringIO.new - - args.each_with_index do |arg, index| - if index.even? # key - buffer << "," if index > 0 - buffer << arg - else # value - buffer << "=" - buffer << self.class.escape(arg) - end - end - - @dn = buffer.string - end - - def initialize_string(arg) - @dn = arg.to_s - end - - ## - # Proxy all other requests to the string object, because a DN is mainly - # used within the library as a string - # rubocop:disable GitlabSecurity/PublicSend - def method_missing(method, *args, &block) - @dn.send(method, *args, &block) - end - - ## - # Redefined to be consistent with redefined `method_missing` behavior - def respond_to?(sym, include_private = false) - @dn.respond_to?(sym, include_private) - end - end - end - end - end - - def perform(start_id, end_id) - return unless migrate? - - ldap_identities = Identity.where("provider like 'ldap%'").where(id: start_id..end_id) - ldap_identities.each do |identity| - identity.extern_uid = Gitlab::Auth::LDAP::DN.new(identity.extern_uid).to_normalized_s - unless identity.save - Rails.logger.info "Unable to normalize \"#{identity.extern_uid}\". Skipping." - end - rescue Gitlab::Auth::LDAP::DN::FormatError => e - Rails.logger.info "Unable to normalize \"#{identity.extern_uid}\" due to \"#{e.message}\". Skipping." - end - end - - def migrate? - Identity.table_exists? - end - end - end -end diff --git a/lib/gitlab/background_migration/populate_fork_networks_range.rb b/lib/gitlab/background_migration/populate_fork_networks_range.rb deleted file mode 100644 index aa4f130538c..00000000000 --- a/lib/gitlab/background_migration/populate_fork_networks_range.rb +++ /dev/null @@ -1,128 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module BackgroundMigration - # This background migration is going to create all `fork_networks` and - # the `fork_network_members` for the roots of fork networks based on the - # existing `forked_project_links`. - # - # When the source of a fork is deleted, we will create the fork with the - # target project as the root. This way, when there are forks of the target - # project, they will be joined into the same fork network. - # - # When the `fork_networks` and memberships for the root projects are created - # the `CreateForkNetworkMembershipsRange` migration is scheduled. This - # migration will create the memberships for all remaining forks-of-forks - class PopulateForkNetworksRange - def perform(start_id, end_id) - create_fork_networks_for_existing_projects(start_id, end_id) - create_fork_networks_for_missing_projects(start_id, end_id) - create_fork_networks_memberships_for_root_projects(start_id, end_id) - - delay = BackgroundMigration::CreateForkNetworkMembershipsRange::RESCHEDULE_DELAY - BackgroundMigrationWorker.perform_in( - delay, "CreateForkNetworkMembershipsRange", [start_id, end_id] - ) - end - - def create_fork_networks_for_existing_projects(start_id, end_id) - log("Creating fork networks: #{start_id} - #{end_id}") - ActiveRecord::Base.connection.execute <<~INSERT_NETWORKS - INSERT INTO fork_networks (root_project_id) - SELECT DISTINCT forked_project_links.forked_from_project_id - - FROM forked_project_links - - -- Exclude the forks that are not the first level fork of a project - WHERE NOT EXISTS ( - SELECT true - FROM forked_project_links inner_links - WHERE inner_links.forked_to_project_id = forked_project_links.forked_from_project_id - ) - - /* Exclude the ones that are already created, in case the fork network - was already created for another fork of the project. - */ - AND NOT EXISTS ( - SELECT true - FROM fork_networks - WHERE forked_project_links.forked_from_project_id = fork_networks.root_project_id - ) - - -- Only create a fork network for a root project that still exists - AND EXISTS ( - SELECT true - FROM projects - WHERE projects.id = forked_project_links.forked_from_project_id - ) - AND forked_project_links.id BETWEEN #{start_id} AND #{end_id} - INSERT_NETWORKS - end - - def create_fork_networks_for_missing_projects(start_id, end_id) - log("Creating fork networks with missing root: #{start_id} - #{end_id}") - ActiveRecord::Base.connection.execute <<~INSERT_NETWORKS - INSERT INTO fork_networks (root_project_id) - SELECT DISTINCT forked_project_links.forked_to_project_id - - FROM forked_project_links - - -- Exclude forks that are not the root forks - WHERE NOT EXISTS ( - SELECT true - FROM forked_project_links inner_links - WHERE inner_links.forked_to_project_id = forked_project_links.forked_from_project_id - ) - - /* Exclude the ones that are already created, in case this migration is - re-run - */ - AND NOT EXISTS ( - SELECT true - FROM fork_networks - WHERE forked_project_links.forked_to_project_id = fork_networks.root_project_id - ) - - /* Exclude projects for which the project still exists, those are - Processed in the previous step of this migration - */ - AND NOT EXISTS ( - SELECT true - FROM projects - WHERE projects.id = forked_project_links.forked_from_project_id - ) - AND forked_project_links.id BETWEEN #{start_id} AND #{end_id} - INSERT_NETWORKS - end - - def create_fork_networks_memberships_for_root_projects(start_id, end_id) - log("Creating memberships for root projects: #{start_id} - #{end_id}") - - ActiveRecord::Base.connection.execute <<~INSERT_ROOT - INSERT INTO fork_network_members (fork_network_id, project_id) - SELECT DISTINCT fork_networks.id, fork_networks.root_project_id - - FROM fork_networks - - /* Joining both on forked_from- and forked_to- so we could create the - memberships for forks for which the source was deleted - */ - INNER JOIN forked_project_links - ON forked_project_links.forked_from_project_id = fork_networks.root_project_id - OR forked_project_links.forked_to_project_id = fork_networks.root_project_id - - WHERE NOT EXISTS ( - SELECT true - FROM fork_network_members - WHERE fork_network_members.project_id = fork_networks.root_project_id - ) - AND forked_project_links.id BETWEEN #{start_id} AND #{end_id} - INSERT_ROOT - end - - def log(message) - Rails.logger.info("#{self.class.name} - #{message}") - end - end - end -end diff --git a/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb b/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb deleted file mode 100644 index dcac355e1b0..00000000000 --- a/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true -# rubocop:disable Style/Documentation - -module Gitlab - module BackgroundMigration - class PopulateMergeRequestsLatestMergeRequestDiffId - BATCH_SIZE = 1_000 - - class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' - - include ::EachBatch - end - - def perform(start_id, stop_id) - update = ' - latest_merge_request_diff_id = ( - SELECT MAX(id) - FROM merge_request_diffs - WHERE merge_requests.id = merge_request_diffs.merge_request_id - )'.squish - - MergeRequest - .where(id: start_id..stop_id) - .where(latest_merge_request_diff_id: nil) - .each_batch(of: BATCH_SIZE) do |relation| - - relation.update_all(update) - end - end - end - end -end diff --git a/lib/tasks/migrate/setup_postgresql.rake b/lib/tasks/migrate/setup_postgresql.rake index f69d204c579..cda88c130bb 100644 --- a/lib/tasks/migrate/setup_postgresql.rake +++ b/lib/tasks/migrate/setup_postgresql.rake @@ -1,23 +1,9 @@ desc 'GitLab | Sets up PostgreSQL' task setup_postgresql: :environment do - require Rails.root.join('db/migrate/20151007120511_namespaces_projects_path_lower_indexes') - require Rails.root.join('db/migrate/20151008110232_add_users_lower_username_email_indexes') - require Rails.root.join('db/migrate/20161212142807_add_lower_path_index_to_routes') - require Rails.root.join('db/migrate/20170317203554_index_routes_path_for_like') - require Rails.root.join('db/migrate/20170724214302_add_lower_path_index_to_redirect_routes') - require Rails.root.join('db/migrate/20170503185032_index_redirect_routes_path_for_like') - require Rails.root.join('db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb') require Rails.root.join('db/migrate/20180215181245_users_name_lower_index.rb') require Rails.root.join('db/migrate/20180504195842_project_name_lower_index.rb') require Rails.root.join('db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb') - NamespacesProjectsPathLowerIndexes.new.up - AddUsersLowerUsernameEmailIndexes.new.up - AddLowerPathIndexToRoutes.new.up - IndexRoutesPathForLike.new.up - AddLowerPathIndexToRedirectRoutes.new.up - IndexRedirectRoutesPathForLike.new.up - AddIndexOnNamespacesLowerName.new.up UsersNameLowerIndex.new.up ProjectNameLowerIndex.new.up AddPathIndexToRedirectRoutes.new.up diff --git a/spec/lib/gitlab/background_migration/create_fork_network_memberships_range_spec.rb b/spec/lib/gitlab/background_migration/create_fork_network_memberships_range_spec.rb deleted file mode 100644 index 5076996474f..00000000000 --- a/spec/lib/gitlab/background_migration/create_fork_network_memberships_range_spec.rb +++ /dev/null @@ -1,125 +0,0 @@ -require 'spec_helper' - -describe Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange, :migration, schema: 20170929131201 do - let(:migration) { described_class.new } - let(:projects) { table(:projects) } - - let(:base1) { projects.create } - let(:base1_fork1) { projects.create } - let(:base1_fork2) { projects.create } - - let(:base2) { projects.create } - let(:base2_fork1) { projects.create } - let(:base2_fork2) { projects.create } - - let(:fork_of_fork) { projects.create } - let(:fork_of_fork2) { projects.create } - let(:second_level_fork) { projects.create } - let(:third_level_fork) { projects.create } - - let(:fork_network1) { fork_networks.find_by(root_project_id: base1.id) } - let(:fork_network2) { fork_networks.find_by(root_project_id: base2.id) } - - let!(:forked_project_links) { table(:forked_project_links) } - let!(:fork_networks) { table(:fork_networks) } - let!(:fork_network_members) { table(:fork_network_members) } - - before do - # The fork-network relation created for the forked project - fork_networks.create(id: 1, root_project_id: base1.id) - fork_network_members.create(project_id: base1.id, fork_network_id: 1) - fork_networks.create(id: 2, root_project_id: base2.id) - fork_network_members.create(project_id: base2.id, fork_network_id: 2) - - # Normal fork links - forked_project_links.create(id: 1, forked_from_project_id: base1.id, forked_to_project_id: base1_fork1.id) - forked_project_links.create(id: 2, forked_from_project_id: base1.id, forked_to_project_id: base1_fork2.id) - forked_project_links.create(id: 3, forked_from_project_id: base2.id, forked_to_project_id: base2_fork1.id) - forked_project_links.create(id: 4, forked_from_project_id: base2.id, forked_to_project_id: base2_fork2.id) - - # Fork links - forked_project_links.create(id: 5, forked_from_project_id: base1_fork1.id, forked_to_project_id: fork_of_fork.id) - forked_project_links.create(id: 6, forked_from_project_id: base1_fork1.id, forked_to_project_id: fork_of_fork2.id) - - # Forks 3 levels down - forked_project_links.create(id: 7, forked_from_project_id: fork_of_fork.id, forked_to_project_id: second_level_fork.id) - forked_project_links.create(id: 8, forked_from_project_id: second_level_fork.id, forked_to_project_id: third_level_fork.id) - - migration.perform(1, 8) - end - - it 'creates a memberships for the direct forks' do - base1_fork1_membership = fork_network_members.find_by(fork_network_id: fork_network1.id, - project_id: base1_fork1.id) - base1_fork2_membership = fork_network_members.find_by(fork_network_id: fork_network1.id, - project_id: base1_fork2.id) - base2_fork1_membership = fork_network_members.find_by(fork_network_id: fork_network2.id, - project_id: base2_fork1.id) - base2_fork2_membership = fork_network_members.find_by(fork_network_id: fork_network2.id, - project_id: base2_fork2.id) - - expect(base1_fork1_membership.forked_from_project_id).to eq(base1.id) - expect(base1_fork2_membership.forked_from_project_id).to eq(base1.id) - expect(base2_fork1_membership.forked_from_project_id).to eq(base2.id) - expect(base2_fork2_membership.forked_from_project_id).to eq(base2.id) - end - - it 'adds the fork network members for forks of forks' do - fork_of_fork_membership = fork_network_members.find_by(project_id: fork_of_fork.id, - fork_network_id: fork_network1.id) - fork_of_fork2_membership = fork_network_members.find_by(project_id: fork_of_fork2.id, - fork_network_id: fork_network1.id) - second_level_fork_membership = fork_network_members.find_by(project_id: second_level_fork.id, - fork_network_id: fork_network1.id) - third_level_fork_membership = fork_network_members.find_by(project_id: third_level_fork.id, - fork_network_id: fork_network1.id) - - expect(fork_of_fork_membership.forked_from_project_id).to eq(base1_fork1.id) - expect(fork_of_fork2_membership.forked_from_project_id).to eq(base1_fork1.id) - expect(second_level_fork_membership.forked_from_project_id).to eq(fork_of_fork.id) - expect(third_level_fork_membership.forked_from_project_id).to eq(second_level_fork.id) - end - - it 'reschedules itself when there are missing members' do - allow(migration).to receive(:missing_members?).and_return(true) - - expect(BackgroundMigrationWorker) - .to receive(:perform_in).with(described_class::RESCHEDULE_DELAY, "CreateForkNetworkMembershipsRange", [1, 3]) - - migration.perform(1, 3) - end - - it 'can be repeated without effect' do - expect { fork_network_members.count }.not_to change { migration.perform(1, 7) } - end - - it 'knows it is finished for this range' do - expect(migration.missing_members?(1, 8)).to be_falsy - end - - it 'does not miss members for forks of forks for which the root was deleted' do - forked_project_links.create(id: 9, forked_from_project_id: base1_fork1.id, forked_to_project_id: projects.create.id) - base1.destroy - - expect(migration.missing_members?(7, 10)).to be_falsy - end - - context 'with more forks' do - before do - forked_project_links.create(id: 9, forked_from_project_id: fork_of_fork.id, forked_to_project_id: projects.create.id) - forked_project_links.create(id: 10, forked_from_project_id: fork_of_fork.id, forked_to_project_id: projects.create.id) - end - - it 'only processes a single batch of links at a time' do - expect(fork_network_members.count).to eq(10) - - migration.perform(8, 10) - - expect(fork_network_members.count).to eq(12) - end - - it 'knows when not all memberships within a batch have been created' do - expect(migration.missing_members?(8, 10)).to be_truthy - end - end -end diff --git a/spec/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range_spec.rb b/spec/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range_spec.rb deleted file mode 100644 index 9bae7e53b71..00000000000 --- a/spec/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe Gitlab::BackgroundMigration::DeleteConflictingRedirectRoutesRange, :migration, schema: 20170907170235 do - let!(:redirect_routes) { table(:redirect_routes) } - let!(:routes) { table(:routes) } - - before do - routes.create!(id: 1, source_id: 1, source_type: 'Namespace', path: 'foo1') - routes.create!(id: 2, source_id: 2, source_type: 'Namespace', path: 'foo2') - routes.create!(id: 3, source_id: 3, source_type: 'Namespace', path: 'foo3') - routes.create!(id: 4, source_id: 4, source_type: 'Namespace', path: 'foo4') - routes.create!(id: 5, source_id: 5, source_type: 'Namespace', path: 'foo5') - - # Valid redirects - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'bar') - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'bar2') - redirect_routes.create!(source_id: 2, source_type: 'Namespace', path: 'bar3') - - # Conflicting redirects - redirect_routes.create!(source_id: 2, source_type: 'Namespace', path: 'foo1') - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo2') - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo3') - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo4') - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo5') - end - - # No-op. See https://gitlab.com/gitlab-com/infrastructure/issues/3460#note_53223252 - it 'NO-OP: does not delete any redirect_routes' do - expect(redirect_routes.count).to eq(8) - - described_class.new.perform(1, 5) - - expect(redirect_routes.count).to eq(8) - end -end diff --git a/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb b/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb deleted file mode 100644 index 188969951a6..00000000000 --- a/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb +++ /dev/null @@ -1,433 +0,0 @@ -require 'spec_helper' - -# rubocop:disable RSpec/FactoriesInMigrationSpecs -describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads::Event, :migration, schema: 20170608152748 do - describe '#commit_title' do - it 'returns nil when there are no commits' do - expect(described_class.new.commit_title).to be_nil - end - - it 'returns nil when there are commits without commit messages' do - event = described_class.new - - allow(event).to receive(:commits).and_return([{ id: '123' }]) - - expect(event.commit_title).to be_nil - end - - it 'returns the commit message when it is less than 70 characters long' do - event = described_class.new - - allow(event).to receive(:commits).and_return([{ message: 'Hello world' }]) - - expect(event.commit_title).to eq('Hello world') - end - - it 'returns the first line of a commit message if multiple lines are present' do - event = described_class.new - - allow(event).to receive(:commits).and_return([{ message: "Hello\n\nworld" }]) - - expect(event.commit_title).to eq('Hello') - end - - it 'truncates the commit to 70 characters when it is too long' do - event = described_class.new - - allow(event).to receive(:commits).and_return([{ message: 'a' * 100 }]) - - expect(event.commit_title).to eq(('a' * 67) + '...') - end - end - - describe '#commit_from_sha' do - it 'returns nil when pushing to a new ref' do - event = described_class.new - - allow(event).to receive(:create?).and_return(true) - - expect(event.commit_from_sha).to be_nil - end - - it 'returns the ID of the first commit when pushing to an existing ref' do - event = described_class.new - - allow(event).to receive(:create?).and_return(false) - allow(event).to receive(:data).and_return(before: '123') - - expect(event.commit_from_sha).to eq('123') - end - end - - describe '#commit_to_sha' do - it 'returns nil when removing an existing ref' do - event = described_class.new - - allow(event).to receive(:remove?).and_return(true) - - expect(event.commit_to_sha).to be_nil - end - - it 'returns the ID of the last commit when pushing to an existing ref' do - event = described_class.new - - allow(event).to receive(:remove?).and_return(false) - allow(event).to receive(:data).and_return(after: '123') - - expect(event.commit_to_sha).to eq('123') - end - end - - describe '#data' do - it 'returns the deserialized data' do - event = described_class.new(data: { before: '123' }) - - expect(event.data).to eq(before: '123') - end - - it 'returns an empty hash when no data is present' do - event = described_class.new - - expect(event.data).to eq({}) - end - end - - describe '#commits' do - it 'returns an Array of commits' do - event = described_class.new(data: { commits: [{ id: '123' }] }) - - expect(event.commits).to eq([{ id: '123' }]) - end - - it 'returns an empty array when no data is present' do - event = described_class.new - - expect(event.commits).to eq([]) - end - end - - describe '#commit_count' do - it 'returns the number of commits' do - event = described_class.new(data: { total_commits_count: 2 }) - - expect(event.commit_count).to eq(2) - end - - it 'returns 0 when no data is present' do - event = described_class.new - - expect(event.commit_count).to eq(0) - end - end - - describe '#ref' do - it 'returns the name of the ref' do - event = described_class.new(data: { ref: 'refs/heads/master' }) - - expect(event.ref).to eq('refs/heads/master') - end - end - - describe '#trimmed_ref_name' do - it 'returns the trimmed ref name for a branch' do - event = described_class.new(data: { ref: 'refs/heads/master' }) - - expect(event.trimmed_ref_name).to eq('master') - end - - it 'returns the trimmed ref name for a tag' do - event = described_class.new(data: { ref: 'refs/tags/v1.2' }) - - expect(event.trimmed_ref_name).to eq('v1.2') - end - end - - describe '#create?' do - it 'returns true when creating a new ref' do - event = described_class.new(data: { before: described_class::BLANK_REF }) - - expect(event.create?).to eq(true) - end - - it 'returns false when pushing to an existing ref' do - event = described_class.new(data: { before: '123' }) - - expect(event.create?).to eq(false) - end - end - - describe '#remove?' do - it 'returns true when removing an existing ref' do - event = described_class.new(data: { after: described_class::BLANK_REF }) - - expect(event.remove?).to eq(true) - end - - it 'returns false when pushing to an existing ref' do - event = described_class.new(data: { after: '123' }) - - expect(event.remove?).to eq(false) - end - end - - describe '#push_action' do - let(:event) { described_class.new } - - it 'returns :created when creating a new ref' do - allow(event).to receive(:create?).and_return(true) - - expect(event.push_action).to eq(:created) - end - - it 'returns :removed when removing an existing ref' do - allow(event).to receive(:create?).and_return(false) - allow(event).to receive(:remove?).and_return(true) - - expect(event.push_action).to eq(:removed) - end - - it 'returns :pushed when pushing to an existing ref' do - allow(event).to receive(:create?).and_return(false) - allow(event).to receive(:remove?).and_return(false) - - expect(event.push_action).to eq(:pushed) - end - end - - describe '#ref_type' do - let(:event) { described_class.new } - - it 'returns :tag for a tag' do - allow(event).to receive(:ref).and_return('refs/tags/1.2') - - expect(event.ref_type).to eq(:tag) - end - - it 'returns :branch for a branch' do - allow(event).to receive(:ref).and_return('refs/heads/1.2') - - expect(event.ref_type).to eq(:branch) - end - end -end - -## -# The background migration relies on a temporary table, hence we're migrating -# to a specific version of the database where said table is still present. -# -describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migration, schema: 20170825154015 do - let(:user_class) do - Class.new(ActiveRecord::Base) do - self.table_name = 'users' - end - end - - let(:migration) { described_class.new } - let(:user_class) { table(:users) } - let(:author) { build(:user).becomes(user_class).tap(&:save!).becomes(User) } - let(:namespace) { create(:namespace, owner: author) } - let(:projects) { table(:projects) } - let(:project) { projects.create(namespace_id: namespace.id, creator_id: author.id) } - - # We can not rely on FactoryBot as the state of Event may change in ways that - # the background migration does not expect, hence we use the Event class of - # the migration itself. - def create_push_event(project, author, data = nil) - klass = Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads::Event - - klass.create!( - action: klass::PUSHED, - project_id: project.id, - author_id: author.id, - data: data - ) - end - - describe '#perform' do - it 'returns if data should not be migrated' do - allow(migration).to receive(:migrate?).and_return(false) - - expect(migration).not_to receive(:find_events) - - migration.perform(1, 10) - end - - it 'migrates the range of events if data is to be migrated' do - event1 = create_push_event(project, author, { commits: [] }) - event2 = create_push_event(project, author, { commits: [] }) - - allow(migration).to receive(:migrate?).and_return(true) - - expect(migration).to receive(:process_event).twice - - migration.perform(event1.id, event2.id) - end - end - - describe '#process_event' do - it 'processes a regular event' do - event = double(:event, push_event?: false) - - expect(migration).to receive(:replicate_event) - expect(migration).not_to receive(:create_push_event_payload) - - migration.process_event(event) - end - - it 'processes a push event' do - event = double(:event, push_event?: true) - - expect(migration).to receive(:replicate_event) - expect(migration).to receive(:create_push_event_payload) - - migration.process_event(event) - end - - it 'handles an error gracefully' do - event1 = create_push_event(project, author, { commits: [] }) - - expect(migration).to receive(:replicate_event).and_call_original - expect(migration).to receive(:create_push_event_payload).and_raise(ActiveRecord::InvalidForeignKey, 'invalid foreign key') - - migration.process_event(event1) - - expect(described_class::EventForMigration.all.count).to eq(0) - end - end - - describe '#replicate_event' do - it 'replicates the event to the "events_for_migration" table' do - event = create_push_event( - project, - author, - data: { commits: [] }, - title: 'bla' - ) - - attributes = event - .attributes.with_indifferent_access.except(:title, :data) - - expect(described_class::EventForMigration) - .to receive(:create!) - .with(attributes) - - migration.replicate_event(event) - end - end - - describe '#create_push_event_payload' do - let(:push_data) do - { - commits: [], - ref: 'refs/heads/master', - before: '156e0e9adc587a383a7eeb5b21ddecb9044768a8', - after: '0' * 40, - total_commits_count: 1 - } - end - - let(:event) do - create_push_event(project, author, push_data) - end - - before do - # The foreign key in push_event_payloads at this point points to the - # "events_for_migration" table so we need to make sure a row exists in - # said table. - migration.replicate_event(event) - end - - it 'creates a push event payload for an event' do - payload = migration.create_push_event_payload(event) - - expect(PushEventPayload.count).to eq(1) - expect(payload.valid?).to eq(true) - end - - it 'does not create push event payloads for removed events' do - allow(event).to receive(:id).and_return(-1) - - expect { migration.create_push_event_payload(event) }.to raise_error(ActiveRecord::InvalidForeignKey) - - expect(PushEventPayload.count).to eq(0) - end - - it 'encodes and decodes the commit IDs from and to binary data' do - payload = migration.create_push_event_payload(event) - packed = migration.pack(push_data[:before]) - - expect(payload.commit_from).to eq(packed) - expect(payload.commit_to).to be_nil - end - end - - describe '#find_events' do - it 'returns the events for the given ID range' do - event1 = create_push_event(project, author, { commits: [] }) - event2 = create_push_event(project, author, { commits: [] }) - event3 = create_push_event(project, author, { commits: [] }) - events = migration.find_events(event1.id, event2.id) - - expect(events.length).to eq(2) - expect(events.pluck(:id)).not_to include(event3.id) - end - end - - describe '#migrate?' do - it 'returns true when data should be migrated' do - allow(described_class::Event) - .to receive(:table_exists?).and_return(true) - - allow(described_class::PushEventPayload) - .to receive(:table_exists?).and_return(true) - - allow(described_class::EventForMigration) - .to receive(:table_exists?).and_return(true) - - expect(migration.migrate?).to eq(true) - end - - it 'returns false if the "events" table does not exist' do - allow(described_class::Event) - .to receive(:table_exists?).and_return(false) - - expect(migration.migrate?).to eq(false) - end - - it 'returns false if the "push_event_payloads" table does not exist' do - allow(described_class::Event) - .to receive(:table_exists?).and_return(true) - - allow(described_class::PushEventPayload) - .to receive(:table_exists?).and_return(false) - - expect(migration.migrate?).to eq(false) - end - - it 'returns false when the "events_for_migration" table does not exist' do - allow(described_class::Event) - .to receive(:table_exists?).and_return(true) - - allow(described_class::PushEventPayload) - .to receive(:table_exists?).and_return(true) - - allow(described_class::EventForMigration) - .to receive(:table_exists?).and_return(false) - - expect(migration.migrate?).to eq(false) - end - end - - describe '#pack' do - it 'packs a SHA1 into a 20 byte binary string' do - packed = migration.pack('156e0e9adc587a383a7eeb5b21ddecb9044768a8') - - expect(packed.bytesize).to eq(20) - end - - it 'returns nil if the input value is nil' do - expect(migration.pack(nil)).to be_nil - end - end -end -# rubocop:enable RSpec/FactoriesInMigrationSpecs diff --git a/spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb b/spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb deleted file mode 100644 index 89b56906ed0..00000000000 --- a/spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb +++ /dev/null @@ -1,92 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe Gitlab::BackgroundMigration::MigrateStageStatus, :migration, schema: 20170711145320 do - let(:projects) { table(:projects) } - let(:pipelines) { table(:ci_pipelines) } - let(:stages) { table(:ci_stages) } - let(:jobs) { table(:ci_builds) } - - let(:statuses) do - { - created: 0, - pending: 1, - running: 2, - success: 3, - failed: 4, - canceled: 5, - skipped: 6, - manual: 7 - } - end - - before do - projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1') - pipelines.create!(id: 1, project_id: 1, ref: 'master', sha: 'adf43c3a') - stages.create!(id: 1, pipeline_id: 1, project_id: 1, name: 'test', status: nil) - stages.create!(id: 2, pipeline_id: 1, project_id: 1, name: 'deploy', status: nil) - end - - context 'when stage status is known' do - before do - create_job(project: 1, pipeline: 1, stage: 'test', status: 'success') - create_job(project: 1, pipeline: 1, stage: 'test', status: 'running') - create_job(project: 1, pipeline: 1, stage: 'deploy', status: 'failed') - end - - it 'sets a correct stage status' do - described_class.new.perform(1, 2) - - expect(stages.first.status).to eq statuses[:running] - expect(stages.second.status).to eq statuses[:failed] - end - end - - context 'when stage status is not known' do - it 'sets a skipped stage status' do - described_class.new.perform(1, 2) - - expect(stages.first.status).to eq statuses[:skipped] - expect(stages.second.status).to eq statuses[:skipped] - end - end - - context 'when stage status includes status of a retried job' do - before do - create_job(project: 1, pipeline: 1, stage: 'test', status: 'canceled') - create_job(project: 1, pipeline: 1, stage: 'deploy', status: 'failed', retried: true) - create_job(project: 1, pipeline: 1, stage: 'deploy', status: 'success') - end - - it 'sets a correct stage status' do - described_class.new.perform(1, 2) - - expect(stages.first.status).to eq statuses[:canceled] - expect(stages.second.status).to eq statuses[:success] - end - end - - context 'when some job in the stage is blocked / manual' do - before do - create_job(project: 1, pipeline: 1, stage: 'test', status: 'failed') - create_job(project: 1, pipeline: 1, stage: 'test', status: 'manual') - create_job(project: 1, pipeline: 1, stage: 'deploy', status: 'success', when: 'manual') - end - - it 'sets a correct stage status' do - described_class.new.perform(1, 2) - - expect(stages.first.status).to eq statuses[:manual] - expect(stages.second.status).to eq statuses[:success] - end - end - - def create_job(project:, pipeline:, stage:, status:, **opts) - stages = { test: 1, build: 2, deploy: 3 } - - jobs.create!(project_id: project, commit_id: pipeline, - stage_idx: stages[stage.to_sym], stage: stage, - status: status, **opts) - end -end diff --git a/spec/lib/gitlab/background_migration/normalize_ldap_extern_uids_range_spec.rb b/spec/lib/gitlab/background_migration/normalize_ldap_extern_uids_range_spec.rb deleted file mode 100644 index dfbf1bb681a..00000000000 --- a/spec/lib/gitlab/background_migration/normalize_ldap_extern_uids_range_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe Gitlab::BackgroundMigration::NormalizeLdapExternUidsRange, :migration, schema: 20170921101004 do - let!(:identities) { table(:identities) } - - before do - # LDAP identities - (1..4).each do |i| - identities.create!(id: i, provider: 'ldapmain', extern_uid: " uid = foo #{i}, ou = People, dc = example, dc = com ", user_id: i) - end - - # Non-LDAP identity - identities.create!(id: 5, provider: 'foo', extern_uid: " uid = foo 5, ou = People, dc = example, dc = com ", user_id: 5) - - # Another LDAP identity - identities.create!(id: 6, provider: 'ldapmain', extern_uid: " uid = foo 6, ou = People, dc = example, dc = com ", user_id: 6) - end - - it 'normalizes the LDAP identities in the range' do - described_class.new.perform(1, 3) - expect(identities.find(1).extern_uid).to eq("uid=foo 1,ou=people,dc=example,dc=com") - expect(identities.find(2).extern_uid).to eq("uid=foo 2,ou=people,dc=example,dc=com") - expect(identities.find(3).extern_uid).to eq("uid=foo 3,ou=people,dc=example,dc=com") - expect(identities.find(4).extern_uid).to eq(" uid = foo 4, ou = People, dc = example, dc = com ") - expect(identities.find(5).extern_uid).to eq(" uid = foo 5, ou = People, dc = example, dc = com ") - expect(identities.find(6).extern_uid).to eq(" uid = foo 6, ou = People, dc = example, dc = com ") - - described_class.new.perform(4, 6) - expect(identities.find(1).extern_uid).to eq("uid=foo 1,ou=people,dc=example,dc=com") - expect(identities.find(2).extern_uid).to eq("uid=foo 2,ou=people,dc=example,dc=com") - expect(identities.find(3).extern_uid).to eq("uid=foo 3,ou=people,dc=example,dc=com") - expect(identities.find(4).extern_uid).to eq("uid=foo 4,ou=people,dc=example,dc=com") - expect(identities.find(5).extern_uid).to eq(" uid = foo 5, ou = People, dc = example, dc = com ") - expect(identities.find(6).extern_uid).to eq("uid=foo 6,ou=people,dc=example,dc=com") - end -end diff --git a/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb b/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb deleted file mode 100644 index 0e73c8c59c9..00000000000 --- a/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'spec_helper' - -describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, schema: 20170929131201 do - let(:migration) { described_class.new } - let(:projects) { table(:projects) } - let(:base1) { projects.create } - - let(:base2) { projects.create } - let(:base2_fork1) { projects.create } - - let!(:forked_project_links) { table(:forked_project_links) } - let!(:fork_networks) { table(:fork_networks) } - let!(:fork_network_members) { table(:fork_network_members) } - - let(:fork_network1) { fork_networks.find_by(root_project_id: base1.id) } - let(:fork_network2) { fork_networks.find_by(root_project_id: base2.id) } - - before do - # A normal fork link - forked_project_links.create(id: 1, - forked_from_project_id: base1.id, - forked_to_project_id: projects.create.id) - forked_project_links.create(id: 2, - forked_from_project_id: base1.id, - forked_to_project_id: projects.create.id) - forked_project_links.create(id: 3, - forked_from_project_id: base2.id, - forked_to_project_id: base2_fork1.id) - - # create a fork of a fork - forked_project_links.create(id: 4, - forked_from_project_id: base2_fork1.id, - forked_to_project_id: projects.create.id) - forked_project_links.create(id: 5, - forked_from_project_id: projects.create.id, - forked_to_project_id: projects.create.id) - - # Stub out the calls to the other migrations - allow(BackgroundMigrationWorker).to receive(:perform_in) - - migration.perform(1, 3) - end - - it 'creates the fork network' do - expect(fork_network1).not_to be_nil - expect(fork_network2).not_to be_nil - end - - it 'does not create a fork network for a fork-of-fork' do - # perfrom the entire batch - migration.perform(1, 5) - - expect(fork_networks.find_by(root_project_id: base2_fork1.id)).to be_nil - end - - it 'creates memberships for the root of fork networks' do - base1_membership = fork_network_members.find_by(fork_network_id: fork_network1.id, - project_id: base1.id) - base2_membership = fork_network_members.find_by(fork_network_id: fork_network2.id, - project_id: base2.id) - - expect(base1_membership).not_to be_nil - expect(base2_membership).not_to be_nil - end - - it 'creates a fork network for the fork of which the source was deleted' do - fork = projects.create - forked_project_links.create(id: 6, forked_from_project_id: 99999, forked_to_project_id: fork.id) - - migration.perform(5, 8) - - expect(fork_networks.find_by(root_project_id: 99999)).to be_nil - expect(fork_networks.find_by(root_project_id: fork.id)).not_to be_nil - expect(fork_network_members.find_by(project_id: fork.id)).not_to be_nil - end - - it 'schedules a job for inserting memberships for forks-of-forks' do - delay = Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange::RESCHEDULE_DELAY - - expect(BackgroundMigrationWorker) - .to receive(:perform_in).with(delay, "CreateForkNetworkMembershipsRange", [1, 3]) - - migration.perform(1, 3) - end - - it 'only processes a single batch of links at a time' do - expect(fork_networks.count).to eq(2) - - migration.perform(3, 5) - - expect(fork_networks.count).to eq(3) - end - - it 'can be repeated without effect' do - expect { migration.perform(1, 3) }.not_to change { fork_network_members.count } - end -end diff --git a/spec/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id_spec.rb b/spec/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id_spec.rb deleted file mode 100644 index 0cb753c5853..00000000000 --- a/spec/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'spec_helper' - -describe Gitlab::BackgroundMigration::PopulateMergeRequestsLatestMergeRequestDiffId, :migration, schema: 20171026082505 do - let(:projects_table) { table(:projects) } - let(:merge_requests_table) { table(:merge_requests) } - let(:merge_request_diffs_table) { table(:merge_request_diffs) } - - let(:project) { projects_table.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce') } - - def create_mr!(name, diffs: 0) - merge_request = - merge_requests_table.create!(target_project_id: project.id, - target_branch: 'master', - source_project_id: project.id, - source_branch: name, - title: name) - - diffs.times do - merge_request_diffs_table.create!(merge_request_id: merge_request.id) - end - - merge_request - end - - def diffs_for(merge_request) - merge_request_diffs_table.where(merge_request_id: merge_request.id) - end - - describe '#perform' do - it 'ignores MRs without diffs' do - merge_request_without_diff = create_mr!('without_diff') - mr_id = merge_request_without_diff.id - - expect(merge_request_without_diff.latest_merge_request_diff_id).to be_nil - - expect { subject.perform(mr_id, mr_id) } - .not_to change { merge_request_without_diff.reload.latest_merge_request_diff_id } - end - - it 'ignores MRs that have a diff ID already set' do - merge_request_with_multiple_diffs = create_mr!('with_multiple_diffs', diffs: 3) - diff_id = diffs_for(merge_request_with_multiple_diffs).minimum(:id) - mr_id = merge_request_with_multiple_diffs.id - - merge_request_with_multiple_diffs.update!(latest_merge_request_diff_id: diff_id) - - expect { subject.perform(mr_id, mr_id) } - .not_to change { merge_request_with_multiple_diffs.reload.latest_merge_request_diff_id } - end - - it 'migrates multiple MR diffs to the correct values' do - merge_requests = Array.new(3).map.with_index { |_, i| create_mr!(i, diffs: 3) } - - subject.perform(merge_requests.first.id, merge_requests.last.id) - - merge_requests.each do |merge_request| - expect(merge_request.reload.latest_merge_request_diff_id) - .to eq(diffs_for(merge_request).maximum(:id)) - end - end - end -end diff --git a/spec/migrations/add_foreign_key_to_merge_requests_spec.rb b/spec/migrations/add_foreign_key_to_merge_requests_spec.rb deleted file mode 100644 index d9ad9a585f0..00000000000 --- a/spec/migrations/add_foreign_key_to_merge_requests_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20170713104829_add_foreign_key_to_merge_requests.rb') - -describe AddForeignKeyToMergeRequests, :migration do - let(:projects) { table(:projects) } - let(:merge_requests) { table(:merge_requests) } - let(:pipelines) { table(:ci_pipelines) } - - before do - projects.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce') - pipelines.create!(project_id: projects.first.id, - ref: 'some-branch', - sha: 'abc12345') - - # merge request without a pipeline - create_merge_request(head_pipeline_id: nil) - - # merge request with non-existent pipeline - create_merge_request(head_pipeline_id: 1234) - - # merge reqeust with existing pipeline assigned - create_merge_request(head_pipeline_id: pipelines.first.id) - end - - it 'correctly adds a foreign key to head_pipeline_id' do - migrate! - - expect(merge_requests.first.head_pipeline_id).to be_nil - expect(merge_requests.second.head_pipeline_id).to be_nil - expect(merge_requests.third.head_pipeline_id).to eq pipelines.first.id - end - - def create_merge_request(**opts) - merge_requests.create!(source_project_id: projects.first.id, - target_project_id: projects.first.id, - source_branch: 'some-branch', - target_branch: 'master', **opts) - end -end diff --git a/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb b/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb deleted file mode 100644 index 13dc62595b5..00000000000 --- a/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170508170547_add_head_pipeline_for_each_merge_request.rb') - -describe AddHeadPipelineForEachMergeRequest, :migration do - let(:migration) { described_class.new } - - let!(:project) { table(:projects).create! } - let!(:other_project) { table(:projects).create! } - - let!(:pipeline_1) { table(:ci_pipelines).create!(project_id: project.id, ref: "branch_1") } - let!(:pipeline_2) { table(:ci_pipelines).create!(project_id: other_project.id, ref: "branch_1") } - let!(:pipeline_3) { table(:ci_pipelines).create!(project_id: other_project.id, ref: "branch_1") } - let!(:pipeline_4) { table(:ci_pipelines).create!(project_id: project.id, ref: "branch_2") } - - let!(:mr_1) { table(:merge_requests).create!(source_project_id: project.id, target_project_id: project.id, source_branch: "branch_1", target_branch: "target_1") } - let!(:mr_2) { table(:merge_requests).create!(source_project_id: other_project.id, target_project_id: project.id, source_branch: "branch_1", target_branch: "target_2") } - let!(:mr_3) { table(:merge_requests).create!(source_project_id: project.id, target_project_id: project.id, source_branch: "branch_2", target_branch: "master") } - let!(:mr_4) { table(:merge_requests).create!(source_project_id: project.id, target_project_id: project.id, source_branch: "branch_3", target_branch: "master") } - - context "#up" do - context "when source_project and source_branch of pipeline are the same of merge request" do - it "sets head_pipeline_id of given merge requests" do - migration.up - - expect(mr_1.reload.head_pipeline_id).to eq(pipeline_1.id) - expect(mr_2.reload.head_pipeline_id).to eq(pipeline_3.id) - expect(mr_3.reload.head_pipeline_id).to eq(pipeline_4.id) - expect(mr_4.reload.head_pipeline_id).to be_nil - end - end - end -end diff --git a/spec/migrations/calculate_conv_dev_index_percentages_spec.rb b/spec/migrations/calculate_conv_dev_index_percentages_spec.rb deleted file mode 100644 index 09c78d02890..00000000000 --- a/spec/migrations/calculate_conv_dev_index_percentages_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# encoding: utf-8 - -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170803090603_calculate_conv_dev_index_percentages.rb') - -describe CalculateConvDevIndexPercentages, :migration do - let(:migration) { described_class.new } - let!(:conv_dev_index) do - table(:conversational_development_index_metrics).create!( - leader_issues: 9.256, - leader_notes: 0, - leader_milestones: 16.2456, - leader_boards: 5.2123, - leader_merge_requests: 1.2, - leader_ci_pipelines: 12.1234, - leader_environments: 3.3333, - leader_deployments: 1.200, - leader_projects_prometheus_active: 0.111, - leader_service_desk_issues: 15.891, - instance_issues: 1.234, - instance_notes: 28.123, - instance_milestones: 0, - instance_boards: 3.254, - instance_merge_requests: 0.6, - instance_ci_pipelines: 2.344, - instance_environments: 2.2222, - instance_deployments: 0.771, - instance_projects_prometheus_active: 0.109, - instance_service_desk_issues: 13.345, - percentage_issues: 0, - percentage_notes: 0, - percentage_milestones: 0, - percentage_boards: 0, - percentage_merge_requests: 0, - percentage_ci_pipelines: 0, - percentage_environments: 0, - percentage_deployments: 0, - percentage_projects_prometheus_active: 0, - percentage_service_desk_issues: 0) - end - - describe '#up' do - it 'calculates percentages correctly' do - migration.up - conv_dev_index.reload - - expect(conv_dev_index.percentage_issues).to be_within(0.1).of(13.3) - expect(conv_dev_index.percentage_notes).to be_zero # leader 0 - expect(conv_dev_index.percentage_milestones).to be_zero # instance 0 - expect(conv_dev_index.percentage_boards).to be_within(0.1).of(62.4) - expect(conv_dev_index.percentage_merge_requests).to eq(50.0) - expect(conv_dev_index.percentage_ci_pipelines).to be_within(0.1).of(19.3) - expect(conv_dev_index.percentage_environments).to be_within(0.1).of(66.7) - expect(conv_dev_index.percentage_deployments).to be_within(0.1).of(64.2) - expect(conv_dev_index.percentage_projects_prometheus_active).to be_within(0.1).of(98.2) - expect(conv_dev_index.percentage_service_desk_issues).to be_within(0.1).of(84.0) - end - end -end diff --git a/spec/migrations/clean_appearance_symlinks_spec.rb b/spec/migrations/clean_appearance_symlinks_spec.rb deleted file mode 100644 index 9225dc0d894..00000000000 --- a/spec/migrations/clean_appearance_symlinks_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170613111224_clean_appearance_symlinks.rb') - -describe CleanAppearanceSymlinks do - let(:migration) { described_class.new } - let(:test_dir) { File.join(Rails.root, "tmp", "tests", "clean_appearance_test") } - let(:uploads_dir) { File.join(test_dir, "public", "uploads") } - let(:new_uploads_dir) { File.join(uploads_dir, "system") } - let(:original_path) { File.join(new_uploads_dir, 'appearance') } - let(:symlink_path) { File.join(uploads_dir, 'appearance') } - - before do - FileUtils.remove_dir(test_dir) if File.directory?(test_dir) - FileUtils.mkdir_p(uploads_dir) - allow(migration).to receive(:base_directory).and_return(test_dir) - allow(migration).to receive(:say) - end - - describe "#up" do - before do - FileUtils.mkdir_p(original_path) - FileUtils.ln_s(original_path, symlink_path) - end - - it 'removes the symlink' do - migration.up - - expect(File.symlink?(symlink_path)).to be(false) - end - end - - describe '#down' do - before do - FileUtils.mkdir_p(File.join(original_path)) - FileUtils.touch(File.join(original_path, 'dummy.file')) - end - - it 'creates a symlink' do - expected_path = File.join(symlink_path, "dummy.file") - migration.down - - expect(File.exist?(expected_path)).to be(true) - expect(File.symlink?(symlink_path)).to be(true) - end - end -end diff --git a/spec/migrations/clean_stage_id_reference_migration_spec.rb b/spec/migrations/clean_stage_id_reference_migration_spec.rb deleted file mode 100644 index 9a581df28a2..00000000000 --- a/spec/migrations/clean_stage_id_reference_migration_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20170710083355_clean_stage_id_reference_migration.rb') - -describe CleanStageIdReferenceMigration, :migration, :sidekiq, :redis do - let(:migration_class) { 'MigrateBuildStageIdReference' } - let(:migration) { spy('migration') } - - before do - allow(Gitlab::BackgroundMigration.const_get(migration_class)) - .to receive(:new).and_return(migration) - end - - context 'when there are pending background migrations' do - it 'processes pending jobs synchronously' do - Sidekiq::Testing.disable! do - BackgroundMigrationWorker.perform_in(2.minutes, migration_class, [1, 1]) - BackgroundMigrationWorker.perform_async(migration_class, [1, 1]) - - migrate! - - expect(migration).to have_received(:perform).with(1, 1).twice - end - end - end - context 'when there are no background migrations pending' do - it 'does nothing' do - Sidekiq::Testing.disable! do - migrate! - - expect(migration).not_to have_received(:perform) - end - end - end -end diff --git a/spec/migrations/clean_stages_statuses_migration_spec.rb b/spec/migrations/clean_stages_statuses_migration_spec.rb deleted file mode 100644 index 38705f8eaae..00000000000 --- a/spec/migrations/clean_stages_statuses_migration_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20170912113435_clean_stages_statuses_migration.rb') - -describe CleanStagesStatusesMigration, :migration, :sidekiq, :redis do - let(:migration) { spy('migration') } - - before do - allow(Gitlab::BackgroundMigration::MigrateStageStatus) - .to receive(:new).and_return(migration) - end - - context 'when there are pending background migrations' do - it 'processes pending jobs synchronously' do - Sidekiq::Testing.disable! do - BackgroundMigrationWorker - .perform_in(2.minutes, 'MigrateStageStatus', [1, 1]) - BackgroundMigrationWorker - .perform_async('MigrateStageStatus', [1, 1]) - - migrate! - - expect(migration).to have_received(:perform).with(1, 1).twice - end - end - end - - context 'when there are no background migrations pending' do - it 'does nothing' do - Sidekiq::Testing.disable! do - migrate! - - expect(migration).not_to have_received(:perform) - end - end - end - - context 'when there are still unmigrated stages afterwards' do - let(:stages) { table('ci_stages') } - - before do - stages.create!(status: nil, name: 'build') - stages.create!(status: nil, name: 'test') - end - - it 'migrates statuses sequentially in batches' do - migrate! - - expect(migration).to have_received(:perform).once - end - end -end diff --git a/spec/migrations/clean_upload_symlinks_spec.rb b/spec/migrations/clean_upload_symlinks_spec.rb deleted file mode 100644 index 26653b9c008..00000000000 --- a/spec/migrations/clean_upload_symlinks_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170406111121_clean_upload_symlinks.rb') - -describe CleanUploadSymlinks do - let(:migration) { described_class.new } - let(:test_dir) { File.join(Rails.root, "tmp", "tests", "move_uploads_test") } - let(:uploads_dir) { File.join(test_dir, "public", "uploads") } - let(:new_uploads_dir) { File.join(uploads_dir, "-", "system") } - let(:original_path) { File.join(new_uploads_dir, 'user') } - let(:symlink_path) { File.join(uploads_dir, 'user') } - - before do - FileUtils.remove_dir(test_dir) if File.directory?(test_dir) - FileUtils.mkdir_p(uploads_dir) - allow(migration).to receive(:base_directory).and_return(test_dir) - allow(migration).to receive(:say) - end - - describe "#up" do - before do - FileUtils.mkdir_p(original_path) - FileUtils.ln_s(original_path, symlink_path) - end - - it 'removes the symlink' do - migration.up - - expect(File.symlink?(symlink_path)).to be(false) - end - end - - describe '#down' do - before do - FileUtils.mkdir_p(File.join(original_path)) - FileUtils.touch(File.join(original_path, 'dummy.file')) - end - - it 'creates a symlink' do - expected_path = File.join(symlink_path, "dummy.file") - migration.down - - expect(File.exist?(expected_path)).to be(true) - expect(File.symlink?(symlink_path)).to be(true) - end - end -end diff --git a/spec/migrations/cleanup_move_system_upload_folder_symlink_spec.rb b/spec/migrations/cleanup_move_system_upload_folder_symlink_spec.rb deleted file mode 100644 index 3a9fa8c7113..00000000000 --- a/spec/migrations/cleanup_move_system_upload_folder_symlink_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' -require Rails.root.join("db", "post_migrate", "20170717111152_cleanup_move_system_upload_folder_symlink.rb") - -describe CleanupMoveSystemUploadFolderSymlink do - let(:migration) { described_class.new } - let(:test_base) { File.join(Rails.root, 'tmp', 'tests', 'move-system-upload-folder') } - let(:test_folder) { File.join(test_base, '-', 'system') } - - before do - allow(migration).to receive(:base_directory).and_return(test_base) - FileUtils.rm_rf(test_base) - FileUtils.mkdir_p(test_folder) - allow(migration).to receive(:say) - end - - describe '#up' do - before do - FileUtils.ln_s(test_folder, File.join(test_base, 'system')) - end - - it 'removes the symlink' do - migration.up - - expect(File.exist?(File.join(test_base, 'system'))).to be_falsey - end - end - - describe '#down' do - it 'creates the symlink' do - migration.down - - expect(File.symlink?(File.join(test_base, 'system'))).to be_truthy - end - end -end diff --git a/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb b/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb deleted file mode 100644 index 0e6bded29b4..00000000000 --- a/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb') - -describe CleanupNonexistingNamespacePendingDeleteProjects, :migration do - let(:projects) { table(:projects) } - let(:namespaces) { table(:namespaces) } - - describe '#up' do - let!(:some_project) { projects.create! } - let(:namespace) { namespaces.create!(name: 'test', path: 'test') } - - it 'only cleans up when namespace does not exist' do - projects.create!(pending_delete: true, namespace_id: namespace.id) - project = projects.create!(pending_delete: true, namespace_id: 0) - - expect(NamespacelessProjectDestroyWorker).to receive(:bulk_perform_async).with([[project.id]]) - - described_class.new.up - end - - it 'does nothing when no pending delete projects without namespace found' do - projects.create!(pending_delete: true, namespace_id: namespace.id) - - expect(NamespacelessProjectDestroyWorker).not_to receive(:bulk_perform_async) - - described_class.new.up - end - end -end diff --git a/spec/migrations/convert_custom_notification_settings_to_columns_spec.rb b/spec/migrations/convert_custom_notification_settings_to_columns_spec.rb deleted file mode 100644 index d1bf6bdf9d6..00000000000 --- a/spec/migrations/convert_custom_notification_settings_to_columns_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170607121233_convert_custom_notification_settings_to_columns') - -describe ConvertCustomNotificationSettingsToColumns, :migration do - let(:user_class) { table(:users) } - - let(:settings_params) do - [ - { level: 0, events: [:new_note] }, # disabled, single event - { level: 3, events: [:new_issue, :reopen_issue, :close_issue, :reassign_issue] }, # global, multiple events - { level: 5, events: described_class::EMAIL_EVENTS }, # custom, all events - { level: 5, events: [] } # custom, no events - ] - end - - let(:notification_settings_before) do - settings_params.map do |params| - events = {} - - params[:events].each do |event| - events[event] = true - end - - user = user_class.create!(email: "user-#{SecureRandom.hex}@example.org", username: "user-#{SecureRandom.hex}", encrypted_password: '12345678') - create_params = { user_id: user.id, level: params[:level], events: events } - notification_setting = described_class::NotificationSetting.create(create_params) - - [notification_setting, params] - end - end - - let(:notification_settings_after) do - settings_params.map do |params| - events = {} - - params[:events].each do |event| - events[event] = true - end - - user = user_class.create!(email: "user-#{SecureRandom.hex}@example.org", username: "user-#{SecureRandom.hex}", encrypted_password: '12345678') - create_params = events.merge(user_id: user.id, level: params[:level]) - notification_setting = described_class::NotificationSetting.create(create_params) - - [notification_setting, params] - end - end - - describe '#up' do - it 'migrates all settings where a custom event is enabled, even if they are not currently using the custom level' do - notification_settings_before - - described_class.new.up - - notification_settings_before.each do |(notification_setting, params)| - notification_setting.reload - - expect(notification_setting.read_attribute_before_type_cast(:events)).to be_nil - expect(notification_setting.level).to eq(params[:level]) - - described_class::EMAIL_EVENTS.each do |event| - # We don't set the others to false, just let them default to nil - expected = params[:events].include?(event) || nil - - expect(notification_setting.read_attribute(event)).to eq(expected) - end - end - end - end - - describe '#down' do - it 'creates a custom events hash for all settings where at least one event is enabled' do - notification_settings_after - - described_class.new.down - - notification_settings_after.each do |(notification_setting, params)| - notification_setting.reload - - expect(notification_setting.level).to eq(params[:level]) - - if params[:events].empty? - # We don't migrate empty settings - expect(notification_setting.events).to eq({}) - else - described_class::EMAIL_EVENTS.each do |event| - expected = params[:events].include?(event) - - expect(notification_setting.events[event]).to eq(expected) - expect(notification_setting.read_attribute(event)).to be_nil - end - end - end - end - - it 'reverts the database to the state it was in before' do - notification_settings_before - - described_class.new.up - described_class.new.down - - notification_settings_before.each do |(notification_setting, params)| - notification_setting.reload - - expect(notification_setting.level).to eq(params[:level]) - - if params[:events].empty? - # We don't migrate empty settings - expect(notification_setting.events).to eq({}) - else - described_class::EMAIL_EVENTS.each do |event| - expected = params[:events].include?(event) - - expect(notification_setting.events[event]).to eq(expected) - expect(notification_setting.read_attribute(event)).to be_nil - end - end - end - end - end -end diff --git a/spec/migrations/delete_conflicting_redirect_routes_spec.rb b/spec/migrations/delete_conflicting_redirect_routes_spec.rb deleted file mode 100644 index 8a191bd7139..00000000000 --- a/spec/migrations/delete_conflicting_redirect_routes_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170907170235_delete_conflicting_redirect_routes') - -describe DeleteConflictingRedirectRoutes, :migration, :sidekiq do - let!(:redirect_routes) { table(:redirect_routes) } - let!(:routes) { table(:routes) } - - around do |example| - Timecop.freeze { example.run } - end - - before do - routes.create!(id: 1, source_id: 1, source_type: 'Namespace', path: 'foo1') - routes.create!(id: 2, source_id: 2, source_type: 'Namespace', path: 'foo2') - routes.create!(id: 3, source_id: 3, source_type: 'Namespace', path: 'foo3') - routes.create!(id: 4, source_id: 4, source_type: 'Namespace', path: 'foo4') - routes.create!(id: 5, source_id: 5, source_type: 'Namespace', path: 'foo5') - - # Valid redirects - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'bar') - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'bar2') - redirect_routes.create!(source_id: 2, source_type: 'Namespace', path: 'bar3') - - # Conflicting redirects - redirect_routes.create!(source_id: 2, source_type: 'Namespace', path: 'foo1') - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo2') - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo3') - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo4') - redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo5') - end - - # No-op. See https://gitlab.com/gitlab-com/infrastructure/issues/3460#note_53223252 - it 'NO-OP: does not schedule any background migrations' do - Sidekiq::Testing.fake! do - Timecop.freeze do - migrate! - - expect(BackgroundMigrationWorker.jobs.size).to eq 0 - end - end - end -end diff --git a/spec/migrations/fix_wrongly_renamed_routes_spec.rb b/spec/migrations/fix_wrongly_renamed_routes_spec.rb deleted file mode 100644 index 543cf55f076..00000000000 --- a/spec/migrations/fix_wrongly_renamed_routes_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170518231126_fix_wrongly_renamed_routes.rb') - -describe FixWronglyRenamedRoutes, :migration do - let(:subject) { described_class.new } - let(:namespaces_table) { table(:namespaces) } - let(:projects_table) { table(:projects) } - let(:routes_table) { table(:routes) } - let(:broken_namespace) do - namespaces_table.create!(name: 'apiis', path: 'apiis').tap do |namespace| - routes_table.create!(source_type: 'Namespace', source_id: namespace.id, name: 'api0is', path: 'api0is') - end - end - let(:broken_namespace_route) { routes_table.where(source_type: 'Namespace', source_id: broken_namespace.id).first } - - describe '#wrongly_renamed' do - it "includes routes that have names that don't match their namespace" do - broken_namespace - other_namespace = namespaces_table.create!(name: 'api0', path: 'api0') - routes_table.create!(source_type: 'Namespace', source_id: other_namespace.id, name: 'api0', path: 'api0') - - expect(subject.wrongly_renamed.map(&:id)) - .to contain_exactly(broken_namespace_route.id) - end - end - - describe "#paths_and_corrections" do - it 'finds the wrong path and gets the correction from the namespace' do - broken_namespace - namespaces_table.create!(name: 'uploads-test', path: 'uploads-test').tap do |namespace| - routes_table.create!(source_type: 'Namespace', source_id: namespace.id, name: 'uploads-test', path: 'uploads0-test') - end - - expected_result = [ - { 'namespace_path' => 'apiis', 'path' => 'api0is' }, - { 'namespace_path' => 'uploads-test', 'path' => 'uploads0-test' } - ] - - expect(subject.paths_and_corrections).to include(*expected_result) - end - end - - describe '#routes_in_namespace_query' do - it 'includes only the required routes' do - namespace = namespaces_table.create!(name: 'hello', path: 'hello') - namespace_route = routes_table.create!(source_type: 'Namespace', source_id: namespace.id, name: 'hello', path: 'hello') - project = projects_table.new(name: 'my-project', path: 'my-project', namespace_id: namespace.id).tap do |project| - project.save!(validate: false) - end - routes_table.create!(source_type: 'Project', source_id: project.id, name: 'my-project', path: 'hello/my-project') - _other_namespace = namespaces_table.create!(name: 'hello0', path: 'hello0') - - result = routes_table.where(subject.routes_in_namespace_query('hello')) - project_route = routes_table.where(source_type: 'Project', source_id: project.id).first - - expect(result).to contain_exactly(namespace_route, project_route) - end - end - - describe '#up' do - it 'renames incorrectly named routes' do - broken_project = - projects_table.new(name: 'broken-project', path: 'broken-project', namespace_id: broken_namespace.id).tap do |project| - project.save!(validate: false) - routes_table.create!(source_type: 'Project', source_id: project.id, name: 'broken-project', path: 'api0is/broken-project') - end - - subject.up - - broken_project_route = routes_table.where(source_type: 'Project', source_id: broken_project.id).first - - expect(broken_project_route.path).to eq('apiis/broken-project') - expect(broken_namespace_route.reload.path).to eq('apiis') - end - - it "doesn't touch namespaces that look like something that should be renamed" do - namespaces_table.create!(name: 'apiis', path: 'apiis') - namespace = namespaces_table.create!(name: 'hello', path: 'api0') - namespace_route = routes_table.create!(source_type: 'Namespace', source_id: namespace.id, name: 'hello', path: 'api0') - - subject.up - - expect(namespace_route.reload.path).to eq('api0') - end - end -end diff --git a/spec/migrations/issues_moved_to_id_foreign_key_spec.rb b/spec/migrations/issues_moved_to_id_foreign_key_spec.rb deleted file mode 100644 index 71a4e71ac8a..00000000000 --- a/spec/migrations/issues_moved_to_id_foreign_key_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20171106151218_issues_moved_to_id_foreign_key.rb') - -describe IssuesMovedToIdForeignKey, :migration do - let(:issues) { table(:issues) } - - let!(:issue_third) { issues.create! } - let!(:issue_second) { issues.create!(moved_to_id: issue_third.id) } - let!(:issue_first) { issues.create!(moved_to_id: issue_second.id) } - - subject { described_class.new } - - it 'removes the orphaned moved_to_id' do - subject.down - - issue_third.update!(moved_to_id: 0) - - subject.up - - expect(issue_first.reload.moved_to_id).to eq(issue_second.id) - expect(issue_second.reload.moved_to_id).to eq(issue_third.id) - expect(issue_third.reload.moved_to_id).to be_nil - end -end diff --git a/spec/migrations/migrate_build_stage_reference_again_spec.rb b/spec/migrations/migrate_build_stage_reference_again_spec.rb deleted file mode 100644 index 6be480ce58e..00000000000 --- a/spec/migrations/migrate_build_stage_reference_again_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170526190000_migrate_build_stage_reference_again.rb') - -describe MigrateBuildStageReferenceAgain, :migration do - ## - # Create test data - pipeline and CI/CD jobs. - # - - let(:jobs) { table(:ci_builds) } - let(:stages) { table(:ci_stages) } - let(:pipelines) { table(:ci_pipelines) } - let(:projects) { table(:projects) } - - before do - # Create projects - # - projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1') - projects.create!(id: 456, name: 'gitlab2', path: 'gitlab2') - - # Create CI/CD pipelines - # - pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a') - pipelines.create!(id: 2, project_id: 456, ref: 'feature', sha: '21a3deb') - - # Create CI/CD jobs - # - jobs.create!(id: 1, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build') - jobs.create!(id: 2, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build') - jobs.create!(id: 3, commit_id: 1, project_id: 123, stage_idx: 1, stage: 'test') - jobs.create!(id: 4, commit_id: 1, project_id: 123, stage_idx: 3, stage: 'deploy') - jobs.create!(id: 5, commit_id: 2, project_id: 456, stage_idx: 2, stage: 'test:2') - jobs.create!(id: 6, commit_id: 2, project_id: 456, stage_idx: 1, stage: 'test:1') - jobs.create!(id: 7, commit_id: 2, project_id: 456, stage_idx: 1, stage: 'test:1') - jobs.create!(id: 8, commit_id: 3, project_id: 789, stage_idx: 3, stage: 'deploy') - - # Create CI/CD stages - # - stages.create(id: 101, pipeline_id: 1, project_id: 123, name: 'test') - stages.create(id: 102, pipeline_id: 1, project_id: 123, name: 'build') - stages.create(id: 103, pipeline_id: 1, project_id: 123, name: 'deploy') - stages.create(id: 104, pipeline_id: 2, project_id: 456, name: 'test:1') - stages.create(id: 105, pipeline_id: 2, project_id: 456, name: 'test:2') - stages.create(id: 106, pipeline_id: 2, project_id: 456, name: 'deploy') - end - - it 'correctly migrate build stage references' do - expect(jobs.where(stage_id: nil).count).to eq 8 - - migrate! - - expect(jobs.where(stage_id: nil).count).to eq 1 - - expect(jobs.find(1).stage_id).to eq 102 - expect(jobs.find(2).stage_id).to eq 102 - expect(jobs.find(3).stage_id).to eq 101 - expect(jobs.find(4).stage_id).to eq 103 - expect(jobs.find(5).stage_id).to eq 105 - expect(jobs.find(6).stage_id).to eq 104 - expect(jobs.find(7).stage_id).to eq 104 - expect(jobs.find(8).stage_id).to eq nil - end -end diff --git a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb deleted file mode 100644 index ba4c66057d4..00000000000 --- a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb +++ /dev/null @@ -1,181 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb') - -describe MigrateGcpClustersToNewClustersArchitectures, :migration do - let(:projects) { table(:projects) } - let(:project) { projects.create } - let(:users) { table(:users) } - let(:user) { users.create! } - let(:service) { GcpMigrationSpec::KubernetesService.create!(project_id: project.id) } - - module GcpMigrationSpec - class KubernetesService < ActiveRecord::Base - self.table_name = 'services' - - serialize :properties, JSON - - default_value_for :active, true - default_value_for :type, 'KubernetesService' - default_value_for :properties, { - api_url: 'https://kubernetes.example.com', - token: 'a' * 40 - } - end - end - - context 'when cluster is being created' do - let(:project_id) { project.id } - let(:user_id) { user.id } - let(:service_id) { service.id } - let(:status) { 2 } # creating - let(:gcp_cluster_size) { 1 } - let(:created_at) { "'2017-10-17 20:24:02'" } - let(:updated_at) { "'2017-10-17 20:28:44'" } - let(:enabled) { true } - let(:status_reason) { "''" } - let(:project_namespace) { "'sample-app'" } - let(:endpoint) { 'NULL' } - let(:ca_cert) { 'NULL' } - let(:encrypted_kubernetes_token) { 'NULL' } - let(:encrypted_kubernetes_token_iv) { 'NULL' } - let(:username) { 'NULL' } - let(:encrypted_password) { 'NULL' } - let(:encrypted_password_iv) { 'NULL' } - let(:gcp_project_id) { "'gcp_project_id'" } - let(:gcp_cluster_zone) { "'gcp_cluster_zone'" } - let(:gcp_cluster_name) { "'gcp_cluster_name'" } - let(:gcp_machine_type) { "'gcp_machine_type'" } - let(:gcp_operation_id) { 'NULL' } - let(:encrypted_gcp_token) { "'encrypted_gcp_token'" } - let(:encrypted_gcp_token_iv) { "'encrypted_gcp_token_iv'" } - - let(:cluster) { described_class::Cluster.last } - let(:cluster_id) { cluster.id } - - before do - ActiveRecord::Base.connection.execute <<-SQL - INSERT INTO gcp_clusters (project_id, user_id, service_id, status, gcp_cluster_size, created_at, updated_at, enabled, status_reason, project_namespace, endpoint, ca_cert, encrypted_kubernetes_token, encrypted_kubernetes_token_iv, username, encrypted_password, encrypted_password_iv, gcp_project_id, gcp_cluster_zone, gcp_cluster_name, gcp_machine_type, gcp_operation_id, encrypted_gcp_token, encrypted_gcp_token_iv) - VALUES (#{project_id}, #{user_id}, #{service_id}, #{status}, #{gcp_cluster_size}, #{created_at}, #{updated_at}, #{enabled}, #{status_reason}, #{project_namespace}, #{endpoint}, #{ca_cert}, #{encrypted_kubernetes_token}, #{encrypted_kubernetes_token_iv}, #{username}, #{encrypted_password}, #{encrypted_password_iv}, #{gcp_project_id}, #{gcp_cluster_zone}, #{gcp_cluster_name}, #{gcp_machine_type}, #{gcp_operation_id}, #{encrypted_gcp_token}, #{encrypted_gcp_token_iv}); - SQL - end - - it 'correctly migrate to new clusters architectures' do - migrate! - - expect(described_class::Cluster.count).to eq(1) - expect(described_class::ClustersProject.count).to eq(1) - expect(described_class::ProvidersGcp.count).to eq(1) - expect(described_class::PlatformsKubernetes.count).to eq(1) - - expect(cluster.user_id).to eq(user.id) - expect(cluster.enabled).to be_truthy - expect(cluster.name).to eq(gcp_cluster_name.delete!("'")) - expect(cluster.provider_type).to eq('gcp') - expect(cluster.platform_type).to eq('kubernetes') - - expect(cluster.project_ids).to include(project.id) - - expect(cluster.provider_gcp.cluster_id).to eq(cluster.id) - expect(cluster.provider_gcp.status).to eq(status) - expect(cluster.provider_gcp.status_reason).to eq(tr(status_reason)) - expect(cluster.provider_gcp.gcp_project_id).to eq(tr(gcp_project_id)) - expect(cluster.provider_gcp.zone).to eq(tr(gcp_cluster_zone)) - expect(cluster.provider_gcp.num_nodes).to eq(gcp_cluster_size) - expect(cluster.provider_gcp.machine_type).to eq(tr(gcp_machine_type)) - expect(cluster.provider_gcp.operation_id).to be_nil - expect(cluster.provider_gcp.endpoint).to be_nil - expect(cluster.provider_gcp.encrypted_access_token).to eq(tr(encrypted_gcp_token)) - expect(cluster.provider_gcp.encrypted_access_token_iv).to eq(tr(encrypted_gcp_token_iv)) - - expect(cluster.platform_kubernetes.cluster_id).to eq(cluster.id) - expect(cluster.platform_kubernetes.api_url).to be_nil - expect(cluster.platform_kubernetes.ca_cert).to be_nil - expect(cluster.platform_kubernetes.namespace).to eq(tr(project_namespace)) - expect(cluster.platform_kubernetes.username).to be_nil - expect(cluster.platform_kubernetes.encrypted_password).to be_nil - expect(cluster.platform_kubernetes.encrypted_password_iv).to be_nil - expect(cluster.platform_kubernetes.encrypted_token).to be_nil - expect(cluster.platform_kubernetes.encrypted_token_iv).to be_nil - end - end - - context 'when cluster has been created' do - let(:project_id) { project.id } - let(:user_id) { user.id } - let(:service_id) { service.id } - let(:status) { 3 } # created - let(:gcp_cluster_size) { 1 } - let(:created_at) { "'2017-10-17 20:24:02'" } - let(:updated_at) { "'2017-10-17 20:28:44'" } - let(:enabled) { true } - let(:status_reason) { "'general error'" } - let(:project_namespace) { "'sample-app'" } - let(:endpoint) { "'111.111.111.111'" } - let(:ca_cert) { "'ca_cert'" } - let(:encrypted_kubernetes_token) { "'encrypted_kubernetes_token'" } - let(:encrypted_kubernetes_token_iv) { "'encrypted_kubernetes_token_iv'" } - let(:username) { "'username'" } - let(:encrypted_password) { "'encrypted_password'" } - let(:encrypted_password_iv) { "'encrypted_password_iv'" } - let(:gcp_project_id) { "'gcp_project_id'" } - let(:gcp_cluster_zone) { "'gcp_cluster_zone'" } - let(:gcp_cluster_name) { "'gcp_cluster_name'" } - let(:gcp_machine_type) { "'gcp_machine_type'" } - let(:gcp_operation_id) { "'gcp_operation_id'" } - let(:encrypted_gcp_token) { "'encrypted_gcp_token'" } - let(:encrypted_gcp_token_iv) { "'encrypted_gcp_token_iv'" } - - let(:cluster) { described_class::Cluster.last } - let(:cluster_id) { cluster.id } - - before do - ActiveRecord::Base.connection.execute <<-SQL - INSERT INTO gcp_clusters (project_id, user_id, service_id, status, gcp_cluster_size, created_at, updated_at, enabled, status_reason, project_namespace, endpoint, ca_cert, encrypted_kubernetes_token, encrypted_kubernetes_token_iv, username, encrypted_password, encrypted_password_iv, gcp_project_id, gcp_cluster_zone, gcp_cluster_name, gcp_machine_type, gcp_operation_id, encrypted_gcp_token, encrypted_gcp_token_iv) - VALUES (#{project_id}, #{user_id}, #{service_id}, #{status}, #{gcp_cluster_size}, #{created_at}, #{updated_at}, #{enabled}, #{status_reason}, #{project_namespace}, #{endpoint}, #{ca_cert}, #{encrypted_kubernetes_token}, #{encrypted_kubernetes_token_iv}, #{username}, #{encrypted_password}, #{encrypted_password_iv}, #{gcp_project_id}, #{gcp_cluster_zone}, #{gcp_cluster_name}, #{gcp_machine_type}, #{gcp_operation_id}, #{encrypted_gcp_token}, #{encrypted_gcp_token_iv}); - SQL - end - - it 'correctly migrate to new clusters architectures' do - migrate! - - expect(described_class::Cluster.count).to eq(1) - expect(described_class::ClustersProject.count).to eq(1) - expect(described_class::ProvidersGcp.count).to eq(1) - expect(described_class::PlatformsKubernetes.count).to eq(1) - - expect(cluster.user_id).to eq(user.id) - expect(cluster.enabled).to be_truthy - expect(cluster.name).to eq(tr(gcp_cluster_name)) - expect(cluster.provider_type).to eq('gcp') - expect(cluster.platform_type).to eq('kubernetes') - - expect(cluster.project_ids).to include(project.id) - - expect(cluster.provider_gcp.cluster_id).to eq(cluster.id) - expect(cluster.provider_gcp.status).to eq(status) - expect(cluster.provider_gcp.status_reason).to eq(tr(status_reason)) - expect(cluster.provider_gcp.gcp_project_id).to eq(tr(gcp_project_id)) - expect(cluster.provider_gcp.zone).to eq(tr(gcp_cluster_zone)) - expect(cluster.provider_gcp.num_nodes).to eq(gcp_cluster_size) - expect(cluster.provider_gcp.machine_type).to eq(tr(gcp_machine_type)) - expect(cluster.provider_gcp.operation_id).to eq(tr(gcp_operation_id)) - expect(cluster.provider_gcp.endpoint).to eq(tr(endpoint)) - expect(cluster.provider_gcp.encrypted_access_token).to eq(tr(encrypted_gcp_token)) - expect(cluster.provider_gcp.encrypted_access_token_iv).to eq(tr(encrypted_gcp_token_iv)) - - expect(cluster.platform_kubernetes.cluster_id).to eq(cluster.id) - expect(cluster.platform_kubernetes.api_url).to eq('https://' + tr(endpoint)) - expect(cluster.platform_kubernetes.ca_cert).to eq(tr(ca_cert)) - expect(cluster.platform_kubernetes.namespace).to eq(tr(project_namespace)) - expect(cluster.platform_kubernetes.username).to eq(tr(username)) - expect(cluster.platform_kubernetes.encrypted_password).to eq(tr(encrypted_password)) - expect(cluster.platform_kubernetes.encrypted_password_iv).to eq(tr(encrypted_password_iv)) - expect(cluster.platform_kubernetes.encrypted_token).to eq(tr(encrypted_kubernetes_token)) - expect(cluster.platform_kubernetes.encrypted_token_iv).to eq(tr(encrypted_kubernetes_token_iv)) - end - end - - def tr(str) - str.delete("'") - end -end diff --git a/spec/migrations/migrate_issues_to_ghost_user_spec.rb b/spec/migrations/migrate_issues_to_ghost_user_spec.rb deleted file mode 100644 index 0016f058a17..00000000000 --- a/spec/migrations/migrate_issues_to_ghost_user_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20170825104051_migrate_issues_to_ghost_user.rb') - -describe MigrateIssuesToGhostUser, :migration do - describe '#up' do - let(:projects) { table(:projects) } - let(:issues) { table(:issues) } - let(:users) { table(:users) } - - before do - project = projects.create!(name: 'gitlab', namespace_id: 1) - user = users.create(email: 'test@example.com') - issues.create(title: 'Issue 1', author_id: nil, project_id: project.id) - issues.create(title: 'Issue 2', author_id: user.id, project_id: project.id) - end - - context 'when ghost user exists' do - let!(:ghost) { users.create(ghost: true, email: 'ghost@example.com') } - - it 'does not create a new user' do - expect { migrate! }.not_to change { User.count } - end - - it 'migrates issues where author = nil to the ghost user' do - migrate! - - expect(issues.first.reload.author_id).to eq(ghost.id) - end - - it 'does not change issues authored by an existing user' do - expect { migrate! }.not_to change { issues.second.reload.author_id} - end - end - - context 'when ghost user does not exist' do - it 'creates a new user' do - expect { migrate! }.to change { User.count }.by(1) - end - - it 'migrates issues where author = nil to the ghost user' do - migrate! - - expect(issues.first.reload.author_id).to eq(User.ghost.id) - end - - it 'does not change issues authored by an existing user' do - expect { migrate! }.not_to change { issues.second.reload.author_id} - end - end - end -end diff --git a/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb b/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb deleted file mode 100644 index df0015b6dd3..00000000000 --- a/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb +++ /dev/null @@ -1,312 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb') - -describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do - context 'when unique KubernetesService exists' do - shared_examples 'KubernetesService migration' do - let(:sample_num) { 2 } - - let(:projects) do - (1..sample_num).each_with_object([]) do |n, array| - array << MigrateKubernetesServiceToNewClustersArchitectures::Project.create! - end - end - - let!(:kubernetes_services) do - projects.map do |project| - MigrateKubernetesServiceToNewClustersArchitectures::Service.create!( - project: project, - active: active, - category: 'deployment', - type: 'KubernetesService', - properties: "{\"namespace\":\"prod\",\"api_url\":\"https://kubernetes#{project.id}.com\",\"ca_pem\":\"ca_pem#{project.id}\",\"token\":\"token#{project.id}\"}") - end - end - - it 'migrates the KubernetesService to Platform::Kubernetes' do - expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(sample_num) - - projects.each do |project| - project.clusters.last.tap do |cluster| - expect(cluster.enabled).to eq(active) - expect(cluster.platform_kubernetes.api_url).to eq(project.kubernetes_service.api_url) - expect(cluster.platform_kubernetes.ca_cert).to eq(project.kubernetes_service.ca_pem) - expect(cluster.platform_kubernetes.token).to eq(project.kubernetes_service.token) - expect(project.kubernetes_service).not_to be_active - end - end - end - end - - context 'when KubernetesService is active' do - let(:active) { true } - - it_behaves_like 'KubernetesService migration' - end - end - - context 'when unique KubernetesService spawned from Service Template' do - let(:sample_num) { 2 } - - let(:projects) do - (1..sample_num).each_with_object([]) do |n, array| - array << MigrateKubernetesServiceToNewClustersArchitectures::Project.create! - end - end - - let!(:kubernetes_service_template) do - MigrateKubernetesServiceToNewClustersArchitectures::Service.create!( - template: true, - category: 'deployment', - type: 'KubernetesService', - properties: "{\"namespace\":\"prod\",\"api_url\":\"https://sample.kubernetes.com\",\"ca_pem\":\"ca_pem-sample\",\"token\":\"token-sample\"}") - end - - let!(:kubernetes_services) do - projects.map do |project| - MigrateKubernetesServiceToNewClustersArchitectures::Service.create!( - project: project, - category: 'deployment', - type: 'KubernetesService', - properties: "{\"namespace\":\"prod\",\"api_url\":\"#{kubernetes_service_template.api_url}\",\"ca_pem\":\"#{kubernetes_service_template.ca_pem}\",\"token\":\"#{kubernetes_service_template.token}\"}") - end - end - - it 'migrates the KubernetesService to Platform::Kubernetes without template' do - expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(sample_num) - - projects.each do |project| - project.clusters.last.tap do |cluster| - expect(cluster.platform_kubernetes.api_url).to eq(project.kubernetes_service.api_url) - expect(cluster.platform_kubernetes.ca_cert).to eq(project.kubernetes_service.ca_pem) - expect(cluster.platform_kubernetes.token).to eq(project.kubernetes_service.token) - expect(project.kubernetes_service).not_to be_active - end - end - end - end - - context 'when managed KubernetesService exists' do - let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! } - - let(:cluster) do - MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create!( - projects: [project], - name: 'sample-cluster', - platform_type: :kubernetes, - provider_type: :user, - platform_kubernetes_attributes: { - api_url: 'https://sample.kubernetes.com', - ca_cert: 'ca_pem-sample', - token: 'token-sample' - } ) - end - - let!(:kubernetes_service) do - MigrateKubernetesServiceToNewClustersArchitectures::Service.create!( - project: project, - active: cluster.enabled, - category: 'deployment', - type: 'KubernetesService', - properties: "{\"api_url\":\"#{cluster.platform_kubernetes.api_url}\"}") - end - - it 'does not migrate the KubernetesService and disables the kubernetes_service' do # Because the corresponding Platform::Kubernetes already exists - expect { migrate! }.not_to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count } - - kubernetes_service.reload - expect(kubernetes_service).not_to be_active - end - end - - context 'when production cluster has already been existed' do # i.e. There are no environment_scope conflicts - let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! } - - let(:cluster) do - MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create!( - projects: [project], - name: 'sample-cluster', - platform_type: :kubernetes, - provider_type: :user, - environment_scope: 'production/*', - platform_kubernetes_attributes: { - api_url: 'https://sample.kubernetes.com', - ca_cert: 'ca_pem-sample', - token: 'token-sample' - } ) - end - - let!(:kubernetes_service) do - MigrateKubernetesServiceToNewClustersArchitectures::Service.create!( - project: project, - active: true, - category: 'deployment', - type: 'KubernetesService', - properties: "{\"api_url\":\"https://debug.kube.com\"}") - end - - it 'migrates the KubernetesService to Platform::Kubernetes' do - expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(1) - - kubernetes_service.reload - project.clusters.last.tap do |cluster| - expect(cluster.environment_scope).to eq('*') - expect(cluster.platform_kubernetes.api_url).to eq(kubernetes_service.api_url) - expect(cluster.platform_kubernetes.ca_cert).to eq(kubernetes_service.ca_pem) - expect(cluster.platform_kubernetes.token).to eq(kubernetes_service.token) - expect(kubernetes_service).not_to be_active - end - end - end - - context 'when default cluster has already been existed' do - let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! } - - let!(:cluster) do - MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create!( - projects: [project], - name: 'sample-cluster', - platform_type: :kubernetes, - provider_type: :user, - environment_scope: '*', - platform_kubernetes_attributes: { - api_url: 'https://sample.kubernetes.com', - ca_cert: 'ca_pem-sample', - token: 'token-sample' - } ) - end - - let!(:kubernetes_service) do - MigrateKubernetesServiceToNewClustersArchitectures::Service.create!( - project: project, - active: true, - category: 'deployment', - type: 'KubernetesService', - properties: "{\"api_url\":\"https://debug.kube.com\"}") - end - - it 'migrates the KubernetesService to Platform::Kubernetes with dedicated environment_scope' do # Because environment_scope is duplicated - expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(1) - - kubernetes_service.reload - project.clusters.last.tap do |cluster| - expect(cluster.environment_scope).to eq('migrated/*') - expect(cluster.platform_kubernetes.api_url).to eq(kubernetes_service.api_url) - expect(cluster.platform_kubernetes.ca_cert).to eq(kubernetes_service.ca_pem) - expect(cluster.platform_kubernetes.token).to eq(kubernetes_service.token) - expect(kubernetes_service).not_to be_active - end - end - end - - context 'when default cluster and migrated cluster has already been existed' do - let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! } - - let!(:cluster) do - MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create!( - projects: [project], - name: 'sample-cluster', - platform_type: :kubernetes, - provider_type: :user, - environment_scope: '*', - platform_kubernetes_attributes: { - api_url: 'https://sample.kubernetes.com', - ca_cert: 'ca_pem-sample', - token: 'token-sample' - } ) - end - - let!(:migrated_cluster) do - MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create!( - projects: [project], - name: 'sample-cluster', - platform_type: :kubernetes, - provider_type: :user, - environment_scope: 'migrated/*', - platform_kubernetes_attributes: { - api_url: 'https://sample.kubernetes.com', - ca_cert: 'ca_pem-sample', - token: 'token-sample' - } ) - end - - let!(:kubernetes_service) do - MigrateKubernetesServiceToNewClustersArchitectures::Service.create!( - project: project, - active: true, - category: 'deployment', - type: 'KubernetesService', - properties: "{\"api_url\":\"https://debug.kube.com\"}") - end - - it 'migrates the KubernetesService to Platform::Kubernetes with dedicated environment_scope' do # Because environment_scope is duplicated - expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(1) - - kubernetes_service.reload - project.clusters.last.tap do |cluster| - expect(cluster.environment_scope).to eq('migrated0/*') - expect(cluster.platform_kubernetes.api_url).to eq(kubernetes_service.api_url) - expect(cluster.platform_kubernetes.ca_cert).to eq(kubernetes_service.ca_pem) - expect(cluster.platform_kubernetes.token).to eq(kubernetes_service.token) - expect(kubernetes_service).not_to be_active - end - end - end - - context 'when KubernetesService has nullified parameters' do - let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! } - - before do - MigrateKubernetesServiceToNewClustersArchitectures::Service.create!( - project: project, - active: false, - category: 'deployment', - type: 'KubernetesService', - properties: "{}") - end - - it 'does not migrate the KubernetesService and disables the kubernetes_service' do - expect { migrate! }.not_to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count } - - expect(project.kubernetes_service).not_to be_active - end - end - - # Platforms::Kubernetes validates `token` reagdless of the activeness, - # whereas KubernetesService validates `token` if only it's activated - # However, in this migration file, there are no validations because of the re-defined model class - # therefore, we should safely add this raw to Platform::Kubernetes - context 'when KubernetesService has empty token' do - let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! } - - before do - MigrateKubernetesServiceToNewClustersArchitectures::Service.create!( - project: project, - active: false, - category: 'deployment', - type: 'KubernetesService', - properties: "{\"namespace\":\"prod\",\"api_url\":\"http://111.111.111.111\",\"ca_pem\":\"a\",\"token\":\"\"}") - end - - it 'does not migrate the KubernetesService and disables the kubernetes_service' do - expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(1) - - project.clusters.last.tap do |cluster| - expect(cluster.environment_scope).to eq('*') - expect(cluster.platform_kubernetes.namespace).to eq('prod') - expect(cluster.platform_kubernetes.api_url).to eq('http://111.111.111.111') - expect(cluster.platform_kubernetes.ca_cert).to eq('a') - expect(cluster.platform_kubernetes.token).to be_empty - expect(project.kubernetes_service).not_to be_active - end - end - end - - context 'when KubernetesService does not exist' do - let!(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! } - - it 'does not migrate the KubernetesService' do - expect { migrate! }.not_to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count } - end - end -end diff --git a/spec/migrations/migrate_old_artifacts_spec.rb b/spec/migrations/migrate_old_artifacts_spec.rb deleted file mode 100644 index bc826d91471..00000000000 --- a/spec/migrations/migrate_old_artifacts_spec.rb +++ /dev/null @@ -1,140 +0,0 @@ -# encoding: utf-8 - -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170523083112_migrate_old_artifacts.rb') - -# Adding the ci_job_artifacts table (from the 20170918072948 schema) -# makes the use of model code below easier. -describe MigrateOldArtifacts, :migration, schema: 20170918072948 do - let(:migration) { described_class.new } - let!(:directory) { Dir.mktmpdir } - - before do - allow(Gitlab.config.artifacts).to receive(:path).and_return(directory) - end - - after do - FileUtils.remove_entry_secure(directory) - end - - context 'with migratable data' do - let(:projects) { table(:projects) } - let(:ci_pipelines) { table(:ci_pipelines) } - let(:ci_builds) { table(:ci_builds) } - - let!(:project1) { projects.create!(ci_id: 2) } - let!(:project2) { projects.create!(ci_id: 3) } - let!(:project3) { projects.create! } - - let!(:pipeline1) { ci_pipelines.create!(project_id: project1.id) } - let!(:pipeline2) { ci_pipelines.create!(project_id: project2.id) } - let!(:pipeline3) { ci_pipelines.create!(project_id: project3.id) } - - let!(:build_with_legacy_artifacts) { ci_builds.create!(commit_id: pipeline1.id, project_id: project1.id, type: 'Ci::Build').becomes(Ci::Build) } - let!(:build_without_artifacts) { ci_builds.create!(commit_id: pipeline1.id, project_id: project1.id, type: 'Ci::Build').becomes(Ci::Build) } - let!(:build2) { ci_builds.create!(commit_id: pipeline2.id, project_id: project2.id, type: 'Ci::Build').becomes(Ci::Build) } - let!(:build3) { ci_builds.create!(commit_id: pipeline3.id, project_id: project3.id, type: 'Ci::Build').becomes(Ci::Build) } - - before do - setup_builds(build2, build3) - - store_artifacts_in_legacy_path(build_with_legacy_artifacts) - end - - it "legacy artifacts are not accessible" do - expect(build_with_legacy_artifacts.artifacts?).to be_falsey - end - - describe '#min_id' do - subject { migration.send(:min_id) } - - it 'returns the newest build for which ci_id is not defined' do - is_expected.to eq(build3.id) - end - end - - describe '#builds_with_artifacts' do - subject { migration.send(:builds_with_artifacts).map(&:id) } - - it 'returns a list of builds that has artifacts and could be migrated' do - is_expected.to contain_exactly(build_with_legacy_artifacts.id, build2.id) - end - end - - describe '#up' do - context 'when migrating artifacts' do - before do - migration.up - end - - it 'all files do have artifacts' do - Ci::Build.with_artifacts_archive do |build| - expect(build).to have_artifacts - end - end - - it 'artifacts are no longer present on legacy path' do - expect(File.exist?(legacy_path(build_with_legacy_artifacts))).to eq(false) - end - end - - context 'when there are artifacts in old and new directory' do - before do - store_artifacts_in_legacy_path(build2) - - migration.up - end - - it 'does not move old files' do - expect(File.exist?(legacy_path(build2))).to eq(true) - end - end - end - - private - - def store_artifacts_in_legacy_path(build) - FileUtils.mkdir_p(legacy_path(build)) - - FileUtils.copy( - Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), - File.join(legacy_path(build), "ci_build_artifacts.zip")) - - FileUtils.copy( - Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), - File.join(legacy_path(build), "ci_build_artifacts_metadata.gz")) - - build.update_columns( - artifacts_file: 'ci_build_artifacts.zip', - artifacts_metadata: 'ci_build_artifacts_metadata.gz') - - build.reload - end - - def legacy_path(build) - File.join(directory, - build.created_at.utc.strftime('%Y_%m'), - build.project.ci_id.to_s, - build.id.to_s) - end - - def new_legacy_path(build) - File.join(directory, - build.created_at.utc.strftime('%Y_%m'), - build.project_id.to_s, - build.id.to_s) - end - - def setup_builds(*builds) - builds.each do |build| - FileUtils.mkdir_p(new_legacy_path(build)) - - build.update_columns( - artifacts_file: 'ci_build_artifacts.zip', - artifacts_metadata: 'ci_build_artifacts_metadata.gz') - - build.reload - end - end - end -end diff --git a/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb b/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb deleted file mode 100644 index e38044ccceb..00000000000 --- a/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170822101017_migrate_pipeline_sidekiq_queues.rb') - -describe MigratePipelineSidekiqQueues, :sidekiq, :redis do - include Gitlab::Database::MigrationHelpers - include StubWorker - - context 'when there are jobs in the queues' do - it 'correctly migrates queue when migrating up' do - Sidekiq::Testing.disable! do - stub_worker(queue: :pipeline).perform_async('Something', [1]) - stub_worker(queue: :build).perform_async('Something', [1]) - - described_class.new.up - - expect(sidekiq_queue_length('pipeline')).to eq 0 - expect(sidekiq_queue_length('build')).to eq 0 - expect(sidekiq_queue_length('pipeline_default')).to eq 2 - end - end - - it 'correctly migrates queue when migrating down' do - Sidekiq::Testing.disable! do - stub_worker(queue: :pipeline_default).perform_async('Class', [1]) - stub_worker(queue: :pipeline_processing).perform_async('Class', [2]) - stub_worker(queue: :pipeline_hooks).perform_async('Class', [3]) - stub_worker(queue: :pipeline_cache).perform_async('Class', [4]) - - described_class.new.down - - expect(sidekiq_queue_length('pipeline')).to eq 4 - expect(sidekiq_queue_length('pipeline_default')).to eq 0 - expect(sidekiq_queue_length('pipeline_processing')).to eq 0 - expect(sidekiq_queue_length('pipeline_hooks')).to eq 0 - expect(sidekiq_queue_length('pipeline_cache')).to eq 0 - end - end - end - - context 'when there are no jobs in the queues' do - it 'does not raise error when migrating up' do - expect { described_class.new.up }.not_to raise_error - end - - it 'does not raise error when migrating down' do - expect { described_class.new.down }.not_to raise_error - end - end -end diff --git a/spec/migrations/migrate_pipeline_stages_spec.rb b/spec/migrations/migrate_pipeline_stages_spec.rb deleted file mode 100644 index c47f2bb8ff9..00000000000 --- a/spec/migrations/migrate_pipeline_stages_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170526185842_migrate_pipeline_stages.rb') - -describe MigratePipelineStages, :migration do - ## - # Create test data - pipeline and CI/CD jobs. - # - - let(:jobs) { table(:ci_builds) } - let(:stages) { table(:ci_stages) } - let(:pipelines) { table(:ci_pipelines) } - let(:projects) { table(:projects) } - - before do - # Create projects - # - projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1') - projects.create!(id: 456, name: 'gitlab2', path: 'gitlab2') - - # Create CI/CD pipelines - # - pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a') - pipelines.create!(id: 2, project_id: 456, ref: 'feature', sha: '21a3deb') - - # Create CI/CD jobs - # - jobs.create!(id: 1, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build') - jobs.create!(id: 2, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build') - jobs.create!(id: 3, commit_id: 1, project_id: 123, stage_idx: 1, stage: 'test') - jobs.create!(id: 4, commit_id: 1, project_id: 123, stage_idx: 1, stage: 'test') - jobs.create!(id: 5, commit_id: 1, project_id: 123, stage_idx: 3, stage: 'deploy') - jobs.create!(id: 6, commit_id: 2, project_id: 456, stage_idx: 3, stage: 'deploy') - jobs.create!(id: 7, commit_id: 2, project_id: 456, stage_idx: 2, stage: 'test:2') - jobs.create!(id: 8, commit_id: 2, project_id: 456, stage_idx: 1, stage: 'test:1') - jobs.create!(id: 9, commit_id: 2, project_id: 456, stage_idx: 1, stage: 'test:1') - jobs.create!(id: 10, commit_id: 2, project_id: 456, stage_idx: 2, stage: 'test:2') - jobs.create!(id: 11, commit_id: 3, project_id: 456, stage_idx: 3, stage: 'deploy') - jobs.create!(id: 12, commit_id: 2, project_id: 789, stage_idx: 3, stage: 'deploy') - end - - it 'correctly migrates pipeline stages' do - expect(stages.count).to be_zero - - migrate! - - expect(stages.count).to eq 6 - expect(stages.all.pluck(:name)) - .to match_array %w[test build deploy test:1 test:2 deploy] - expect(stages.where(pipeline_id: 1).order(:id).pluck(:name)) - .to eq %w[test build deploy] - expect(stages.where(pipeline_id: 2).order(:id).pluck(:name)) - .to eq %w[test:1 test:2 deploy] - expect(stages.where(pipeline_id: 3).count).to be_zero - expect(stages.where(project_id: 789).count).to be_zero - end -end diff --git a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb deleted file mode 100644 index 6219a67c900..00000000000 --- a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb +++ /dev/null @@ -1,197 +0,0 @@ -# encoding: utf-8 - -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20161124141322_migrate_process_commit_worker_jobs.rb') - -describe MigrateProcessCommitWorkerJobs do - set(:project) { create(:project, :legacy_storage, :repository) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - set(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let(:commit) do - Gitlab::Git::Commit.last(project.repository.raw) - end - - describe 'Project' do - describe 'find_including_path' do - it 'returns Project instances' do - expect(described_class::Project.find_including_path(project.id)) - .to be_an_instance_of(described_class::Project) - end - - it 'selects the full path for every Project' do - migration_project = described_class::Project - .find_including_path(project.id) - - expect(migration_project[:path_with_namespace]) - .to eq(project.full_path) - end - end - - describe '#repository' do - it 'returns a mock implemention of ::Repository' do - migration_project = described_class::Project - .find_including_path(project.id) - - expect(migration_project.repository).to respond_to(:storage) - expect(migration_project.repository).to respond_to(:gitaly_repository) - end - end - end - - describe '#up', :clean_gitlab_redis_shared_state do - let(:migration) { described_class.new } - - def job_count - Sidekiq.redis { |r| r.llen('queue:process_commit') } - end - - def pop_job - JSON.parse(Sidekiq.redis { |r| r.lpop('queue:process_commit') }) - end - - before do - Sidekiq.redis do |redis| - job = JSON.dump(args: [project.id, user.id, commit.id]) - redis.lpush('queue:process_commit', job) - end - end - - it 'skips jobs using a project that no longer exists' do - allow(described_class::Project).to receive(:find_including_path) - .with(project.id) - .and_return(nil) - - migration.up - - expect(job_count).to eq(0) - end - - it 'skips jobs using commits that no longer exist' do - allow_any_instance_of(Gitlab::GitalyClient::CommitService) - .to receive(:find_commit) - .with(commit.id) - .and_return(nil) - - migration.up - - expect(job_count).to eq(0) - end - - it 'inserts migrated jobs back into the queue' do - migration.up - - expect(job_count).to eq(1) - end - - it 'encodes data to UTF-8' do - allow(commit).to receive(:body) - .and_return('김치'.force_encoding('BINARY')) - - migration.up - - job = pop_job - - # We don't care so much about what is being stored, instead we just want - # to make sure the encoding is right so that JSON encoding the data - # doesn't produce any errors. - expect(job['args'][2]['message'].encoding).to eq(Encoding::UTF_8) - end - - context 'a migrated job' do - let(:job) do - migration.up - pop_job - end - - let(:commit_hash) do - job['args'][2] - end - - it 'includes the project ID' do - expect(job['args'][0]).to eq(project.id) - end - - it 'includes the user ID' do - expect(job['args'][1]).to eq(user.id) - end - - it 'includes the commit ID' do - expect(commit_hash['id']).to eq(commit.id) - end - - it 'includes the commit message' do - expect(commit_hash['message']).to eq(commit.message) - end - - it 'includes the parent IDs' do - expect(commit_hash['parent_ids']).to eq(commit.parent_ids) - end - - it 'includes the author date' do - expect(commit_hash['authored_date']).to eq(commit.authored_date.to_s) - end - - it 'includes the author name' do - expect(commit_hash['author_name']).to eq(commit.author_name) - end - - it 'includes the author Email' do - expect(commit_hash['author_email']).to eq(commit.author_email) - end - - it 'includes the commit date' do - expect(commit_hash['committed_date']).to eq(commit.committed_date.to_s) - end - - it 'includes the committer name' do - expect(commit_hash['committer_name']).to eq(commit.committer_name) - end - - it 'includes the committer Email' do - expect(commit_hash['committer_email']).to eq(commit.committer_email) - end - end - end - - describe '#down', :clean_gitlab_redis_shared_state do - let(:migration) { described_class.new } - - def job_count - Sidekiq.redis { |r| r.llen('queue:process_commit') } - end - - before do - Sidekiq.redis do |redis| - job = JSON.dump(args: [project.id, user.id, commit.id]) - redis.lpush('queue:process_commit', job) - - migration.up - end - end - - it 'pushes migrated jobs back into the queue' do - migration.down - - expect(job_count).to eq(1) - end - - context 'a migrated job' do - let(:job) do - migration.down - - JSON.parse(Sidekiq.redis { |r| r.lpop('queue:process_commit') }) - end - - it 'includes the project ID' do - expect(job['args'][0]).to eq(project.id) - end - - it 'includes the user ID' do - expect(job['args'][1]).to eq(user.id) - end - - it 'includes the commit SHA' do - expect(job['args'][2]).to eq(commit.id) - end - end - end -end diff --git a/spec/migrations/migrate_stage_id_reference_in_background_spec.rb b/spec/migrations/migrate_stage_id_reference_in_background_spec.rb deleted file mode 100644 index dd6f5325750..00000000000 --- a/spec/migrations/migrate_stage_id_reference_in_background_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170628080858_migrate_stage_id_reference_in_background') - -describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do - let(:jobs) { table(:ci_builds) } - let(:stages) { table(:ci_stages) } - let(:pipelines) { table(:ci_pipelines) } - let(:projects) { table(:projects) } - - before do - stub_const("#{described_class.name}::BATCH_SIZE", 3) - stub_const("#{described_class.name}::RANGE_SIZE", 2) - - projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1') - projects.create!(id: 345, name: 'gitlab2', path: 'gitlab2') - - pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a') - pipelines.create!(id: 2, project_id: 345, ref: 'feature', sha: 'cdf43c3c') - - jobs.create!(id: 1, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build') - jobs.create!(id: 2, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build') - jobs.create!(id: 3, commit_id: 1, project_id: 123, stage_idx: 1, stage: 'test') - jobs.create!(id: 4, commit_id: 1, project_id: 123, stage_idx: 3, stage: 'deploy') - jobs.create!(id: 5, commit_id: 2, project_id: 345, stage_idx: 1, stage: 'test') - - stages.create(id: 101, pipeline_id: 1, project_id: 123, name: 'test') - stages.create(id: 102, pipeline_id: 1, project_id: 123, name: 'build') - stages.create(id: 103, pipeline_id: 1, project_id: 123, name: 'deploy') - - jobs.create!(id: 6, commit_id: 2, project_id: 345, stage_id: 101, stage_idx: 1, stage: 'test') - end - - it 'correctly schedules background migrations' do - Sidekiq::Testing.fake! do - Timecop.freeze do - migrate! - - expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 1, 2) - expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 3, 3) - expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 4, 5) - expect(BackgroundMigrationWorker.jobs.size).to eq 3 - end - end - end - - it 'schedules background migrations' do - perform_enqueued_jobs do - expect(jobs.where(stage_id: nil).count).to eq 5 - - migrate! - - expect(jobs.where(stage_id: nil).count).to eq 1 - end - end -end diff --git a/spec/migrations/migrate_stages_statuses_spec.rb b/spec/migrations/migrate_stages_statuses_spec.rb deleted file mode 100644 index 5483e24fce7..00000000000 --- a/spec/migrations/migrate_stages_statuses_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170711145558_migrate_stages_statuses.rb') - -describe MigrateStagesStatuses, :sidekiq, :migration do - let(:jobs) { table(:ci_builds) } - let(:stages) { table(:ci_stages) } - let(:pipelines) { table(:ci_pipelines) } - let(:projects) { table(:projects) } - - STATUSES = { created: 0, pending: 1, running: 2, success: 3, - failed: 4, canceled: 5, skipped: 6, manual: 7 }.freeze - - before do - stub_const("#{described_class.name}::BATCH_SIZE", 2) - stub_const("#{described_class.name}::RANGE_SIZE", 1) - - projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1') - projects.create!(id: 2, name: 'gitlab2', path: 'gitlab2') - - pipelines.create!(id: 1, project_id: 1, ref: 'master', sha: 'adf43c3a') - pipelines.create!(id: 2, project_id: 2, ref: 'feature', sha: '21a3deb') - - create_job(project: 1, pipeline: 1, stage: 'test', status: 'success') - create_job(project: 1, pipeline: 1, stage: 'test', status: 'running') - create_job(project: 1, pipeline: 1, stage: 'build', status: 'success') - create_job(project: 1, pipeline: 1, stage: 'build', status: 'failed') - create_job(project: 2, pipeline: 2, stage: 'test', status: 'success') - create_job(project: 2, pipeline: 2, stage: 'test', status: 'success') - create_job(project: 2, pipeline: 2, stage: 'test', status: 'failed', retried: true) - - stages.create!(id: 1, pipeline_id: 1, project_id: 1, name: 'test', status: nil) - stages.create!(id: 2, pipeline_id: 1, project_id: 1, name: 'build', status: nil) - stages.create!(id: 3, pipeline_id: 2, project_id: 2, name: 'test', status: nil) - end - - it 'correctly migrates stages statuses' do - perform_enqueued_jobs do - expect(stages.where(status: nil).count).to eq 3 - - migrate! - - expect(stages.where(status: nil)).to be_empty - expect(stages.all.order('id ASC').pluck(:status)) - .to eq [STATUSES[:running], STATUSES[:failed], STATUSES[:success]] - end - end - - it 'correctly schedules background migrations' do - Sidekiq::Testing.fake! do - Timecop.freeze do - migrate! - - expect(described_class::MIGRATION).to be_scheduled_delayed_migration(5.minutes, 1, 1) - expect(described_class::MIGRATION).to be_scheduled_delayed_migration(5.minutes, 2, 2) - expect(described_class::MIGRATION).to be_scheduled_delayed_migration(10.minutes, 3, 3) - expect(BackgroundMigrationWorker.jobs.size).to eq 3 - end - end - end - - def create_job(project:, pipeline:, stage:, status:, **opts) - stages = { test: 1, build: 2, deploy: 3 } - - jobs.create!(project_id: project, commit_id: pipeline, - stage_idx: stages[stage.to_sym], stage: stage, - status: status, **opts) - end -end diff --git a/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb b/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb deleted file mode 100644 index 88aef3b70b4..00000000000 --- a/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -# encoding: utf-8 - -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170324160416_migrate_user_activities_to_users_last_activity_on.rb') - -describe MigrateUserActivitiesToUsersLastActivityOn, :clean_gitlab_redis_shared_state, :migration do - let(:migration) { described_class.new } - let!(:user_active_1) { table(:users).create!(email: 'test1', username: 'test1') } - let!(:user_active_2) { table(:users).create!(email: 'test2', username: 'test2') } - - def record_activity(user, time) - Gitlab::Redis::SharedState.with do |redis| - redis.zadd(described_class::USER_ACTIVITY_SET_KEY, time.to_i, user.username) - end - end - - around do |example| - Timecop.freeze { example.run } - end - - before do - record_activity(user_active_1, described_class::TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED + 2.months) - record_activity(user_active_2, described_class::TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED + 3.months) - mute_stdout { migration.up } - end - - describe '#up' do - it 'fills last_activity_on from the legacy Redis Sorted Set' do - expect(user_active_1.reload.last_activity_on).to eq((described_class::TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED + 2.months).to_date) - expect(user_active_2.reload.last_activity_on).to eq((described_class::TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED + 3.months).to_date) - end - end - - describe '#down' do - it 'sets last_activity_on to NULL for all users' do - mute_stdout { migration.down } - - expect(user_active_1.reload.last_activity_on).to be_nil - expect(user_active_2.reload.last_activity_on).to be_nil - end - end - - def mute_stdout - orig_stdout = $stdout - $stdout = StringIO.new - yield - $stdout = orig_stdout - end -end diff --git a/spec/migrations/migrate_user_authentication_token_to_personal_access_token_spec.rb b/spec/migrations/migrate_user_authentication_token_to_personal_access_token_spec.rb deleted file mode 100644 index b4834705011..00000000000 --- a/spec/migrations/migrate_user_authentication_token_to_personal_access_token_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20171012125712_migrate_user_authentication_token_to_personal_access_token.rb') - -describe MigrateUserAuthenticationTokenToPersonalAccessToken, :migration do - let(:users) { table(:users) } - let(:personal_access_tokens) { table(:personal_access_tokens) } - - let!(:user) { users.create!(id: 1, email: 'user@example.com', authentication_token: 'user-token', admin: false) } - let!(:admin) { users.create!(id: 2, email: 'admin@example.com', authentication_token: 'admin-token', admin: true) } - - it 'migrates private tokens to Personal Access Tokens' do - migrate! - - expect(personal_access_tokens.count).to eq(2) - - user_token = personal_access_tokens.find_by(user_id: user.id) - admin_token = personal_access_tokens.find_by(user_id: admin.id) - - expect(user_token.token).to eq('user-token') - expect(admin_token.token).to eq('admin-token') - - expect(user_token.scopes).to eq(%w[api].to_yaml) - expect(admin_token.scopes).to eq(%w[api sudo].to_yaml) - end -end diff --git a/spec/migrations/migrate_user_project_view_spec.rb b/spec/migrations/migrate_user_project_view_spec.rb deleted file mode 100644 index a0179ab3ceb..00000000000 --- a/spec/migrations/migrate_user_project_view_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# encoding: utf-8 - -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170406142253_migrate_user_project_view.rb') - -describe MigrateUserProjectView, :migration do - let(:migration) { described_class.new } - let!(:user) { table(:users).create!(project_view: User.project_views['readme']) } - - describe '#up' do - it 'updates project view setting with new value' do - migration.up - - expect(user.reload.project_view).to eq(User.project_views['files']) - end - end -end diff --git a/spec/migrations/move_personal_snippets_files_spec.rb b/spec/migrations/move_personal_snippets_files_spec.rb deleted file mode 100644 index d94ae1e52f5..00000000000 --- a/spec/migrations/move_personal_snippets_files_spec.rb +++ /dev/null @@ -1,197 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170612071012_move_personal_snippets_files.rb') - -describe MovePersonalSnippetsFiles, :migration do - let(:migration) { described_class.new } - let(:test_dir) { File.join(Rails.root, "tmp", "tests", "move_snippet_files_test") } - let(:uploads_dir) { File.join(test_dir, 'uploads') } - let(:new_uploads_dir) { File.join(uploads_dir, '-', 'system') } - - let(:notes) { table(:notes) } - let(:snippets) { table(:snippets) } - let(:uploads) { table(:uploads) } - - let(:user) { table(:users).create!(email: 'user@example.com', projects_limit: 10) } - let(:project) { table(:projects).create!(name: 'gitlab', namespace_id: 1) } - - before do - allow(CarrierWave).to receive(:root).and_return(test_dir) - allow(migration).to receive(:base_directory).and_return(test_dir) - FileUtils.remove_dir(test_dir) if File.directory?(test_dir) - allow(migration).to receive(:say) - end - - describe "#up" do - let(:snippet) do - snippet = snippets.create!(author_id: user.id) - create_upload('picture.jpg', snippet) - snippet.update(description: markdown_linking_file('picture.jpg', snippet)) - snippet - end - - let(:snippet_with_missing_file) do - snippet = snippets.create!(author_id: user.id, project_id: project.id) - create_upload('picture.jpg', snippet, create_file: false) - snippet.update(description: markdown_linking_file('picture.jpg', snippet)) - snippet - end - - it 'moves the files' do - source_path = File.join(uploads_dir, model_file_path('picture.jpg', snippet)) - destination_path = File.join(new_uploads_dir, model_file_path('picture.jpg', snippet)) - - migration.up - - expect(File.exist?(source_path)).to be_falsy - expect(File.exist?(destination_path)).to be_truthy - end - - describe 'updating the markdown' do - it 'includes the new path when the file exists' do - secret = "secret#{snippet.id}" - file_location = "/uploads/-/system/personal_snippet/#{snippet.id}/#{secret}/picture.jpg" - - migration.up - - expect(snippet.reload.description).to include(file_location) - end - - it 'does not update the markdown when the file is missing' do - secret = "secret#{snippet_with_missing_file.id}" - file_location = "/uploads/personal_snippet/#{snippet_with_missing_file.id}/#{secret}/picture.jpg" - - migration.up - - expect(snippet_with_missing_file.reload.description).to include(file_location) - end - - it 'updates the note markdown' do - secret = "secret#{snippet.id}" - file_location = "/uploads/-/system/personal_snippet/#{snippet.id}/#{secret}/picture.jpg" - markdown = markdown_linking_file('picture.jpg', snippet) - note = notes.create!(noteable_id: snippet.id, - noteable_type: Snippet, - note: "with #{markdown}", - author_id: user.id) - - migration.up - - expect(note.reload.note).to include(file_location) - end - end - end - - describe "#down" do - let(:snippet) do - snippet = snippets.create!(author_id: user.id) - create_upload('picture.jpg', snippet, in_new_path: true) - snippet.update(description: markdown_linking_file('picture.jpg', snippet, in_new_path: true)) - snippet - end - - let(:snippet_with_missing_file) do - snippet = snippets.create!(author_id: user.id) - create_upload('picture.jpg', snippet, create_file: false, in_new_path: true) - snippet.update(description: markdown_linking_file('picture.jpg', snippet, in_new_path: true)) - snippet - end - - it 'moves the files' do - source_path = File.join(new_uploads_dir, model_file_path('picture.jpg', snippet)) - destination_path = File.join(uploads_dir, model_file_path('picture.jpg', snippet)) - - migration.down - - expect(File.exist?(source_path)).to be_falsey - expect(File.exist?(destination_path)).to be_truthy - end - - describe 'updating the markdown' do - it 'includes the new path when the file exists' do - secret = "secret#{snippet.id}" - file_location = "/uploads/personal_snippet/#{snippet.id}/#{secret}/picture.jpg" - - migration.down - - expect(snippet.reload.description).to include(file_location) - end - - it 'keeps the markdown as is when the file is missing' do - secret = "secret#{snippet_with_missing_file.id}" - file_location = "/uploads/-/system/personal_snippet/#{snippet_with_missing_file.id}/#{secret}/picture.jpg" - - migration.down - - expect(snippet_with_missing_file.reload.description).to include(file_location) - end - - it 'updates the note markdown' do - markdown = markdown_linking_file('picture.jpg', snippet, in_new_path: true) - secret = "secret#{snippet.id}" - file_location = "/uploads/personal_snippet/#{snippet.id}/#{secret}/picture.jpg" - note = notes.create!(noteable_id: snippet.id, - noteable_type: Snippet, - note: "with #{markdown}", - author_id: user.id) - - migration.down - - expect(note.reload.note).to include(file_location) - end - end - end - - describe '#update_markdown' do - it 'escapes sql in the snippet description' do - migration.instance_variable_set('@source_relative_location', '/uploads/personal_snippet') - migration.instance_variable_set('@destination_relative_location', '/uploads/system/personal_snippet') - - secret = '123456789' - filename = 'hello.jpg' - snippet = snippets.create!(author_id: user.id) - - path_before = "/uploads/personal_snippet/#{snippet.id}/#{secret}/#{filename}" - path_after = "/uploads/system/personal_snippet/#{snippet.id}/#{secret}/#{filename}" - description_before = "Hello world; ![image](#{path_before})'; select * from users;" - description_after = "Hello world; ![image](#{path_after})'; select * from users;" - - migration.update_markdown(snippet.id, secret, filename, description_before) - - expect(snippet.reload.description).to eq(description_after) - end - end - - def create_upload(filename, snippet, create_file: true, in_new_path: false) - secret = "secret#{snippet.id}" - absolute_path = if in_new_path - File.join(new_uploads_dir, model_file_path(filename, snippet)) - else - File.join(uploads_dir, model_file_path(filename, snippet)) - end - - if create_file - FileUtils.mkdir_p(File.dirname(absolute_path)) - FileUtils.touch(absolute_path) - end - - uploads.create!(model_id: snippet.id, - model_type: snippet.class, - path: "#{secret}/#{filename}", - uploader: PersonalFileUploader, - size: 100.kilobytes) - end - - def markdown_linking_file(filename, snippet, in_new_path: false) - markdown = "![#{filename.split('.')[0]}]" - markdown += '(/uploads' - markdown += '/-/system' if in_new_path - markdown += "/#{model_file_path(filename, snippet)})" - markdown - end - - def model_file_path(filename, snippet) - secret = "secret#{snippet.id}" - - File.join('personal_snippet', snippet.id.to_s, secret, filename) - end -end diff --git a/spec/migrations/move_system_upload_folder_spec.rb b/spec/migrations/move_system_upload_folder_spec.rb deleted file mode 100644 index d3180477db3..00000000000 --- a/spec/migrations/move_system_upload_folder_spec.rb +++ /dev/null @@ -1,80 +0,0 @@ -require 'spec_helper' -require Rails.root.join("db", "migrate", "20170717074009_move_system_upload_folder.rb") - -describe MoveSystemUploadFolder do - let(:migration) { described_class.new } - let(:test_base) { File.join(Rails.root, 'tmp', 'tests', 'move-system-upload-folder') } - - before do - allow(migration).to receive(:base_directory).and_return(test_base) - FileUtils.rm_rf(test_base) - FileUtils.mkdir_p(test_base) - allow(migration).to receive(:say) - end - - describe '#up' do - let(:test_folder) { File.join(test_base, 'system') } - let(:test_file) { File.join(test_folder, 'file') } - - before do - FileUtils.mkdir_p(test_folder) - FileUtils.touch(test_file) - end - - it 'moves the related folder' do - migration.up - - expect(File.exist?(File.join(test_base, '-', 'system', 'file'))).to be_truthy - end - - it 'creates a symlink linking making the new folder available on the old path' do - migration.up - - expect(File.symlink?(File.join(test_base, 'system'))).to be_truthy - expect(File.exist?(File.join(test_base, 'system', 'file'))).to be_truthy - end - - it 'does not move if the target directory already exists' do - FileUtils.mkdir_p(File.join(test_base, '-', 'system')) - - expect(FileUtils).not_to receive(:mv) - expect(migration).to receive(:say).with(/already exists. No need to redo the move/) - - migration.up - end - end - - describe '#down' do - let(:test_folder) { File.join(test_base, '-', 'system') } - let(:test_file) { File.join(test_folder, 'file') } - - before do - FileUtils.mkdir_p(test_folder) - FileUtils.touch(test_file) - end - - it 'moves the system folder back to the old location' do - migration.down - - expect(File.exist?(File.join(test_base, 'system', 'file'))).to be_truthy - end - - it 'removes the symlink if it existed' do - FileUtils.ln_s(test_folder, File.join(test_base, 'system')) - - migration.down - - expect(File.directory?(File.join(test_base, 'system'))).to be_truthy - expect(File.symlink?(File.join(test_base, 'system'))).to be_falsey - end - - it 'does not move if the old directory already exists' do - FileUtils.mkdir_p(File.join(test_base, 'system')) - - expect(FileUtils).not_to receive(:mv) - expect(migration).to receive(:say).with(/already exists and is not a symlink, no need to revert/) - - migration.down - end - end -end diff --git a/spec/migrations/move_uploads_to_system_dir_spec.rb b/spec/migrations/move_uploads_to_system_dir_spec.rb deleted file mode 100644 index ca11a2004c5..00000000000 --- a/spec/migrations/move_uploads_to_system_dir_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -require "spec_helper" -require Rails.root.join("db", "migrate", "20170316163845_move_uploads_to_system_dir.rb") - -describe MoveUploadsToSystemDir do - let(:migration) { described_class.new } - let(:test_dir) { File.join(Rails.root, "tmp", "move_uploads_test") } - let(:uploads_dir) { File.join(test_dir, "public", "uploads") } - let(:new_uploads_dir) { File.join(uploads_dir, "-", "system") } - - before do - FileUtils.remove_dir(test_dir) if File.directory?(test_dir) - FileUtils.mkdir_p(uploads_dir) - allow(migration).to receive(:base_directory).and_return(test_dir) - allow(migration).to receive(:say) - end - - describe "#up" do - before do - FileUtils.mkdir_p(File.join(uploads_dir, 'user')) - FileUtils.touch(File.join(uploads_dir, 'user', 'dummy.file')) - end - - it 'moves the directory to the new path' do - expected_path = File.join(new_uploads_dir, 'user', 'dummy.file') - - migration.up - - expect(File.exist?(expected_path)).to be(true) - end - - it 'creates a symlink in the old location' do - symlink_path = File.join(uploads_dir, 'user') - expected_path = File.join(symlink_path, 'dummy.file') - - migration.up - - expect(File.exist?(expected_path)).to be(true) - expect(File.symlink?(symlink_path)).to be(true) - end - end - - describe "#down" do - before do - FileUtils.mkdir_p(File.join(new_uploads_dir, 'user')) - FileUtils.touch(File.join(new_uploads_dir, 'user', 'dummy.file')) - end - - it 'moves the directory to the old path' do - expected_path = File.join(uploads_dir, 'user', 'dummy.file') - - migration.down - - expect(File.exist?(expected_path)).to be(true) - end - - it 'removes the symlink if it existed' do - FileUtils.ln_s(File.join(new_uploads_dir, 'user'), File.join(uploads_dir, 'user')) - - directory = File.join(uploads_dir, 'user') - expected_path = File.join(directory, 'dummy.file') - - migration.down - - expect(File.exist?(expected_path)).to be(true) - expect(File.symlink?(directory)).to be(false) - end - end -end diff --git a/spec/migrations/normalize_ldap_extern_uids_spec.rb b/spec/migrations/normalize_ldap_extern_uids_spec.rb deleted file mode 100644 index a23a5d54e0a..00000000000 --- a/spec/migrations/normalize_ldap_extern_uids_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170921101004_normalize_ldap_extern_uids') - -describe NormalizeLdapExternUids, :migration, :sidekiq do - let!(:identities) { table(:identities) } - - around do |example| - Timecop.freeze { example.run } - end - - before do - stub_const("Gitlab::Database::MigrationHelpers::BACKGROUND_MIGRATION_BATCH_SIZE", 2) - stub_const("Gitlab::Database::MigrationHelpers::BACKGROUND_MIGRATION_JOB_BUFFER_SIZE", 2) - - # LDAP identities - (1..4).each do |i| - identities.create!(id: i, provider: 'ldapmain', extern_uid: " uid = foo #{i}, ou = People, dc = example, dc = com ", user_id: i) - end - - # Non-LDAP identity - identities.create!(id: 5, provider: 'foo', extern_uid: " uid = foo 5, ou = People, dc = example, dc = com ", user_id: 5) - end - - it 'correctly schedules background migrations' do - Sidekiq::Testing.fake! do - Timecop.freeze do - migrate! - - expect(BackgroundMigrationWorker.jobs[0]['args']).to eq([described_class::MIGRATION, [1, 2]]) - expect(BackgroundMigrationWorker.jobs[0]['at']).to eq(2.minutes.from_now.to_f) - expect(BackgroundMigrationWorker.jobs[1]['args']).to eq([described_class::MIGRATION, [3, 4]]) - expect(BackgroundMigrationWorker.jobs[1]['at']).to eq(4.minutes.from_now.to_f) - expect(BackgroundMigrationWorker.jobs[2]['args']).to eq([described_class::MIGRATION, [5, 5]]) - expect(BackgroundMigrationWorker.jobs[2]['at']).to eq(6.minutes.from_now.to_f) - expect(BackgroundMigrationWorker.jobs.size).to eq 3 - end - end - end - - it 'migrates the LDAP identities' do - perform_enqueued_jobs do - migrate! - identities.where(id: 1..4).each do |identity| - expect(identity.extern_uid).to eq("uid=foo #{identity.id},ou=people,dc=example,dc=com") - end - end - end - - it 'does not modify non-LDAP identities' do - perform_enqueued_jobs do - migrate! - identity = identities.last - expect(identity.extern_uid).to eq(" uid = foo 5, ou = People, dc = example, dc = com ") - end - end -end diff --git a/spec/migrations/populate_can_push_from_deploy_keys_projects_spec.rb b/spec/migrations/populate_can_push_from_deploy_keys_projects_spec.rb deleted file mode 100644 index 0ff98933d5c..00000000000 --- a/spec/migrations/populate_can_push_from_deploy_keys_projects_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20171215113714_populate_can_push_from_deploy_keys_projects.rb') - -describe PopulateCanPushFromDeployKeysProjects, :migration do - let(:migration) { described_class.new } - let(:deploy_keys) { table(:keys) } - let(:deploy_keys_projects) { table(:deploy_keys_projects) } - let(:projects) { table(:projects) } - - before do - deploy_keys.inheritance_column = nil - - projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1') - (1..10).each do |index| - deploy_keys.create!(id: index, title: 'dummy', type: 'DeployKey', key: Spec::Support::Helpers::KeyGeneratorHelper.new(1024).generate + ' dummy@gitlab.com') - deploy_keys_projects.create!(id: index, deploy_key_id: index, project_id: 1) - end - end - - describe '#up' do - it 'migrates can_push from deploy_keys to deploy_keys_projects' do - deploy_keys.limit(5).update_all(can_push: true) - - expected = deploy_keys.order(:id).pluck(:id, :can_push) - - migration.up - - expect(deploy_keys_projects.order(:id).pluck(:deploy_key_id, :can_push)).to eq expected - end - end - - describe '#down' do - it 'migrates can_push from deploy_keys_projects to deploy_keys' do - deploy_keys_projects.limit(5).update_all(can_push: true) - - expected = deploy_keys_projects.order(:id).pluck(:deploy_key_id, :can_push) - - migration.down - - expect(deploy_keys.order(:id).pluck(:id, :can_push)).to eq expected - end - end -end diff --git a/spec/migrations/remove_assignee_id_from_issue_spec.rb b/spec/migrations/remove_assignee_id_from_issue_spec.rb deleted file mode 100644 index 2c6f992d3ae..00000000000 --- a/spec/migrations/remove_assignee_id_from_issue_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170523073948_remove_assignee_id_from_issue.rb') - -describe RemoveAssigneeIdFromIssue, :migration do - let(:issues) { table(:issues) } - let(:issue_assignees) { table(:issue_assignees) } - let(:users) { table(:users) } - - let!(:user_1) { users.create(email: 'email1@example.com') } - let!(:user_2) { users.create(email: 'email2@example.com') } - let!(:user_3) { users.create(email: 'email3@example.com') } - - def create_issue(assignees:) - issues.create.tap do |issue| - assignees.each do |assignee| - issue_assignees.create(issue_id: issue.id, user_id: assignee.id) - end - end - end - - let!(:issue_single_assignee) { create_issue(assignees: [user_1]) } - let!(:issue_no_assignee) { create_issue(assignees: []) } - let!(:issue_multiple_assignees) { create_issue(assignees: [user_2, user_3]) } - - describe '#down' do - it 'sets the assignee_id to a random matching assignee from the assignees table' do - migrate! - disable_migrations_output { described_class.new.down } - - expect(issue_single_assignee.reload.assignee_id).to eq(user_1.id) - expect(issue_no_assignee.reload.assignee_id).to be_nil - expect(issue_multiple_assignees.reload.assignee_id).to eq(user_2.id).or(user_3.id) - - disable_migrations_output { described_class.new.up } - end - end -end diff --git a/spec/migrations/remove_dot_git_from_usernames_spec.rb b/spec/migrations/remove_dot_git_from_usernames_spec.rb deleted file mode 100644 index f11880a83e9..00000000000 --- a/spec/migrations/remove_dot_git_from_usernames_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -# encoding: utf-8 - -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20161226122833_remove_dot_git_from_usernames.rb') - -describe RemoveDotGitFromUsernames do - let(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let(:migration) { described_class.new } - - describe '#up' do - before do - update_namespace(user, 'test.git') - end - - it 'renames user with .git in username' do - migration.up - - expect(user.reload.username).to eq('test_git') - expect(user.namespace.reload.path).to eq('test_git') - expect(user.namespace.route.path).to eq('test_git') - end - end - - context 'when new path exists already' do - describe '#up' do - let(:user2) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - - before do - update_namespace(user, 'test.git') - update_namespace(user2, 'test_git') - - default_hash = Gitlab.config.repositories.storages.default.to_h - default_hash['path'] = 'tmp/tests/custom_repositories' - storages = { 'default' => Gitlab::GitalyClient::StorageSettings.new(default_hash) } - - allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) - allow(migration).to receive(:route_exists?).with('test_git').and_return(true) - allow(migration).to receive(:route_exists?).with('test_git1').and_return(false) - end - - it 'renames user with .git in username' do - migration.up - - expect(user.reload.username).to eq('test_git1') - expect(user.namespace.reload.path).to eq('test_git1') - expect(user.namespace.route.path).to eq('test_git1') - end - end - end - - def update_namespace(user, path) - namespace = user.namespace - namespace.path = path - namespace.save!(validate: false) - - user.update_column(:username, path) - end -end diff --git a/spec/migrations/remove_duplicate_mr_events_spec.rb b/spec/migrations/remove_duplicate_mr_events_spec.rb deleted file mode 100644 index 2509ac6afd6..00000000000 --- a/spec/migrations/remove_duplicate_mr_events_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170815060945_remove_duplicate_mr_events.rb') - -describe RemoveDuplicateMrEvents, :delete do - let(:migration) { described_class.new } - - describe '#up' do - let(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let(:merge_requests) { create_list(:merge_request, 2) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let(:issue) { create(:issue) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let!(:events) do - [ - create(:event, :created, author: user, target: merge_requests.first), # rubocop:disable RSpec/FactoriesInMigrationSpecs - create(:event, :created, author: user, target: merge_requests.first), # rubocop:disable RSpec/FactoriesInMigrationSpecs - create(:event, :updated, author: user, target: merge_requests.first), # rubocop:disable RSpec/FactoriesInMigrationSpecs - create(:event, :created, author: user, target: merge_requests.second), # rubocop:disable RSpec/FactoriesInMigrationSpecs - create(:event, :created, author: user, target: issue), # rubocop:disable RSpec/FactoriesInMigrationSpecs - create(:event, :created, author: user, target: issue) # rubocop:disable RSpec/FactoriesInMigrationSpecs - ] - end - - it 'removes duplicated merge request create records' do - expect { migration.up }.to change { Event.count }.from(6).to(5) - end - end -end diff --git a/spec/migrations/remove_empty_fork_networks_spec.rb b/spec/migrations/remove_empty_fork_networks_spec.rb deleted file mode 100644 index f6d030ab25c..00000000000 --- a/spec/migrations/remove_empty_fork_networks_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20171114104051_remove_empty_fork_networks.rb') - -describe RemoveEmptyForkNetworks, :migration do - let!(:fork_networks) { table(:fork_networks) } - let!(:projects) { table(:projects) } - let!(:fork_network_members) { table(:fork_network_members) } - - let(:deleted_project) { projects.create! } - let!(:empty_network) { fork_networks.create!(id: 1, root_project_id: deleted_project.id) } - let!(:other_network) { fork_networks.create!(id: 2, root_project_id: projects.create.id) } - - before do - fork_network_members.create(fork_network_id: empty_network.id, - project_id: empty_network.root_project_id) - fork_network_members.create(fork_network_id: other_network.id, - project_id: other_network.root_project_id) - - deleted_project.destroy! - end - - after do - Upload.reset_column_information - end - - it 'deletes only the fork network without members' do - expect(fork_networks.count).to eq(2) - - migrate! - - expect(fork_networks.find_by(id: empty_network.id)).to be_nil - expect(fork_networks.find_by(id: other_network.id)).not_to be_nil - expect(fork_networks.count).to eq(1) - end -end diff --git a/spec/migrations/rename_duplicated_variable_key_spec.rb b/spec/migrations/rename_duplicated_variable_key_spec.rb deleted file mode 100644 index 11096564dfa..00000000000 --- a/spec/migrations/rename_duplicated_variable_key_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20170622135451_rename_duplicated_variable_key.rb') - -describe RenameDuplicatedVariableKey, :migration do - let(:variables) { table(:ci_variables) } - let(:projects) { table(:projects) } - - before do - projects.create!(id: 1) - variables.create!(id: 1, key: 'key1', project_id: 1) - variables.create!(id: 2, key: 'key2', project_id: 1) - variables.create!(id: 3, key: 'keyX', project_id: 1) - variables.create!(id: 4, key: 'keyX', project_id: 1) - variables.create!(id: 5, key: 'keyY', project_id: 1) - variables.create!(id: 6, key: 'keyX', project_id: 1) - variables.create!(id: 7, key: 'key7', project_id: 1) - variables.create!(id: 8, key: 'keyY', project_id: 1) - end - - it 'correctly remove duplicated records with smaller id' do - migrate! - - expect(variables.pluck(:id, :key)).to contain_exactly( - [1, 'key1'], - [2, 'key2'], - [3, 'keyX_3'], - [4, 'keyX_4'], - [5, 'keyY_5'], - [6, 'keyX'], - [7, 'key7'], - [8, 'keyY'] - ) - end -end diff --git a/spec/migrations/rename_more_reserved_project_names_spec.rb b/spec/migrations/rename_more_reserved_project_names_spec.rb deleted file mode 100644 index 80ae209e9d1..00000000000 --- a/spec/migrations/rename_more_reserved_project_names_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# encoding: utf-8 - -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170313133418_rename_more_reserved_project_names.rb') - -# This migration uses multiple threads, and thus different transactions. This -# means data created in this spec may not be visible to some threads. To work -# around this we use the DELETE cleaning strategy. -describe RenameMoreReservedProjectNames, :delete do - let(:migration) { described_class.new } - let!(:project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - - before do - project.path = 'artifacts' - project.save!(validate: false) - end - - describe '#up' do - context 'when project repository exists' do - before do - project.create_repository - end - - context 'when no exception is raised' do - it 'renames project with reserved names' do - migration.up - - expect(project.reload.path).to eq('artifacts0') - end - end - - context 'when exception is raised during rename' do - before do - service = instance_double('service') - - allow(service) - .to receive(:execute) - .and_raise(Projects::AfterRenameService::RenameFailedError) - - expect(migration) - .to receive(:after_rename_service) - .and_return(service) - end - - it 'captures exception from project rename' do - expect { migration.up }.not_to raise_error - end - end - end - - context 'when project repository does not exist' do - it 'does not raise error' do - expect { migration.up }.not_to raise_error - end - end - end -end diff --git a/spec/migrations/rename_reserved_project_names_spec.rb b/spec/migrations/rename_reserved_project_names_spec.rb deleted file mode 100644 index 93e5c032287..00000000000 --- a/spec/migrations/rename_reserved_project_names_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -# encoding: utf-8 - -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20161221153951_rename_reserved_project_names.rb') - -# This migration is using factories, which set fields that don't actually -# exist in the DB schema previous to 20161221153951. Thus we just use the -# latest schema when testing this migration. -# This is ok-ish because: -# 1. This migration is a data migration -# 2. It only relies on very stable DB fields: routes.id, routes.path, namespaces.id, projects.namespace_id -# Ideally, the test should not use factories and rely on the `table` helper instead. -describe RenameReservedProjectNames, :migration, schema: :latest do - let(:migration) { described_class.new } - let!(:project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - - before do - project.path = 'projects' - project.save!(validate: false) - end - - describe '#up' do - context 'when project repository exists' do - before do - project.create_repository - end - - context 'when no exception is raised' do - it 'renames project with reserved names' do - migration.up - - expect(project.reload.path).to eq('projects0') - end - end - - context 'when exception is raised during rename' do - before do - service = instance_double('service') - - allow(service) - .to receive(:execute) - .and_raise(Projects::AfterRenameService::RenameFailedError) - - expect(migration) - .to receive(:after_rename_service) - .and_return(service) - end - - it 'captures exception from project rename' do - expect { migration.up }.not_to raise_error - end - end - end - - context 'when project repository does not exist' do - it 'does not raise error' do - expect { migration.up }.not_to raise_error - end - end - end -end diff --git a/spec/migrations/rename_users_with_renamed_namespace_spec.rb b/spec/migrations/rename_users_with_renamed_namespace_spec.rb deleted file mode 100644 index b8a4dc2b2c0..00000000000 --- a/spec/migrations/rename_users_with_renamed_namespace_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170518200835_rename_users_with_renamed_namespace.rb') - -describe RenameUsersWithRenamedNamespace, :delete do - it 'renames a user that had their namespace renamed to the namespace path' do - other_user = create(:user, username: 'kodingu') # rubocop:disable RSpec/FactoriesInMigrationSpecs - other_user1 = create(:user, username: 'api0') # rubocop:disable RSpec/FactoriesInMigrationSpecs - - user = create(:user, username: "Users0") # rubocop:disable RSpec/FactoriesInMigrationSpecs - user.update_column(:username, 'Users') - user1 = create(:user, username: "import0") # rubocop:disable RSpec/FactoriesInMigrationSpecs - user1.update_column(:username, 'import') - - described_class.new.up - - expect(user.reload.username).to eq('Users0') - expect(user1.reload.username).to eq('import0') - - expect(other_user.reload.username).to eq('kodingu') - expect(other_user1.reload.username).to eq('api0') - end -end diff --git a/spec/migrations/schedule_merge_request_latest_merge_request_diff_id_migrations_spec.rb b/spec/migrations/schedule_merge_request_latest_merge_request_diff_id_migrations_spec.rb deleted file mode 100644 index 76fe16581ac..00000000000 --- a/spec/migrations/schedule_merge_request_latest_merge_request_diff_id_migrations_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations') - -describe ScheduleMergeRequestLatestMergeRequestDiffIdMigrations, :migration, :sidekiq do - let(:projects_table) { table(:projects) } - let(:merge_requests_table) { table(:merge_requests) } - let(:merge_request_diffs_table) { table(:merge_request_diffs) } - - let(:project) { projects_table.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce') } - - let!(:merge_request_1) { create_mr!('mr_1', diffs: 1) } - let!(:merge_request_2) { create_mr!('mr_2', diffs: 2) } - let!(:merge_request_migrated) { create_mr!('merge_request_migrated', diffs: 3) } - let!(:merge_request_4) { create_mr!('mr_4', diffs: 3) } - - def create_mr!(name, diffs: 0) - merge_request = - merge_requests_table.create!(target_project_id: project.id, - target_branch: 'master', - source_project_id: project.id, - source_branch: name, - title: name) - - diffs.times do - merge_request_diffs_table.create!(merge_request_id: merge_request.id) - end - - merge_request - end - - def diffs_for(merge_request) - merge_request_diffs_table.where(merge_request_id: merge_request.id) - end - - before do - stub_const("#{described_class.name}::BATCH_SIZE", 1) - - diff_id = diffs_for(merge_request_migrated).minimum(:id) - merge_request_migrated.update!(latest_merge_request_diff_id: diff_id) - end - - it 'correctly schedules background migrations' do - Sidekiq::Testing.fake! do - Timecop.freeze do - migrate! - - expect(described_class::MIGRATION).to be_scheduled_delayed_migration(5.minutes, merge_request_1.id, merge_request_1.id) - expect(described_class::MIGRATION).to be_scheduled_delayed_migration(10.minutes, merge_request_2.id, merge_request_2.id) - expect(described_class::MIGRATION).to be_scheduled_delayed_migration(15.minutes, merge_request_4.id, merge_request_4.id) - expect(BackgroundMigrationWorker.jobs.size).to eq 3 - end - end - end - - it 'schedules background migrations' do - perform_enqueued_jobs do - expect(merge_requests_table.where(latest_merge_request_diff_id: nil).count).to eq 3 - - migrate! - - expect(merge_requests_table.where(latest_merge_request_diff_id: nil).count).to eq 0 - end - end -end diff --git a/spec/migrations/track_untracked_uploads_spec.rb b/spec/migrations/track_untracked_uploads_spec.rb deleted file mode 100644 index 2fccfb3f12c..00000000000 --- a/spec/migrations/track_untracked_uploads_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20171103140253_track_untracked_uploads') - -describe TrackUntrackedUploads, :migration, :sidekiq do - include MigrationsHelpers::TrackUntrackedUploadsHelpers - - it 'correctly schedules the follow-up background migration' do - Sidekiq::Testing.fake! do - migrate! - - expect(described_class::MIGRATION).to be_scheduled_migration - expect(BackgroundMigrationWorker.jobs.size).to eq(1) - end - end -end diff --git a/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb b/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb deleted file mode 100644 index 5f5ba426d69..00000000000 --- a/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb') - -describe TurnNestedGroupsIntoRegularGroupsForMysql do - let!(:parent_group) { create(:group) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let!(:child_group) { create(:group, parent: parent_group) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let!(:project) { create(:project, :legacy_storage, :empty_repo, namespace: child_group) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let!(:member) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let(:migration) { described_class.new } - - before do - parent_group.add_developer(member) - - allow(migration).to receive(:run_migration?).and_return(true) - allow(migration).to receive(:verbose).and_return(false) - end - - describe '#up' do - let(:updated_project) do - # path_with_namespace is memoized in an instance variable so we retrieve a - # new row here to work around that. - Project.find(project.id) - end - - before do - migration.up - end - - it 'unsets the parent_id column' do - expect(Namespace.where('parent_id IS NOT NULL').any?).to eq(false) - end - - it 'adds members of parent groups as members to the migrated group' do - is_member = child_group.members - .where(user_id: member, access_level: Gitlab::Access::DEVELOPER).any? - - expect(is_member).to eq(true) - end - - it 'update the path of the nested group' do - child_group.reload - - expect(child_group.path).to eq("#{parent_group.name}-#{child_group.name}") - end - - it 'renames projects of the nested group' do - expect(updated_project.full_path) - .to eq("#{parent_group.name}-#{child_group.name}/#{updated_project.path}") - end - - it 'renames the repository of any projects' do - repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do - updated_project.repository.path - end - - expect(repo_path) - .to end_with("#{parent_group.name}-#{child_group.name}/#{updated_project.path}.git") - - expect(File.directory?(repo_path)).to eq(true) - end - - it 'creates a redirect route for renamed projects' do - exists = RedirectRoute - .where(source_type: 'Project', source_id: project.id) - .any? - - expect(exists).to eq(true) - end - end -end diff --git a/spec/migrations/update_legacy_diff_notes_type_for_import_spec.rb b/spec/migrations/update_legacy_diff_notes_type_for_import_spec.rb deleted file mode 100644 index d625b60ff50..00000000000 --- a/spec/migrations/update_legacy_diff_notes_type_for_import_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170927112318_update_legacy_diff_notes_type_for_import.rb') - -describe UpdateLegacyDiffNotesTypeForImport, :migration do - let(:notes) { table(:notes) } - - before do - notes.inheritance_column = nil - - notes.create(type: 'Note') - notes.create(type: 'LegacyDiffNote') - notes.create(type: 'Github::Import::Note') - notes.create(type: 'Github::Import::LegacyDiffNote') - end - - it 'updates the notes type' do - migrate! - - expect(notes.pluck(:type)) - .to contain_exactly('Note', 'Github::Import::Note', 'LegacyDiffNote', 'LegacyDiffNote') - end -end diff --git a/spec/migrations/update_notes_type_for_import_spec.rb b/spec/migrations/update_notes_type_for_import_spec.rb deleted file mode 100644 index 06195d970d8..00000000000 --- a/spec/migrations/update_notes_type_for_import_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170927112319_update_notes_type_for_import.rb') - -describe UpdateNotesTypeForImport, :migration do - let(:notes) { table(:notes) } - - before do - notes.inheritance_column = nil - - notes.create(type: 'Note') - notes.create(type: 'LegacyDiffNote') - notes.create(type: 'Github::Import::Note') - notes.create(type: 'Github::Import::LegacyDiffNote') - end - - it 'updates the notes type' do - migrate! - - expect(notes.pluck(:type)) - .to contain_exactly('Note', 'Note', 'LegacyDiffNote', 'Github::Import::LegacyDiffNote') - end -end diff --git a/spec/migrations/update_retried_for_ci_build_spec.rb b/spec/migrations/update_retried_for_ci_build_spec.rb deleted file mode 100644 index 637dcbb8e01..00000000000 --- a/spec/migrations/update_retried_for_ci_build_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170503004427_update_retried_for_ci_build.rb') - -describe UpdateRetriedForCiBuild, :delete do - let(:pipeline) { create(:ci_pipeline) } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let!(:build_old) { create(:ci_build, pipeline: pipeline, name: 'test') } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let!(:build_new) { create(:ci_build, pipeline: pipeline, name: 'test') } # rubocop:disable RSpec/FactoriesInMigrationSpecs - - before do - described_class.new.up - end - - it 'updates ci_builds.is_retried' do - expect(build_old.reload).to be_retried - expect(build_new.reload).not_to be_retried - end -end diff --git a/spec/migrations/update_upload_paths_to_system_spec.rb b/spec/migrations/update_upload_paths_to_system_spec.rb deleted file mode 100644 index 984b428a020..00000000000 --- a/spec/migrations/update_upload_paths_to_system_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170317162059_update_upload_paths_to_system.rb') - -describe UpdateUploadPathsToSystem, :migration do - let(:migration) { described_class.new } - let(:uploads_table) { table(:uploads) } - let(:base_upload_attributes) { { size: 42, uploader: 'John Doe' } } - - before do - allow(migration).to receive(:say) - end - - describe '#uploads_to_switch_to_new_path' do - it 'contains only uploads with the old path for the correct models' do - _upload_for_other_type = create_upload('Pipeline', 'uploads/ci_pipeline/avatar.jpg') - _upload_with_system_path = create_upload('Project', 'uploads/-/system/project/avatar.jpg') - _upload_with_other_path = create_upload('Project', 'thelongsecretforafileupload/avatar.jpg') - old_upload = create_upload('Project', 'uploads/project/avatar.jpg') - group_upload = create_upload('Namespace', 'uploads/group/avatar.jpg') - - expect(uploads_table.where(migration.uploads_to_switch_to_new_path)).to contain_exactly(old_upload, group_upload) - end - end - - describe '#uploads_to_switch_to_old_path' do - it 'contains only uploads with the new path for the correct models' do - _upload_for_other_type = create_upload('Pipeline', 'uploads/ci_pipeline/avatar.jpg') - upload_with_system_path = create_upload('Project', 'uploads/-/system/project/avatar.jpg') - _upload_with_other_path = create_upload('Project', 'thelongsecretforafileupload/avatar.jpg') - _old_upload = create_upload('Project', 'uploads/project/avatar.jpg') - - expect(uploads_table.where(migration.uploads_to_switch_to_old_path)).to contain_exactly(upload_with_system_path) - end - end - - describe '#up' do - it 'updates old upload records to the new path' do - old_upload = create_upload('Project', 'uploads/project/avatar.jpg') - - migration.up - - expect(old_upload.reload.path).to eq('uploads/-/system/project/avatar.jpg') - end - end - - describe '#down' do - it 'updates the new system patsh to the old paths' do - new_upload = create_upload('Project', 'uploads/-/system/project/avatar.jpg') - - migration.down - - expect(new_upload.reload.path).to eq('uploads/project/avatar.jpg') - end - end - - def create_upload(type, path) - uploads_table.create(base_upload_attributes.merge(model_type: type, path: path)) - end -end |