# Generated by Django 3.2.21 on 2023-11-30 14:41

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

import baserow_premium.row_comments.models

import baserow.core.fields


class Migration(migrations.Migration):
    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("database", "0141_formview_users_to_notify_on_submit"),
        ("baserow_premium", "0015_delete_stale_fieldoptions"),
    ]

    operations = [
        migrations.CreateModel(
            name="RowCommentsNotificationMode",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_on", models.DateTimeField(auto_now_add=True)),
                ("updated_on", baserow.core.fields.SyncedDateTimeField(auto_now=True)),
                (
                    "row_id",
                    models.PositiveIntegerField(
                        help_text="The id of the row the subscription is for."
                    ),
                ),
                (
                    "mode",
                    models.CharField(
                        choices=[
                            (
                                baserow_premium.row_comments.models.RowCommentsNotificationModes[
                                    "MODE_ALL_COMMENTS"
                                ],
                                "All comments",
                            ),
                            (
                                baserow_premium.row_comments.models.RowCommentsNotificationModes[
                                    "MODE_ONLY_MENTIONS"
                                ],
                                "Only mentions",
                            ),
                        ],
                        default=baserow_premium.row_comments.models.RowCommentsNotificationModes[
                            "MODE_ONLY_MENTIONS"
                        ],
                        help_text="The notification mode for this user and row.",
                        max_length=32,
                    ),
                ),
                (
                    "table",
                    models.ForeignKey(
                        help_text="The table where the row is found in.",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="database.table",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        help_text="The user who wants to receive notifications for this row.",
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "unique_together": {("table", "row_id", "user")},
            },
        ),
    ]
