# Generated by Django 2.2 on 2021-03-25 17:02

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Dialog',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='отправлено')),
                ('name', models.CharField(blank=True, max_length=64, verbose_name='имя')),
            ],
            options={
                'verbose_name': 'диалог',
                'verbose_name_plural': 'диалоги',
                'ordering': ['-created'],
            },
        ),
        migrations.CreateModel(
            name='DialogMemebers',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role', models.CharField(choices=[(0, 'создатель'), (1, 'собеседник')], db_index=True, max_length=128, verbose_name='роль')),
                ('dialog', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='members', to='mainapp.Dialog', verbose_name='диалог')),
                ('member', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='dialogs', to=settings.AUTH_USER_MODEL, verbose_name='участник диалога')),
            ],
            options={
                'ordering': ['dialog', '-role', 'member'],
            },
        ),
        migrations.CreateModel(
            name='Message',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField(verbose_name='сообщение')),
                ('read', models.BooleanField(default=False, verbose_name='прочитано')),
                ('created', models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='отправлено')),
                ('sender', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mainapp.DialogMemebers', verbose_name='отправитель')),
            ],
            options={
                'verbose_name': 'сообщение',
                'verbose_name_plural': 'сообщения',
                'ordering': ['sender', '-created'],
            },
        ),
    ]

# Generated by Django 2.2 on 2021-03-25 17:02

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Dialog',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='отправлено')),
                ('name', models.CharField(blank=True, max_length=64, verbose_name='имя')),
            ],
            options={
                'verbose_name': 'диалог',
                'verbose_name_plural': 'диалоги',
                'ordering': ['-created'],
            },
        ),
        migrations.CreateModel(
            name='DialogMemebers',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role', models.CharField(choices=[(0, 'создатель'), (1, 'собеседник')], db_index=True, max_length=128, verbose_name='роль')),
                ('dialog', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='members', to='mainapp.Dialog', verbose_name='диалог')),
                ('member', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='dialogs', to=settings.AUTH_USER_MODEL, verbose_name='участник диалога')),
            ],
            options={
                'ordering': ['dialog', '-role', 'member'],
            },
        ),
        migrations.CreateModel(
            name='Message',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField(verbose_name='сообщение')),
                ('read', models.BooleanField(default=False, verbose_name='прочитано')),
                ('created', models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='отправлено')),
                ('sender', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mainapp.DialogMemebers', verbose_name='отправитель')),
            ],
            options={
                'verbose_name': 'сообщение',
                'verbose_name_plural': 'сообщения',
                'ordering': ['sender', '-created'],
            },
        ),
    ]

# Generated by Django 2.2 on 2021-03-25 17:02