diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-08-25 12:10:53 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-08-25 12:10:53 +0000 |
commit | a653c8ead4d45ffcab5447a9e38f9742600c0d09 (patch) | |
tree | e48db5b9f0a2c1ebe9624aef0c66cfa5c18683f3 /db | |
parent | faf92651aa5e9c6bcb88acac8de27c878d7edf06 (diff) | |
parent | 676f77269daa8a8c697bc34666bf3b00d540099b (diff) | |
download | gitlab-ce-a653c8ead4d45ffcab5447a9e38f9742600c0d09.tar.gz |
Merge branch 'master' into 'backstage/gb/rename-ci-cd-processing-sidekiq-queues'
# Conflicts:
# db/schema.rb
Diffstat (limited to 'db')
6 files changed, 77 insertions, 5 deletions
diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb index 7c1d758dada..383782112a8 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -15,7 +15,7 @@ class Gitlab::Seeder::CycleAnalytics # to disable the `pre_receive` hook in order to remove this # dependency on the GitLab API. def stub_git_pre_receive! - GitHooksService.class_eval do + Gitlab::Git::HooksService.class_eval do def run_hook(name) [true, ''] end diff --git a/db/migrate/20140502125220_migrate_repo_size.rb b/db/migrate/20140502125220_migrate_repo_size.rb index f5d5d834307..ca1b054600c 100644 --- a/db/migrate/20140502125220_migrate_repo_size.rb +++ b/db/migrate/20140502125220_migrate_repo_size.rb @@ -11,7 +11,7 @@ class MigrateRepoSize < ActiveRecord::Migration path = File.join(namespace_path, project['project_path'] + '.git') begin - repo = Gitlab::Git::Repository.new('default', path) + repo = Gitlab::Git::Repository.new('default', path, '') if repo.empty? print '-' else diff --git a/db/migrate/20170809142252_cleanup_appearances_schema.rb b/db/migrate/20170809142252_cleanup_appearances_schema.rb index 90d12925ba2..acf45060114 100644 --- a/db/migrate/20170809142252_cleanup_appearances_schema.rb +++ b/db/migrate/20170809142252_cleanup_appearances_schema.rb @@ -7,7 +7,7 @@ class CleanupAppearancesSchema < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false - NOT_NULL_COLUMNS = %i[title description description_html created_at updated_at] + NOT_NULL_COLUMNS = %i[title description created_at updated_at] TIME_COLUMNS = %i[created_at updated_at] diff --git a/db/migrate/20170824162758_allow_appearances_description_html_null.rb b/db/migrate/20170824162758_allow_appearances_description_html_null.rb new file mode 100644 index 00000000000..d7f481ee894 --- /dev/null +++ b/db/migrate/20170824162758_allow_appearances_description_html_null.rb @@ -0,0 +1,18 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AllowAppearancesDescriptionHtmlNull < ActiveRecord::Migration + 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/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb b/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb new file mode 100644 index 00000000000..3f085c17133 --- /dev/null +++ b/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb @@ -0,0 +1,54 @@ +# 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 + 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/schema.rb b/db/schema.rb index 916aa1ffa4c..0f4b0c0c3b3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170822101017) do +ActiveRecord::Schema.define(version: 20170824162758) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -34,7 +34,7 @@ ActiveRecord::Schema.define(version: 20170822101017) do t.string "logo" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.text "description_html", null: false + t.text "description_html" t.integer "cached_markdown_version" end |