Class: Gitlab::BackgroundMigration::MigrateUsersBioToUserDetails
- Inherits:
-
Object
- Object
- Gitlab::BackgroundMigration::MigrateUsersBioToUserDetails
- Defined in:
- lib/gitlab/background_migration/migrate_users_bio_to_user_details.rb
Defined Under Namespace
Classes: User, UserDetails
Instance Method Summary collapse
Instance Method Details
#perform(start_id, stop_id) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitlab/background_migration/migrate_users_bio_to_user_details.rb', line 15 def perform(start_id, stop_id) return if Feature.disabled?(:migrate_bio_to_user_details, default_enabled: true) relation = User .select("id AS user_id", "substring(COALESCE(bio, '') from 1 for 255) AS bio") .where("(COALESCE(bio, '') IS DISTINCT FROM '')") .where(id: (start_id..stop_id)) ActiveRecord::Base.connection.execute <<-EOF.strip_heredoc INSERT INTO user_details (user_id, bio) #{relation.to_sql} ON CONFLICT (user_id) DO UPDATE SET "bio" = EXCLUDED."bio"; EOF end |