2017-05-03 03:46:36 +02:00
# Generated by Django 1.10.5 on 2017-05-02 21:44
import django . core . validators
from django . db import migrations , models
2020-04-27 07:19:08 +02:00
from django . db . backends . postgresql . schema import DatabaseSchemaEditor
2017-05-03 03:46:36 +02:00
from django . db . migrations . state import StateApps
2020-01-14 21:59:46 +01:00
2017-05-03 03:46:36 +02:00
class Migration ( migrations . Migration ) :
dependencies = [
( ' zerver ' , ' 0080_realm_description_length ' ) ,
]
2017-10-26 11:36:30 +02:00
def emoji_to_lowercase ( apps : StateApps , schema_editor : DatabaseSchemaEditor ) - > None :
2017-05-03 03:46:36 +02:00
RealmEmoji = apps . get_model ( " zerver " , " RealmEmoji " )
emoji = RealmEmoji . objects . all ( )
for e in emoji :
# Technically, this could create a conflict, but it's
# exceedingly unlikely. If that happens, the sysadmin can
# manually rename the conflicts with the manage.py shell
# and then rerun the migration/upgrade.
e . name = e . name . lower ( )
e . save ( )
operations = [
2020-04-29 08:43:25 +02:00
migrations . RunPython ( emoji_to_lowercase , elidable = True ) ,
2017-05-03 03:46:36 +02:00
migrations . AlterField (
model_name = ' realmemoji ' ,
name = ' name ' ,
field = models . TextField ( validators = [ django . core . validators . MinLengthValidator ( 1 ) , django . core . validators . RegexValidator ( message = ' Invalid characters in emoji name ' , regex = ' ^[0-9a-z. \\ -_]+(?<![. \\ -_])$ ' ) ] ) ,
) ,
]