Reference fields not being deleted properly in the Database Manager

Wappler Version : 4.8.3
Operating System : MacOS Monterey - M1
Server Model: NodeJS
Database Type: Postgres
Hosting Type: Own Server

Expected behavior

What do you think should happen?

When deleting a reference field in a table, the field should no longer be present afterwards.

Actual behavior

What actually happens?

The field switches to an integer (or whatever the type of the reference field is) but is not removed from the table. Because the column isn’t actually dropped, undoing the migration doesn’t work either because there is a mismatch.

I checked the migration file, and it looks like an issue with the async functions (the knex migration functions were switched to async with the 4.8.3 update?). This is what is generated in the knex file:

// This doesn't work properly   
exports.up = function (knex) {
        return knex.schema
            .table('app_user_status_assignment', async function (table) {
                await table.dropForeign('user_status_id');
                table.dropColumn('user_status_id');
            })
    };

It looks like the table.dropForeign('user_status_id'); action is run, but the table.dropColumn('user_status_id'); action does not run.

However, if I remove the await before the table.dropForeign('user_status_id');, the field is removed properly.

// This works
exports.up = function (knex) {
    return knex.schema
        .table('app_user_status_assignment', async function (table) {
            table.dropForeign('user_status_id');
            table.dropColumn('user_status_id');
        })
};

Yes we found that out indeed with another bug.

Thanks for the report - will be solved in the next update

This has been fixed in Wappler 4.9.0

This topic was automatically closed after 2 days. New replies are no longer allowed.