Commit 19b83032 authored by Xavier Thompson's avatar Xavier Thompson

proxy: Version up and provide migration path

Fill the new partition_root field when from migrating older databases.
parent 7e549881
--version:16
--version:17
CREATE TABLE IF NOT EXISTS local_software_release_root%(version)s (
path VARCHAR(255)
);
......
......@@ -196,6 +196,16 @@ def _upgradeDatabaseIfNeeded():
placeholders = ':'+', :'.join(row.keys())
query = 'INSERT OR REPLACE INTO %s (%s) VALUES (%s)' % ('%s', columns, placeholders)
execute_db(table, query, row)
if int(current_schema_version) <= 16:
# Fill partition_root field in partition table
for row in execute_db('partition', 'SELECT * from %s'):
row['root_partition'] = getRootPartitionId(row['requested_by'])
columns = ', '.join(row.keys())
placeholders = ':'+', :'.join(row.keys())
query = 'INSERT OR REPLACE INTO %s (%s) VALUES (%s)' % ('%s', columns, placeholders)
execute_db('partition', query, row)
# then drop old tables
for previous_table in previous_table_list:
g.db.execute("DROP table %s" % previous_table)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment