Skip to content

Commit 46b3627

Browse files
committed
DB migration to fix now invalid User.names updated to account for name uniqueness constraint.
1 parent 45cc8bb commit 46b3627

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

migrations/MANUAL-fix-usernames-6b042b.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,19 @@ def upgrade(self, session):
3434
expression = """
3535
UPDATE iam_users
3636
SET
37-
email = COALESCE(email, name),
38-
name = SUBSTRING(name, 1, POSITION('@' IN name) - 1)
37+
name = REPLACE(name, '@', '.at.')
3938
WHERE name LIKE '%@%';
4039
"""
4140
session.execute(expression)
4241

4342
def downgrade(self, session):
44-
pass
43+
expression = """
44+
UPDATE iam_users
45+
SET
46+
name = REPLACE(name, '.at.', '@')
47+
WHERE name LIKE '%.at.%';
48+
"""
49+
session.execute(expression)
4550

4651

4752
migration_step = MigrationStep()

0 commit comments

Comments
 (0)