from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('zerver', '0188_userprofile_enable_login_emails'),
    ]

    operations = [
        migrations.AlterField(
            model_name='userprofile',
            name='emojiset',
            field=models.CharField(choices=[('google', 'Google modern'), ('google-blob', 'Google classic'), ('twitter', 'Twitter'), ('text', 'Plain text')], default='google-blob', max_length=20),
        ),
    ]

from __future__ import unicode_literals

from django.db import migrations, models
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps

def change_emojiset_choice(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
    UserProfile = apps.get_model('zerver', 'UserProfile')
    UserProfile.objects.filter(emojiset='google').update(emojiset='google-blob')

class Migration(migrations.Migration):

    dependencies = [
        ('zerver', '0188_userprofile_enable_login_emails'),
    ]

    operations = [
        migrations.AlterField(
            model_name='userprofile',
            name='emojiset',
            field=models.CharField(choices=[('google', 'Google modern'), ('google-blob', 'Google classic'), ('twitter', 'Twitter'), ('text', 'Plain text')], default='google-blob', max_length=20),
        ),
        migrations.RunPython(
            change_emojiset_choice,
            reverse_code=migrations.RunPython.noop),
    ]

Set default emoji to google-blob for existing users too.
emoji: Set default emoji to google-blob for existing users too.

This fixes an inconsistent test failure with test_users.py (that
depended on the ordering between this migration and the creation of
test database users like hamlet).

  from __future__ import unicode_literals
  
  from django.db import migrations, models
+ from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
+ from django.db.migrations.state import StateApps
  
+ def change_emojiset_choice(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
+     UserProfile = apps.get_model('zerver', 'UserProfile')
+     UserProfile.objects.filter(emojiset='google').update(emojiset='google-blob')
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('zerver', '0188_userprofile_enable_login_emails'),
      ]
  
      operations = [
          migrations.AlterField(
              model_name='userprofile',
              name='emojiset',
              field=models.CharField(choices=[('google', 'Google modern'), ('google-blob', 'Google classic'), ('twitter', 'Twitter'), ('text', 'Plain text')], default='google-blob', max_length=20),
          ),
+         migrations.RunPython(
+             change_emojiset_choice,
+             reverse_code=migrations.RunPython.noop),
      ]
  
Set default emoji to google-blob for existing users too.
## Code Before:
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('zerver', '0188_userprofile_enable_login_emails'),
    ]

    operations = [
        migrations.AlterField(
            model_name='userprofile',
            name='emojiset',
            field=models.CharField(choices=[('google', 'Google modern'), ('google-blob', 'Google classic'), ('twitter', 'Twitter'), ('text', 'Plain text')], default='google-blob', max_length=20),
        ),
    ]

## Instruction:
Set default emoji to google-blob for existing users too.
## Code After:
from __future__ import unicode_literals

from django.db import migrations, models
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps

def change_emojiset_choice(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
    UserProfile = apps.get_model('zerver', 'UserProfile')
    UserProfile.objects.filter(emojiset='google').update(emojiset='google-blob')

class Migration(migrations.Migration):

    dependencies = [
        ('zerver', '0188_userprofile_enable_login_emails'),
    ]

    operations = [
        migrations.AlterField(
            model_name='userprofile',
            name='emojiset',
            field=models.CharField(choices=[('google', 'Google modern'), ('google-blob', 'Google classic'), ('twitter', 'Twitter'), ('text', 'Plain text')], default='google-blob', max_length=20),
        ),
        migrations.RunPython(
            change_emojiset_choice,
            reverse_code=migrations.RunPython.noop),
    ]
