 # Generated by Django 4.2.17 on 2025-01-09 14:43

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


class Migration(migrations.Migration):

    dependencies = [
        ('db', '0089_workspacehomepreference_and_more'),
    ]

    operations = [
        migrations.RenameModel(
            old_name='Dashboard',
            new_name='DeprecatedDashboard',
        ),
        migrations.RenameModel(
            old_name='DashboardWidget',
            new_name='DeprecatedDashboardWidget',
        ),
        migrations.RenameModel(
            old_name='Widget',
            new_name='DeprecatedWidget',
        ),
        migrations.AlterModelOptions(
            name='deprecateddashboard',
            options={'ordering': ('-created_at',), 'verbose_name': 'DeprecatedDashboard', 'verbose_name_plural': 'DeprecatedDashboards'},
        ),
        migrations.AlterModelOptions(
            name='deprecateddashboardwidget',
            options={'ordering': ('-created_at',), 'verbose_name': 'Deprecated Dashboard Widget', 'verbose_name_plural': 'Deprecated Dashboard Widgets'},
        ),
        migrations.AlterModelOptions(
            name='deprecatedwidget',
            options={'ordering': ('-created_at',), 'verbose_name': 'DeprecatedWidget', 'verbose_name_plural': 'DeprecatedWidgets'},
        ),
        migrations.AlterField(
            model_name='workspacehomepreference',
            name='sort_order',
            field=models.FloatField(default=65535),
        ),
        migrations.AlterModelTable(
            name='deprecateddashboard',
            table='deprecated_dashboards',
        ),
        migrations.AlterModelTable(
            name='deprecateddashboardwidget',
            table='deprecated_dashboard_widgets',
        ),
        migrations.AlterModelTable(
            name='deprecatedwidget',
            table='deprecated_widgets',
        ),
        migrations.CreateModel(
            name='WorkspaceUserPreference',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Last Modified At')),
                ('deleted_at', models.DateTimeField(blank=True, null=True, verbose_name='Deleted At')),
                ('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
                ('key', models.CharField(max_length=255)),
                ('is_pinned', models.BooleanField(default=False)),
                ('sort_order', models.FloatField(default=65535)),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL, verbose_name='Created By')),
                ('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_updated_by', to=settings.AUTH_USER_MODEL, verbose_name='Last Modified By')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_user_preferences', to=settings.AUTH_USER_MODEL)),
                ('workspace', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_user_preferences', to='db.workspace')),
            ],
            options={
                'verbose_name': 'Workspace User Preference',
                'verbose_name_plural': 'Workspace User Preferences',
                'db_table': 'workspace_user_preferences',
                'ordering': ('-created_at',),
            },
        ),
        migrations.AddConstraint(
            model_name='workspaceuserpreference',
            constraint=models.UniqueConstraint(condition=models.Q(('deleted_at__isnull', True)), fields=('workspace', 'user', 'key'), name='workspace_user_preferences_unique_workspace_user_key_when_deleted_at_null'),
        ),
        migrations.AlterUniqueTogether(
            name='workspaceuserpreference',
            unique_together={('workspace', 'user', 'key', 'deleted_at')},
        ),
    ]
