# Generated by Django 2.2.20 on 2021-05-03 09:45
from os.path import basename

from django.db import migrations

def create_file_names_if_empty(apps, schema_editor):
    """
    Before this migration, if files in the spaces_files app could have empty "name" fields.
    This prevents consistent sort order, though. This migration fills the FileField's basename
    if the user didn't provide a custom name.
    """
    db_alias = schema_editor.connection.alias
    File = apps.get_model("spaces_files", "File")
    for file in File.objects.all():
        if not file.name:
            file.name = basename(file.file.name)
            file.save()
    
    

class Migration(migrations.Migration):

    dependencies = [
        ('spaces_files', '0008_auto_20200422_1110'),
    ]

    operations = [
        migrations.RunPython(create_file_names_if_empty),
        migrations.AlterModelOptions(
            name='file',
            options={'ordering': ['name'], 'verbose_name': 'file', 'verbose_name_plural': 'files'},
        ),
    ]

feeeba15b2f0570af4855bc6b277c8a203d8d3ff
<mask token>


class Migration(migrations.Migration):
    <mask token>
    <mask token>

<mask token>


class Migration(migrations.Migration):
    dependencies = [('spaces_files', '0008_auto_20200422_1110')]
    operations = [migrations.RunPython(create_file_names_if_empty),
        migrations.AlterModelOptions(name='file', options={'ordering': [
        'name'], 'verbose_name': 'file', 'verbose_name_plural': 'files'})]

<mask token>


def create_file_names_if_empty(apps, schema_editor):
    """
    Before this migration, if files in the spaces_files app could have empty "name" fields.
    This prevents consistent sort order, though. This migration fills the FileField's basename
    if the user didn't provide a custom name.
    """
    db_alias = schema_editor.connection.alias
    File = apps.get_model('spaces_files', 'File')
    for file in File.objects.all():
        if not file.name:
            file.name = basename(file.file.name)
            file.save()


class Migration(migrations.Migration):
    dependencies = [('spaces_files', '0008_auto_20200422_1110')]
    operations = [migrations.RunPython(create_file_names_if_empty),
        migrations.AlterModelOptions(name='file', options={'ordering': [
        'name'], 'verbose_name': 'file', 'verbose_name_plural': 'files'})]

from os.path import basename
from django.db import migrations


def create_file_names_if_empty(apps, schema_editor):
    """
    Before this migration, if files in the spaces_files app could have empty "name" fields.
    This prevents consistent sort order, though. This migration fills the FileField's basename
    if the user didn't provide a custom name.
    """
    db_alias = schema_editor.connection.alias
    File = apps.get_model('spaces_files', 'File')
    for file in File.objects.all():
        if not file.name:
            file.name = basename(file.file.name)
            file.save()


class Migration(migrations.Migration):
    dependencies = [('spaces_files', '0008_auto_20200422_1110')]
    operations = [migrations.RunPython(create_file_names_if_empty),
        migrations.AlterModelOptions(name='file', options={'ordering': [
        'name'], 'verbose_name': 'file', 'verbose_name_plural': 'files'})]

# Generated by Django 2.2.20 on 2021-05-03 09:45
from os.path import basename

from django.db import migrations

def create_file_names_if_empty(apps, schema_editor):
    """
    Before this migration, if files in the spaces_files app could have empty "name" fields.
    This prevents consistent sort order, though. This migration fills the FileField's basename
    if the user didn't provide a custom name.
    """
    db_alias = schema_editor.connection.alias
    File = apps.get_model("spaces_files", "File")
    for file in File.objects.all():
        if not file.name:
            file.name = basename(file.file.name)
            file.save()
    
    

class Migration(migrations.Migration):

    dependencies = [
        ('spaces_files', '0008_auto_20200422_1110'),
    ]

    operations = [
        migrations.RunPython(create_file_names_if_empty),
        migrations.AlterModelOptions(
            name='file',
            options={'ordering': ['name'], 'verbose_name': 'file', 'verbose_name_plural': 'files'},
        ),
    ]
