Migrate archive table in chunks. Fixes #266 (#267)

This commit is contained in:
Manuel Riel 2019-04-22 15:41:22 +08:00 committed by GitHub
parent dc9b23f911
commit cb995334d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -348,6 +348,8 @@ def init_db(con):
ArchiveModel.time, ArchiveModel.duration, ArchiveModel.size]
data = [row for row in cursor.fetchall()]
with db.atomic():
ArchiveModel.insert_many(data, fields=fields).execute()
size = 1000
for i in range(0, len(data), size):
ArchiveModel.insert_many(data[i:i + size], fields=fields).execute()
_apply_schema_update(current_schema, 13)