Fix v2.19.1 migration schema connection ownership
This commit is contained in:
1 parent
9ca372429b
commit
0044cbc1fc
2 files changed
+41
-16
No files matched your search
+8
-11
@@ -830,14 +830,13 @@ const VERSIONED_MIGRATIONS = [
|
||||
version: '2.19.1',
|
||||
label: 'v2.19.1 rebuild managed font references',
|
||||
run: async function (pool) {
|
||||
const connection = await pool.getConnection();
|
||||
try {
|
||||
await connection.beginTransaction();
|
||||
await connection.query('DELETE FROM c_content_references WHERE reference_type = ?', ['font-family']);
|
||||
await pool.beginTransaction();
|
||||
await pool.query('DELETE FROM c_content_references WHERE reference_type = ?', ['font-family']);
|
||||
|
||||
let lastSlideId = 0;
|
||||
while (true) {
|
||||
const [slides] = await connection.query(
|
||||
const [slides] = await pool.query(
|
||||
'SELECT id, content_json FROM c_slides WHERE id > ? AND content_json IS NOT NULL ORDER BY id ASC LIMIT 500',
|
||||
[lastSlideId]
|
||||
);
|
||||
@@ -847,13 +846,13 @@ const VERSIONED_MIGRATIONS = [
|
||||
references.push.apply(references, collectContentReferences('slide', slide.id, parseJsonSafe(slide.content_json) || {})
|
||||
.filter(function (reference) { return reference.reference_type === 'font-family'; }));
|
||||
});
|
||||
await insertContentReferences(connection, references);
|
||||
await insertContentReferences(pool, references);
|
||||
lastSlideId = Number(slides[slides.length - 1].id);
|
||||
}
|
||||
|
||||
let lastRegionId = 0;
|
||||
while (true) {
|
||||
const [regions] = await connection.query(
|
||||
const [regions] = await pool.query(
|
||||
'SELECT id, template_id, region_key, default_content_json FROM c_template_regions WHERE id > ? AND default_content_json IS NOT NULL ORDER BY id ASC LIMIT 500',
|
||||
[lastRegionId]
|
||||
);
|
||||
@@ -865,16 +864,14 @@ const VERSIONED_MIGRATIONS = [
|
||||
references.push.apply(references, collectContentReferences('template', region.template_id, regionContent)
|
||||
.filter(function (reference) { return reference.reference_type === 'font-family'; }));
|
||||
});
|
||||
await insertContentReferences(connection, references);
|
||||
await insertContentReferences(pool, references);
|
||||
lastRegionId = Number(regions[regions.length - 1].id);
|
||||
}
|
||||
|
||||
await connection.commit();
|
||||
await pool.commit();
|
||||
} catch (error) {
|
||||
await connection.rollback();
|
||||
await pool.rollback();
|
||||
throw error;
|
||||
} finally {
|
||||
connection.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user