diff --git a/plugins/app-backend/migrations/20240113144027_assets-namespace.js b/plugins/app-backend/migrations/20240113144027_assets-namespace.js index c39407d08b..de6ca2e333 100644 --- a/plugins/app-backend/migrations/20240113144027_assets-namespace.js +++ b/plugins/app-backend/migrations/20240113144027_assets-namespace.js @@ -22,7 +22,10 @@ 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 + .string('namespace') + .defaultTo('default') + .comment('The namespace of the file'); table.dropPrimary(); table.primary(['namespace', 'path']); }); @@ -32,7 +35,10 @@ 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 + .delete() + .from('static_assets_cache') + .whereNot('namespace', 'default'); await knex.schema.alterTable('static_assets_cache', table => { table.dropPrimary(); diff --git a/plugins/app-backend/src/lib/assets/StaticAssetsStore.ts b/plugins/app-backend/src/lib/assets/StaticAssetsStore.ts index 27573300e7..038d5bd9bf 100644 --- a/plugins/app-backend/src/lib/assets/StaticAssetsStore.ts +++ b/plugins/app-backend/src/lib/assets/StaticAssetsStore.ts @@ -50,7 +50,7 @@ export interface StaticAssetsStoreOptions { export class StaticAssetsStore implements StaticAssetProvider { #db: Knex; #logger: Logger; - #namespace: string | null; + #namespace: string; static async create(options: StaticAssetsStoreOptions) { const { database } = options; @@ -68,7 +68,7 @@ export class StaticAssetsStore implements StaticAssetProvider { private constructor(client: Knex, logger: Logger, namespace?: string) { this.#db = client; this.#logger = logger; - this.#namespace = namespace ?? null; + this.#namespace = namespace ?? 'default'; } /**