docbrown/db/migrate/20210219043102_add_check_constraint_for_username.rb
2021-02-22 16:49:21 -05:00

12 lines
293 B
Ruby

class AddCheckConstraintForUsername < ActiveRecord::Migration[6.0]
def change
safety_assured do
execute(<<~SQL.squish)
ALTER TABLE "users"
ADD CONSTRAINT "users_username_not_null"
CHECK ("username" IS NOT NULL)
NOT VALID
SQL
end
end
end