Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Length of username in database may be too short for X.509 DNs and 255 seems a sane value for it. Fixes bug #1081932 Change-Id: Ie8f696845ea15d37cf13f3fe7978b22deac798b0
- Loading branch information
1 parent
049c5c7
commit 8d6055e
Showing
6 changed files
with
75 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
keystone/common/sql/migrate_repo/versions/032_username_length.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import sqlalchemy as sql | ||
from sqlalchemy.orm import sessionmaker | ||
|
||
|
||
def upgrade(migrate_engine): | ||
meta = sql.MetaData() | ||
meta.bind = migrate_engine | ||
user_table = sql.Table('user', meta, autoload=True) | ||
user_table.c.name.alter(type=sql.String(255)) | ||
|
||
|
||
def downgrade(migrate_engine): | ||
meta = sql.MetaData() | ||
meta.bind = migrate_engine | ||
user_table = sql.Table('user', meta, autoload=True) | ||
if migrate_engine.name != 'mysql': | ||
# NOTE(aloga): sqlite does not enforce length on the | ||
# VARCHAR types: http://www.sqlite.org/faq.html#q9 | ||
# postgresql and DB2 do not truncate. | ||
maker = sessionmaker(bind=migrate_engine) | ||
session = maker() | ||
for user in session.query(user_table).all(): | ||
values = {'name': user.name[:64]} | ||
update = (user_table.update(). | ||
where(user_table.c.id == user.id). | ||
values(values)) | ||
migrate_engine.execute(update) | ||
|
||
session.commit() | ||
session.close() | ||
user_table.c.name.alter(type=sql.String(64)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters