diff --git a/packages/e2e-test/src/commands/run.ts b/packages/e2e-test/src/commands/run.ts index b57e426116..20b2753f6b 100644 --- a/packages/e2e-test/src/commands/run.ts +++ b/packages/e2e-test/src/commands/run.ts @@ -69,7 +69,10 @@ export async function run() { print('Starting the app'); await testAppServe(pluginId, appDir); - if (Boolean(process.env.POSTGRES_USER) || Boolean(process.env.MYSQL_USER)) { + if ( + Boolean(process.env.POSTGRES_USER) || + Boolean(process.env.MYSQL_CONNECTION) + ) { print('Testing the database backend startup'); await preCleanDatabase(); const appConfig = path.resolve(appDir, 'app-config.yaml'); diff --git a/plugins/app-backend/migrations/20211229105307_init.js b/plugins/app-backend/migrations/20211229105307_init.js index 9a05f97198..25ed48c307 100644 --- a/plugins/app-backend/migrations/20211229105307_init.js +++ b/plugins/app-backend/migrations/20211229105307_init.js @@ -21,7 +21,7 @@ */ exports.up = async function up(knex) { const isMySQL = knex.client.config.client.includes('mysql'); - return knex.schema.createTable('static_assets_cache', table => { + await knex.schema.createTable('static_assets_cache', table => { table.comment( 'A cache of static assets that where previously deployed and may still be lazy-loaded by clients', ); @@ -32,7 +32,6 @@ exports.up = async function up(knex) { .notNullable() .comment('The path of the file'); } else { - // cannot have a unique key in mysql with a text column greater than 733 bytes table.text('path').notNullable().comment('The path of the file'); } table @@ -45,6 +44,12 @@ exports.up = async function up(knex) { table.binary('content').notNullable().comment('The asset content'); table.index('last_modified_at', 'static_asset_cache_last_modified_at_idx'); }); + // specifically for mysql specify a unique index up to 254 characters(mysql limit) + if (isMySQL) { + await knex.schema.raw( + 'create unique index static_assets_cache_path_idx on static_assets_cache(path(254));', + ); + } }; /**