sql: switch role uuid column to varchar (#52156)

This commit is contained in:
Frédéric Péters 2021-03-18 10:03:06 +01:00
parent af87cabb0d
commit 2d0ffd609f
1 changed files with 5 additions and 3 deletions

View File

@ -830,6 +830,7 @@ def do_role_table(concurrently=False):
allows_backoffice_access BOOLEAN)'''
% table_name
)
cur.execute('ALTER TABLE roles ALTER COLUMN uuid TYPE VARCHAR')
cur.execute(
'''SELECT column_name FROM information_schema.columns
WHERE table_schema = 'public'
@ -2514,7 +2515,7 @@ class Role(SqlMixin, wcs.roles.Role):
_table_static_fields = [
('id', 'varchar'),
('name', 'varchar'),
('uuid', 'uuid'),
('uuid', 'varchar'),
('slug', 'varchar'),
('internal', 'boolean'),
('details', 'varchar'),
@ -3301,7 +3302,7 @@ def get_period_total(
# latest migration, number + description (description is not used
# programmaticaly but will make sure git conflicts if two migrations are
# separately added with the same number)
SQL_LEVEL = (49, 'Role migration')
SQL_LEVEL = (50, 'switch role uuid column to varchar')
def migrate_global_views(conn, cur):
@ -3472,8 +3473,9 @@ def migrate():
# 47: store LoggedErrors in SQL
# 48: remove acked attribute from LoggedError
do_loggederrors_table()
if sql_level < 49:
if sql_level < 50:
# 49: store Role in SQL
# 50: switch role uuid column to varchar
do_role_table()
migrate_legacy_roles()