Add check constraint for users.username (#12741)
This commit is contained in:
parent
c7c907ac86
commit
acb79a2cf2
2 changed files with 13 additions and 1 deletions
|
|
@ -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
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue