From 5d10e28d6903fd8d1c55075fe1f8988f77c476e5 Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 17 May 2024 13:30:34 +0200 Subject: [PATCH] feat(migrations): Initialize database schema for messaging This commit introduces the initial set of database migrations required for setting up the foundational models of the messaging system within the application. These models include `GatewayUser`, `GatewayUserSetting`, `Notification`, and various scheduling entities to manage notification delivery timings. It lays the groundwork for linking users to their gateway preferences, storing customizable settings per gateway-user pair, and managing notifications with flexible scheduling options. This schema setup is crucial for supporting a dynamic and configurable messaging system, enabling efficient notification management and dispatching based on user preferences and predefined schedules. By establishing a robust database schema upfront, we ensure that the application can scale effectively, facilitating ease of maintenance and future enhancements. This migration caters to the need for a cohesive and flexible data model to represent users, their notification preferences, and the logistics of notification dispatching and scheduling within the system. --- msgio/migrations/0001_initial.py | 70 ++++++++++++++++++++++++++++++++ msgio/migrations/__init__.py | 0 2 files changed, 70 insertions(+) create mode 100644 msgio/migrations/0001_initial.py create mode 100644 msgio/migrations/__init__.py diff --git a/msgio/migrations/0001_initial.py b/msgio/migrations/0001_initial.py new file mode 100644 index 0000000..bb9fcc4 --- /dev/null +++ b/msgio/migrations/0001_initial.py @@ -0,0 +1,70 @@ +# Generated by Django 5.0.6 on 2024-05-17 11:30 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='GatewayUser', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('gateway', models.CharField(max_length=64)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='GatewayUserSetting', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('key', models.CharField(max_length=64)), + ('value', models.CharField(max_length=256)), + ('gatewayuser', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='msgio.gatewayuser')), + ], + ), + migrations.CreateModel( + name='Notification', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('content', models.TextField()), + ('app', models.CharField(blank=True, max_length=64, null=True)), + ('data', models.CharField(blank=True, max_length=128, null=True)), + ('recipient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='NotificationDailySchedule', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('time', models.TimeField()), + ('last_sent', models.DateField(blank=True, null=True)), + ('notification', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='msgio.notification')), + ], + ), + migrations.CreateModel( + name='NotificationDatetimeSchedule', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('datetime', models.DateTimeField()), + ('sent', models.BooleanField(default=False)), + ('notification', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='msgio.notification')), + ], + ), + migrations.CreateModel( + name='NotificationDispatcher', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('dispatcher', models.CharField(max_length=64)), + ('notification', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='msgio.notification')), + ], + ), + ] diff --git a/msgio/migrations/__init__.py b/msgio/migrations/__init__.py new file mode 100644 index 0000000..e69de29