Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: mysql migrations

mertmita27805def8a6
diff --git a/packages/nocodb/src/meta/migrations/v2/nc_097_unify_schema.ts b/packages/nocodb/src/meta/migrations/v2/nc_097_unify_schema.ts
index 28e13ba281..27b8a626b5 100644
--- a/packages/nocodb/src/meta/migrations/v2/nc_097_unify_schema.ts
+++ b/packages/nocodb/src/meta/migrations/v2/nc_097_unify_schema.ts
@@ -92,7 +92,6 @@ const up = async (knex: Knex) => {
// Drop old indexes
const tablesToDropOldBaseIdIndex = [
- { tableName: MetaTable.AUDIT, indexName: 'nc_audit_v2_base_id_index' },
{
tableName: MetaTable.PROJECT_USERS,
indexName: 'nc_base_users_v2_base_id_index',
@@ -742,7 +741,6 @@ const up = async (knex: Knex) => {
const down = async (knex: Knex) => {
// Recreate the old indexes that were dropped in `up()`.
const tablesToRecreateOldBaseIdIndex = [
- { tableName: MetaTable.AUDIT, indexName: 'nc_audit_v2_base_id_index' },
{
tableName: MetaTable.PROJECT_USERS,
indexName: 'nc_base_users_v2_base_id_index',
diff --git a/packages/nocodb/src/meta/migrations/v2/nc_098_default_workspace.ts b/packages/nocodb/src/meta/migrations/v2/nc_098_default_workspace.ts
index 319724f457..7a5bd82c89 100644
--- a/packages/nocodb/src/meta/migrations/v2/nc_098_default_workspace.ts
+++ b/packages/nocodb/src/meta/migrations/v2/nc_098_default_workspace.ts
@@ -31,11 +31,21 @@ const up = async (knex: Knex) => {
// find super user
const superUser = await knex(MetaTable.USERS)
- .whereLike('roles', '%super%')
+ .where('roles', 'like', '%super%')
.first();
+ // if no super user exists (no users created yet), skip workspace creation
+ // workspace will be created when first user is created
if (!superUser) {
- throw new Error('Super user not found');
+ const userCount = await knex(MetaTable.USERS)
+ .count('id', { as: 'count' })
+ .first();
+ if (!userCount || +userCount.count === 0) {
+ return;
+ }
+ throw new Error(
+ 'No super user found in the system, cannot create default workspace',
+ );
}
const defaultWorkspaceId = `w${nanoidWorkspace()}`;