You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

  1. # Generated by Django 2.1.5 on 2019-01-11 14:49
  2. from django.db import migrations
  3. def create_projects(apps, schema_editor):
  4. Profile = apps.get_model("accounts", "Profile")
  5. Project = apps.get_model("accounts", "Project")
  6. Member = apps.get_model("accounts", "Member")
  7. for profile in Profile.objects.all():
  8. project = Project()
  9. project.name = profile.team_name
  10. project.owner_id = profile.user_id
  11. project.api_key = profile.api_key
  12. project.api_key_readonly = profile.api_key_readonly
  13. project.save()
  14. profile.current_project = project
  15. profile.save()
  16. Member.objects.filter(team=profile).update(project=project)
  17. for profile in Profile.objects.all():
  18. if profile.current_team_id:
  19. profile.current_project = profile.current_team.current_project
  20. profile.save()
  21. class Migration(migrations.Migration):
  22. dependencies = [
  23. ('accounts', '0017_auto_20190112_1426'),
  24. ]
  25. operations = [
  26. migrations.RunPython(create_projects, migrations.RunPython.noop),
  27. ]