Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a basic migration script to v2.
This should probably use south, but it'll work for anyone using any migration system.
- Loading branch information
1 parent
cd34f2f
commit 80f199d
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.db import connection | ||
|
||
cursor = connection.cursor() | ||
cursor.execute('alter table kong_site add column "servername" varchar(100)') | ||
cursor.execute('alter table kong_site drop column client_id') | ||
cursor.execute('alter table kong_site drop column settings') | ||
cursor.execute('alter table kong_site drop column pythonpath') | ||
cursor.execute('select site_ptr_id, servername from kong_hostedsite') | ||
rows = cursor.fetchall() | ||
names = dict([(row[0], row[1]) for row in rows]) | ||
|
||
from kong.models import Site | ||
for site in Site.objects.all(): | ||
site.servername = names[site.pk] | ||
site.save() | ||
|
||
""" | ||
cursor.execute('delete table kong_alias') | ||
cursor.execute('delete table kong_client') | ||
cursor.execute('delete table kong_deploytarget') | ||
cursor.execute('delete table kong_deploytarget_servers') | ||
cursor.execute('delete table kong_hostedsite') | ||
cursor.execute('delete table kong_hostedsite_on_servers') | ||
cursor.execute('delete table kong_server') | ||
cursor.execute('delete table kong_test_sites') | ||
""" |