Skip to content
Snippets Groups Projects
Commit 13420dd8 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Bugfix for initial data migration of sites app

parent e48b157f
No related branches found
No related tags found
1 merge request!8Superevents
......@@ -20,25 +20,29 @@ SITES = {
def update_site(apps, schema_editor):
Site = apps.get_model('sites', 'Site')
# Get current site matching SITE_ID, should be example.com at this point
site1 = Site.objects.get(id=settings.SITE_ID)
# Get or create our new site:
# If all migrations are being run at once, there shouldn't be any sites
# since the initial example site is created by a post_migrate signal
# If this is being run individually, then we overwrite the existing
# example.com site
site, created = Site.objects.get_or_create(id=settings.SITE_ID)
# Update with new site name and domain
site1.name = SITES['new']['name']
site1.domain = SITES['new']['domain']
site1.save()
site.name = SITES['new']['name']
site.domain = SITES['new']['domain']
site.save()
def revert_site(apps, schema_editor):
Site = apps.get_model('sites', 'Site')
# Get current site matching SITE_ID should be ligo.org
site1 = Site.objects.get(id=settings.SITE_ID)
site = Site.objects.get(id=settings.SITE_ID)
# Revert to original site
site1.name = SITES['old']['name']
site1.domain = SITES['old']['domain']
site1.save()
site.name = SITES['old']['name']
site.domain = SITES['old']['domain']
site.save()
class Migration(migrations.Migration):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment