mirror of
https://github.com/healthchecks/healthchecks.git
synced 2024-11-23 16:07:39 +00:00
38 lines
1.2 KiB
Python
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)]
|