Commit e0a747ab authored by Xavier Thompson's avatar Xavier Thompson

slapproxy: Fix migration of forwarded requests

When migrating entries, use `INSERT OR REPLACE` to get rid of duplicate
rows that cause constraint violations, instead of raising an exception.

Note that this only affects the `forwarded_partition_request` table:
for other tables it changes nothing in terms of behavior because the
intial tables already cannot contain conflicting rows.
parent 2762493f
......@@ -194,7 +194,7 @@ def _upgradeDatabaseIfNeeded():
for row in execute_db(table, 'SELECT * from %s', db_version=current_schema_version):
columns = ', '.join(row.keys())
placeholders = ':'+', :'.join(row.keys())
query = 'INSERT INTO %s (%s) VALUES (%s)' % ('%s', columns, placeholders)
query = 'INSERT OR REPLACE INTO %s (%s) VALUES (%s)' % ('%s', columns, placeholders)
execute_db(table, query, row)
# then drop old tables
for previous_table in previous_table_list:
......
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