app-backend: added migration test + fix namespace migration

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-04-13 13:14:30 +02:00
parent 16ef9e59e5
commit 16b2f7a3eb
3 changed files with 148 additions and 3 deletions
@@ -23,7 +23,8 @@ exports.up = async function up(knex) {
await knex.schema.alterTable('static_assets_cache', table => {
// The namespace is used to allow operations on asset groups, e.g. delete all assets in a namespace
table.string('namespace').comment('The namespace of the file');
table.index('namespace', 'static_asset_cache_namespace_idx');
table.dropPrimary();
table.primary(['namespace', 'path']);
});
};
@@ -31,8 +32,11 @@ exports.up = async function up(knex) {
* @param {import('knex').Knex} knex
*/
exports.down = async function down(knex) {
await knex.delete().from('static_assets_cache').whereNotNull('namespace');
await knex.schema.alterTable('static_assets_cache', table => {
table.dropIndex([], 'static_asset_cache_namespace_idx');
table.dropPrimary();
table.dropColumn('namespace');
table.primary(['path']);
});
};