Skip to content

Update user_type value for humans

What does this MR do and why?

Adds new user_type value for humans. This MR is part of #386474 (closed) efforts to migrate human user type from NULL to 0

Query plans

How to test

Loading development environment (Rails 6.1.7.2)
[1] pry(main)> User.first.user_type
  User Load (3.3ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 /*application:console,db_config_name:main,console_hostname:Skyline-90.local,console_username:shutin,line:(pry):1:in `__pry__'*/
=> "human_deprecated"
[2] pry(main)> User.first.human?
  User Load (0.8ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 /*application:console,db_config_name:main,console_hostname:Skyline-90.local,console_username:shutin,line:(pry):2:in `__pry__'*/
=> true
[3] pry(main)> User.last.user_type
  User Load (2.0ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application:console,db_config_name:main,console_hostname:Skyline-90.local,console_username:shutin,line:(pry):3:in `__pry__'*/
=> "human"
[4] pry(main)> User.last.human?
  User Load (0.5ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application:console,db_config_name:main,console_hostname:Skyline-90.local,console_username:shutin,line:(pry):4:in `__pry__'*/
=> true
[5] pry(main)> User.human.include?(User.first)
  User Load (0.8ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 /*application:console,db_config_name:main,console_hostname:Skyline-90.local,console_username:shutin,line:(pry):5:in `__pry__'*/
  User Exists? (0.5ms)  SELECT 1 AS one FROM "users" WHERE ("users"."user_type" = 0 OR "users"."user_type" IS NULL) AND "users"."id" = 1 LIMIT 1 /*application:console,db_config_name:main,console_hostname:Skyline-90.local,console_username:shutin,line:(pry):5:in `__pry__'*/
=> true
[6] pry(main)> User.human.include?(User.last)
  User Load (0.7ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application:console,db_config_name:main,console_hostname:Skyline-90.local,console_username:shutin,line:(pry):6:in `__pry__'*/
  User Exists? (0.4ms)  SELECT 1 AS one FROM "users" WHERE ("users"."user_type" = 0 OR "users"."user_type" IS NULL) AND "users"."id" = 45 LIMIT 1 /*application:console,db_config_name:main,console_hostname:Skyline-90.local,console_username:shutin,line:(pry):6:in `__pry__'*/
=> true
[7] pry(main)> User.new.user_type
=> "human"

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #386474 (closed)

Edited by Pavel Shutsin

Merge request reports

Loading