From bfa604de333f3f93eb1483cea2c33886b8b6f473 Mon Sep 17 00:00:00 2001 From: "lpete@vmware.com" Date: Thu, 17 Aug 2023 17:38:24 -0400 Subject: [PATCH] remove pk for mysql db Signed-off-by: lpete@vmware.com --- .../migrations/20211229105307_init.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/app-backend/migrations/20211229105307_init.js b/plugins/app-backend/migrations/20211229105307_init.js index 5367d5af60..9a05f97198 100644 --- a/plugins/app-backend/migrations/20211229105307_init.js +++ b/plugins/app-backend/migrations/20211229105307_init.js @@ -20,15 +20,21 @@ * @param {import('knex').Knex} knex */ exports.up = async function up(knex) { + const isMySQL = knex.client.config.client.includes('mysql'); return 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', ); - table - .text('path', 'text') - .unique() - .notNullable() - .comment('The path of the file'); + if (!isMySQL) { + table + .text('path') + .primary() + .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 .dateTime('last_modified_at') .defaultTo(knex.fn.now())