Release v2.19.0: indexed content references
This commit is contained in:
1 parent
24f1603b43
commit
b59fe08298
31 files changed
+663
-237
No files matched your search
@@ -215,4 +215,44 @@ test('template region defaults migration upgrades a 2.17.5 installation', async
|
||||
|
||||
assert.ok(pool.queries.some(([sql]) => String(sql).includes('ALTER TABLE c_template_regions ADD COLUMN default_content_json JSON NULL')));
|
||||
assert.ok(pool.queries.some(([sql]) => String(sql).includes('ALTER TABLE c_template_regions ADD COLUMN read_only TINYINT(1) NOT NULL DEFAULT 0')));
|
||||
});
|
||||
|
||||
test('2.19.0 indexed-reference migration backfills slide and template defaults', async () => {
|
||||
const queries = [];
|
||||
const insertedReferences = [];
|
||||
const pool = {
|
||||
queries,
|
||||
async query(sql, params) {
|
||||
const text = String(sql);
|
||||
queries.push([text, params]);
|
||||
if (text.includes('FROM information_schema.COLUMNS')) return [[{ column_count: 1 }]];
|
||||
if (text.includes('FROM information_schema.TABLES')) return [[{ table_count: 0 }]];
|
||||
if (text.startsWith('SELECT id, content_json FROM c_slides')) {
|
||||
return Number(params[0]) === 0
|
||||
? [[{ id: 2, content_json: JSON.stringify({ hero: { type: 'image', value: '/media/uploads/hero.png' } }) }]]
|
||||
: [[]];
|
||||
}
|
||||
if (text.startsWith('SELECT id, template_id, region_key, default_content_json FROM c_template_regions')) {
|
||||
return Number(params[0]) === 0
|
||||
? [[{ id: 7, template_id: 4, region_key: 'headline', default_content_json: { type: 'text', font_family: 'Acme Display' } }]]
|
||||
: [[]];
|
||||
}
|
||||
if (text.startsWith('INSERT IGNORE INTO c_content_references')) {
|
||||
insertedReferences.push.apply(insertedReferences, params[0]);
|
||||
}
|
||||
return [[]];
|
||||
}
|
||||
};
|
||||
|
||||
const pending = await getPendingMigrations(pool, { currentVersion: '2.18.0' });
|
||||
const migration = pending.find(item => item.version === '2.19.0');
|
||||
assert.ok(migration);
|
||||
await migration.run(pool);
|
||||
|
||||
assert.ok(queries.some(([sql]) => sql.includes('CREATE TABLE IF NOT EXISTS c_content_references')));
|
||||
assert.ok(queries.some(([sql]) => sql.includes('id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY')));
|
||||
assert.ok(queries.some(([sql]) => sql.includes('UNIQUE KEY uq_content_reference_owner')));
|
||||
assert.ok(queries.every(([sql]) => !sql.includes('idx_content_reference_owner')));
|
||||
assert.ok(insertedReferences.some(row => row[0] === 'slide' && row[1] === 2 && row[3] === 'media' && row[4] === '/media/uploads/hero.png'));
|
||||
assert.ok(insertedReferences.some(row => row[0] === 'template' && row[1] === 4 && row[2] === 'headline' && row[3] === 'font-family' && row[4] === 'acme display'));
|
||||
});
|
||||
Reference in new issue
Block a user