Commit 03570415 authored by Pavel Shutsin's avatar Pavel Shutsin

Remove obsolete bot_type column

users.bot_type column is removed in favor
of users.user_type
parent 4e5e26a0
...@@ -65,8 +65,7 @@ class User < ApplicationRecord ...@@ -65,8 +65,7 @@ class User < ApplicationRecord
MINIMUM_INACTIVE_DAYS = 180 MINIMUM_INACTIVE_DAYS = 180
ignore_column :bot_type, remove_with: '12.11', remove_after: '2020-04-22' ignore_column :bot_type, remove_with: '13.1', remove_after: '2020-05-22'
ignore_column :ghost, remove_with: '13.2', remove_after: '2020-06-22' ignore_column :ghost, remove_with: '13.2', remove_after: '2020-06-22'
# Override Devise::Models::Trackable#update_tracked_fields! # Override Devise::Models::Trackable#update_tracked_fields!
......
---
title: Remove obsolete bot_type column
merge_request: 27076
author:
type: other
...@@ -469,7 +469,6 @@ tables: ...@@ -469,7 +469,6 @@ tables:
- last_activity_on - last_activity_on
- notified_of_own_activity - notified_of_own_activity
- user_type - user_type
- bot_type
- preferred_language - preferred_language
- theme_id - theme_id
# frozen_string_literal: true
class RemoveBotType < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
remove_concurrent_index_by_name :users, 'index_users_on_bot_type'
with_lock_retries do
remove_column :users, :bot_type
end
end
def down
unless column_exists?(:users, :bot_type)
with_lock_retries do
add_column :users, :bot_type, :integer, limit: 2 # rubocop:disable Migration/AddColumnsToWideTables
end
end
execute 'UPDATE users set bot_type = user_type WHERE user_type IN(1,2,3,6)'
add_concurrent_index :users, :bot_type
end
end
...@@ -6778,7 +6778,6 @@ CREATE TABLE public.users ( ...@@ -6778,7 +6778,6 @@ CREATE TABLE public.users (
commit_email character varying, commit_email character varying,
group_view integer, group_view integer,
managing_group_id integer, managing_group_id integer,
bot_type smallint,
first_name character varying(255), first_name character varying(255),
last_name character varying(255), last_name character varying(255),
static_object_token character varying(255), static_object_token character varying(255),
...@@ -10732,8 +10731,6 @@ CREATE INDEX index_users_on_accepted_term_id ON public.users USING btree (accept ...@@ -10732,8 +10731,6 @@ CREATE INDEX index_users_on_accepted_term_id ON public.users USING btree (accept
CREATE INDEX index_users_on_admin ON public.users USING btree (admin); CREATE INDEX index_users_on_admin ON public.users USING btree (admin);
CREATE INDEX index_users_on_bot_type ON public.users USING btree (bot_type);
CREATE UNIQUE INDEX index_users_on_confirmation_token ON public.users USING btree (confirmation_token); CREATE UNIQUE INDEX index_users_on_confirmation_token ON public.users USING btree (confirmation_token);
CREATE INDEX index_users_on_created_at ON public.users USING btree (created_at); CREATE INDEX index_users_on_created_at ON public.users USING btree (created_at);
...@@ -13765,6 +13762,7 @@ COPY "schema_migrations" (version) FROM STDIN; ...@@ -13765,6 +13762,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200506085748 20200506085748
20200506125731 20200506125731
20200507221434 20200507221434
20200508091106
20200511145545 20200511145545
\. \.
...@@ -20,6 +20,8 @@ module Gitlab ...@@ -20,6 +20,8 @@ module Gitlab
end end
def perform(from_id, to_id) def perform(from_id, to_id)
return unless User.column_names.include?('bot_type')
(from_id..to_id).each_slice(BATCH_SIZE) do |ids| (from_id..to_id).each_slice(BATCH_SIZE) do |ids|
execute( execute(
<<-EOF <<-EOF
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment