2017-11-13 01:15:11 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2023-02-06 14:59:57 +00:00
|
|
|
from django.conf import settings
|
2017-11-13 01:15:11 +00:00
|
|
|
from django.db import migrations
|
|
|
|
|
|
|
|
|
|
|
|
def add_settings(apps, schema_editor):
|
2022-02-10 00:00:30 +00:00
|
|
|
Settings = apps.get_model("babybuddy", "Settings")
|
2023-02-06 14:59:57 +00:00
|
|
|
User = apps.get_model(settings.AUTH_USER_MODEL)
|
2017-11-13 01:15:11 +00:00
|
|
|
for user in User.objects.all():
|
|
|
|
if Settings.objects.filter(user=user).count() == 0:
|
2023-02-06 14:59:57 +00:00
|
|
|
user_settings = Settings.objects.create(user=user)
|
|
|
|
user_settings.save()
|
2017-11-13 01:15:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
initial = True
|
|
|
|
|
|
|
|
dependencies = [
|
2022-02-10 00:00:30 +00:00
|
|
|
("babybuddy", "0001_initial"),
|
2017-11-13 01:15:11 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(add_settings, reverse_code=migrations.RunPython.noop),
|
|
|
|
]
|