Add check constraint for users.username (#12741)

This commit is contained in:
Michael Kohl 2021-02-23 04:49:21 +07:00 committed by GitHub
parent c7c907ac86
commit acb79a2cf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -0,0 +1,12 @@
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

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_02_16_023520) do
ActiveRecord::Schema.define(version: 2021_02_19_043102) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"