From 0b3a414be19546df348ebca148362bf370c61c15 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 19 Dec 2017 16:06:09 -0800 Subject: [PATCH] Revert "migrations: Replace special chars in stream & user names with space." This reverts commit acebd3a5e, as well as a subsequent fixup commit 0975bebac "quick fix: Fix migrations to be linear." These changes need more work and thought before they're ready to deploy on any large established Zulip server, such as zulipchat.com. See discussion on #6534. In place of the removed migration, leave behind a placeholder so `manage.py migrate` doesn't get confused on installs where it was already applied. --- ..._disallow_chars_in_stream_and_user_name.py | 42 +++---------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py b/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py index 7a6c80ace4..5098ad0097 100644 --- a/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py +++ b/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py @@ -1,39 +1,5 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations -from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor -from django.db.migrations.state import StateApps -from typing import Text - -def remove_special_chars_from_streamname(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None - Stream = apps.get_model('zerver', 'Stream') - NAME_INVALID_CHARS = ['*', '@', '`', '#'] - for stream in Stream.objects.all(): - if (set(stream.name).intersection(NAME_INVALID_CHARS)): - for char in NAME_INVALID_CHARS: - stream.name = stream.name.replace(char, ' ').strip() - - while Stream.objects.filter(name__iexact=stream.name, realm=stream.realm).exists(): - stream.name = stream.name + '^' - if len(stream.name) > 60: - # extremely unlikely, so just do something valid - stream.name = stream.name[-60:] - stream.save(update_fields=['name']) - -def remove_special_chars_from_username(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None - UserProfile = apps.get_model('zerver', 'UserProfile') - NAME_INVALID_CHARS = ['*', '`', '>', '"', '@', '#'] - for userprofile in UserProfile.objects.all(): - if (set(userprofile.full_name).intersection(NAME_INVALID_CHARS)): - for char in NAME_INVALID_CHARS: - userprofile.full_name = userprofile.full_name.replace(char, ' ').strip() - userprofile.save(update_fields=['full_name']) - - if (set(userprofile.short_name).intersection(NAME_INVALID_CHARS)): - for char in NAME_INVALID_CHARS: - userprofile.short_name = userprofile.short_name.replace(char, ' ').strip() - userprofile.save(update_fields=['short_name']) +from django.db import migrations class Migration(migrations.Migration): @@ -42,6 +8,8 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython(remove_special_chars_from_streamname), - migrations.RunPython(remove_special_chars_from_username), + # There was a migration here, which wasn't ready for wide deployment + # and was backed out. This placeholder is left behind to avoid + # confusing the migration engine on any installs that applied the + # migration. (Fortunately no reverse migration is needed.) ]