diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-09-07 18:49:47 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-09-07 19:01:05 +0200 |
commit | 5833aa61d039bf3d1f4372e0390ffc53b7d63eb9 (patch) | |
tree | 694de5c4a2e2faf586fc4e41ab3cca249f947c17 /chimere/scripts/upgrade.py | |
parent | d59f0d18f8a92bdd615c114544f727284a71d66e (diff) | |
download | Chimère-5833aa61d039bf3d1f4372e0390ffc53b7d63eb9.tar.bz2 Chimère-5833aa61d039bf3d1f4372e0390ffc53b7d63eb9.zip |
Add new table and fields to manage GPX and KML files (refs #302)
Diffstat (limited to 'chimere/scripts/upgrade.py')
-rwxr-xr-x | chimere/scripts/upgrade.py | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/chimere/scripts/upgrade.py b/chimere/scripts/upgrade.py index 286842a..accb751 100755 --- a/chimere/scripts/upgrade.py +++ b/chimere/scripts/upgrade.py @@ -258,6 +258,42 @@ CREATE TABLE "main_%s_categories" ( transaction.commit_unless_managed() print " * main_%s_categories created" % table +# -> version 1.2: associate point to route (for the future) +query = QUERY_CHECK_FIELD % ('main_marker', 'route_id') +cursor.execute(query) +transaction.commit_unless_managed() + +row = cursor.fetchone() +if not row: + query_update = 'ALTER TABLE "main_marker" ADD COLUMN \ +"route_id" integer REFERENCES "main_route" ("id") DEFERRABLE INITIALLY DEFERRED' + cursor.execute(query_update) + transaction.commit_unless_managed() + print " * route_id added to table main_marker." + +# -> version 1.3: file associated to routes +query = QUERY_CHECK_TABLE % 'main_routefile' +cursor.execute(query) +transaction.commit_unless_managed() + +row = cursor.fetchone() +if not row: + query_create = """ + CREATE TABLE "main_routefile" ( + "id" serial NOT NULL PRIMARY KEY, + "name" varchar(150) NOT NULL, + "raw_file" varchar(100) NOT NULL, + "simplified_file" varchar(100), + "file_type" varchar(1) NOT NULL + ) + ; + ALTER TABLE "main_route" ADD COLUMN + "associated_file_id" integer REFERENCES "main_routefile" ("id") + DEFERRABLE INITIALLY DEFERRED; + """ + cursor.execute(query_create) + transaction.commit_unless_managed() + print " * main_routefile created" # early versions before 0.1: save route with wrong SRID # only errors with default SRID is managed adapt the script for your SRID @@ -277,17 +313,3 @@ for route in routes: route.save() if changed: print " * projections of routes corrected" - -# -> version 1.3: associate point to route (for the future) -query = QUERY_CHECK_FIELD % ('main_marker', 'route_id') -cursor.execute(query) -transaction.commit_unless_managed() - -row = cursor.fetchone() -if not row: - query_update = 'ALTER TABLE "main_marker" ADD COLUMN \ -"route_id" integer REFERENCES "main_route" ("id") DEFERRABLE INITIALLY DEFERRED' - cursor.execute(query_update) - transaction.commit_unless_managed() - print " * route_id added to table main_marker." - |