Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mentat-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
713
Mentat
mentat-test
Commits
ccb6945a
Commit
ccb6945a
authored
2 years ago
by
Rajmund Hruška
Browse files
Options
Downloads
Patches
Plain Diff
Feature: Add CHECK constraint for email and login. (Redmine issue:
#7593
)
parent
d441e13a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/hawat/migrations/versions/432c8bc8e49b_lowercase_check.py
+23
-0
23 additions, 0 deletions
...hawat/migrations/versions/432c8bc8e49b_lowercase_check.py
lib/mentat/datatype/sqldb.py
+2
-2
2 additions, 2 deletions
lib/mentat/datatype/sqldb.py
with
25 additions
and
2 deletions
lib/hawat/migrations/versions/432c8bc8e49b_lowercase_check.py
0 → 100644
+
23
−
0
View file @
ccb6945a
"""
Lowercase check constraint
Revision ID: 432c8bc8e49b
Revises: 426e6e986b40
Create Date: 2022-07-19 11:48:46.111909
"""
from
alembic
import
op
# revision identifiers, used by Alembic.
revision
=
'
432c8bc8e49b
'
down_revision
=
'
426e6e986b40
'
branch_labels
=
None
depends_on
=
None
def
upgrade
():
op
.
execute
(
"
ALTER TABLE users ADD CONSTRAINT login_lowercase CHECK (login = lower(login))
"
)
op
.
execute
(
"
ALTER TABLE users ADD CONSTRAINT email_lowercase CHECK (email = lower(email))
"
)
def
downgrade
():
op
.
execute
(
"
ALTER TABLE users DROP CONSTRAINT login_lowercase
"
)
op
.
execute
(
"
ALTER TABLE users DROP CONSTRAINT email_lowercase
"
)
This diff is collapsed.
Click to expand it.
lib/mentat/datatype/sqldb.py
+
2
−
2
View file @
ccb6945a
...
@@ -188,9 +188,9 @@ class UserModel(MODEL):
...
@@ -188,9 +188,9 @@ class UserModel(MODEL):
"""
"""
__tablename__
=
'
users
'
__tablename__
=
'
users
'
login
=
sqlalchemy
.
Column
(
sqlalchemy
.
String
(
50
),
unique
=
True
,
index
=
True
)
login
=
sqlalchemy
.
Column
(
sqlalchemy
.
String
(
50
),
sqlalchemy
.
CheckConstraint
(
'
login = lower(login)
'
,
name
=
'
login_lowercase
'
),
unique
=
True
,
index
=
True
)
fullname
=
sqlalchemy
.
Column
(
sqlalchemy
.
String
(
100
),
nullable
=
False
)
fullname
=
sqlalchemy
.
Column
(
sqlalchemy
.
String
(
100
),
nullable
=
False
)
email
=
sqlalchemy
.
Column
(
sqlalchemy
.
String
(
250
),
nullable
=
False
)
email
=
sqlalchemy
.
Column
(
sqlalchemy
.
String
(
250
),
sqlalchemy
.
CheckConstraint
(
'
email = lower(email)
'
,
name
=
'
email_lowercase
'
),
nullable
=
False
)
organization
=
sqlalchemy
.
Column
(
sqlalchemy
.
String
(
250
),
nullable
=
False
)
organization
=
sqlalchemy
.
Column
(
sqlalchemy
.
String
(
250
),
nullable
=
False
)
roles
=
sqlalchemy
.
Column
(
sqlalchemy
.
dialects
.
postgresql
.
ARRAY
(
sqlalchemy
.
String
(
20
),
dimensions
=
1
),
nullable
=
False
,
default
=
[])
roles
=
sqlalchemy
.
Column
(
sqlalchemy
.
dialects
.
postgresql
.
ARRAY
(
sqlalchemy
.
String
(
20
),
dimensions
=
1
),
nullable
=
False
,
default
=
[])
password
=
sqlalchemy
.
Column
(
sqlalchemy
.
String
)
password
=
sqlalchemy
.
Column
(
sqlalchemy
.
String
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment