healthchecks_healthchecks/hc/accounts/migrations/0018_auto_20190112_1426.py
2023-10-25 18:12:12 +03:00

38 lines
1.2 KiB
Python

# Generated by Django 2.1.5 on 2019-01-11 14:49
from __future__ import annotations
from typing import Any
from django.apps.registry import Apps
from django.db import migrations
def create_projects(apps: Apps, schema_editor: Any) -> None:
Profile = apps.get_model("accounts", "Profile")
Project = apps.get_model("accounts", "Project")
Member = apps.get_model("accounts", "Member")
for profile in Profile.objects.all():
project = Project()
project.name = profile.team_name
project.owner_id = profile.user_id
project.api_key = profile.api_key
project.api_key_readonly = profile.api_key_readonly
project.save()
profile.current_project = project
profile.save()
Member.objects.filter(team=profile).update(project=project)
for profile in Profile.objects.all():
if profile.current_team_id:
profile.current_project = profile.current_team.current_project
profile.save()
class Migration(migrations.Migration):
dependencies = [("accounts", "0017_auto_20190112_1426")]
operations = [migrations.RunPython(create_projects, migrations.RunPython.noop)]