Database Changes no longer appearing in Changes section

Wappler Version: 5.3.2
Operating System: Windows 11
Server Model: node.js
Database Type: postgres
Hosting Type: local docker

Expected behavior

Changes should appear in Changes section of Database Manager

Actual behavior

Changes do not show in Changes section and are not available in Windows migration directory.

How to reproduce

See video

I turned on logging and see this error.

TypeError: Cannot read properties of undefined (reading 'name') at 
file:///C:/Users/Keith/AppData/Local/Wappler/resources/app/Shared/DMXzone/dmxAppCreator/UI/databaseManager.js:8:148205 
at Array.forEach (<anonymous>) 
at h (file:///C:/Users/Keith/AppData/Local/Wappler/resources/app/Shared/DMXzone/dmxAppCreator/UI/databaseManager.js:8:148170) 
at file:///C:/Users/Keith/AppData/Local/Wappler/resources/app/Shared/DMXzone/dmxAppCreator/UI/databaseManager.js:8:148607 
at Array.forEach (<anonymous>) 
at y (file:///C:/Users/Keith/AppData/Local/Wappler/resources/app/Shared/DMXzone/dmxAppCreator/UI/databaseManager.js:8:148291) 
at file:///C:/Users/Keith/AppData/Local/Wappler/resources/app/Shared/DMXzone/dmxAppCreator/UI/databaseManager.js:8:146597 
at Array.forEach (<anonymous>) 
at r.saveDatabaseChangesFromTree (file:///C:/Users/Keith/AppData/Local/Wappler/resources/app/Shared/DMXzone/dmxAppCreator/UI/databaseManager.js:8:146550) 
at Object.callBack (file:///C:/Users/Keith/AppData/Local/Wappler/resources/app/Shared/DMXzone/dmxAppCreator/UI/databaseManager.js:8:139452) 
at HTMLButtonElement.<anonymous> (file:///C:/Users/Keith/AppData/Local/Wappler/resources/app/Shared/DMXzone/dmxAppCreator/UI/w2ui/w2ui.min.js:7:282087) 
at HTMLButtonElement.dispatch (C:\Users\Keith\AppData\Local\Wappler\resources\app\node_modules\jquery\dist\jquery.js:5430:27) 
at HTMLButtonElement.elemData.handle (C:\Users\Keith\AppData\Local\Wappler\resources\app\node_modules\jquery\dist\jquery.js:5234:28) 
at HTMLButtonElement.sentryWrapped (C:\Users\Keith\AppData\Local\Wappler\resources\app\node_modules\@sentry\browser\dist\helpers.js:75:23)

I don’t see the changes disappearing in your video?

If chances are not shown and an error occur, you should see the error instead of the changes.

Maybe add a screenshot about that.

Where are the migration file(s) for each change I made? I literally showed changes made in the video that do not have a migration file.

Well you see them in the database manager under changes and as files they are available under your project folder then .wappler/migrations/db_connection_name - like you have shown them in your video.

Do note that the .Wappler folder is hidden in Wappler File Manager

Minute 0:33, the change he made wasn’t generated, 8 pending changes icon in the UI after clicking “Ok”

@George, please don’t mistake me for an idiot. I’ve been an enterprise software consultant for 20 years and spend plenty of time troubleshooting. I’m happy to get on a Zoom or some other screenshare if my video is not clear enough for you.

The files you see in the video were all of the previous changes/migration before the issue started to occur. I even type out a description of each change. Do you see that same text in any of the Changes or migration files?

If you watch the video closely you will see that every change I make in the video does not result in a new migration file, but it does create an entry in git and modifies the db.json file. I even provided a potential error at the end of the original post.

I’m just trying to understand the exact problem. I was under the impression that all changes (migration files) files were gone.

So you mean that one change that you saved wasn’t generated in to a file? So you tried again and you got two change files with the same name?

This is a brand new project since the consensus was I could not continue with the previous project since I removed all of the migration files.

Two separate, but most likely related, bugs. Correct, the change(s) appear to work, but do not generate a file.

  1. The first issue in creating a brand new project and tables happened in Database Manager bugs. this is where after adding a multi-reference field, Wappler database manager corrupted something. I’m guessing it has something to do with how it creates a separate table via the multi-reference field. I didn’t notice an issue until I went to create the next field, which was the isActive field on user table. This threw an error about roleid related to the previous change. So I tried one more time resulting in two change files with the same name.

I ended up removing one of the change files and modifying the second change migration file to only contain the isActive field addition and then I was able to apply the change successfully.

Here’s the code that should only include the isActive field, but somehow has duplicated the changes from the previous change I performed.

My guess to the cause? Either something in the code that generates the multi-reference table or one of the schema refreshes I attempted caused this issue.

Here’s the original code that should only contain the isActive field addition to the user table.

exports.up = function(knex) {
  return knex.schema
    .createTable('Roleusers', async function (table) {
      table.uuid('RoleId');
      table.foreign('RoleId').references('id').inTable('role').onUpdate('CASCADE').onDelete('CASCADE');
      table.uuid('UserId');
      table.foreign('UserId').references('id').inTable('user').onUpdate('CASCADE').onDelete('CASCADE');
    })
    .table('user', async function (table) {
      table.boolean('isActive');
    })
};

exports.down = function(knex) {
  return knex.schema
    .table('user', async function (table) {
      table.dropColumn('isActive');
    })
    .dropTable('Roleusers')
    .dropTable('Rolepermissions')
};

Here’s the modified code:

exports.up = function (knex) {
  return knex.schema
    .table('user', async function (table) {
      table.boolean('isActive');
    })
};

exports.down = function (knex) {
  return knex.schema
    .table('user', async function (table) {
      table.dropColumn('isActive');
    })
};

If you’re thinking “well he must have lumped those two changes together”. The answer is no, because here is the migration file that I created directly before attempting to add the isActive to the user table. You can see that it has two createTable actions for the Rolepermissions and Roleusers tables. So why, are they appearing again in the next migration file?

exports.up = function(knex) {
  return knex.schema
    .table('role', async function (table) {
      table.string('name');
      table.uuid('createdBy');
      table.foreign('createdBy').references('id').inTable('user').onUpdate('CASCADE').onDelete('CASCADE');
      table.uuid('updatedBy');
      table.foreign('updatedBy').references('id').inTable('user').onUpdate('CASCADE').onDelete('CASCADE');
      table.datetime('createdDate').defaultTo(knex.fn.now());
      table.datetime('updatedDate').defaultTo(knex.fn.now());
      table.string('shortDescription');
      table.text('description');
      table.boolean('isActive');
    })
    .createTable('Rolepermissions', async function (table) {
      table.uuid('RoleId');
      table.foreign('RoleId').references('id').inTable('role').onUpdate('CASCADE').onDelete('CASCADE');
      table.uuid('PermissionId');
      table.foreign('PermissionId').references('id').inTable('permission').onUpdate('CASCADE').onDelete('CASCADE');
    })
    .createTable('Roleusers', async function (table) {
      table.uuid('RoleId');
      table.foreign('RoleId').references('id').inTable('role').onUpdate('CASCADE').onDelete('CASCADE');
      table.uuid('UserId');
      table.foreign('UserId').references('id').inTable('user').onUpdate('CASCADE').onDelete('CASCADE');
    })
};

exports.down = function(knex) {
  return knex.schema
    .dropTable('Roleusers')
    .dropTable('Rolepermissions')
    .table('role', async function (table) {
      table.dropColumn('name');
      table.dropForeign('createdBy');
      table.dropColumn('createdBy');
      table.dropForeign('updatedBy');
      table.dropColumn('updatedBy');
      table.dropColumn('createdDate');
      table.dropColumn('updatedDate');
      table.dropColumn('shortDescription');
      table.dropColumn('description');
      table.dropColumn('isActive');
    })
};
  1. So, I’m past the previous error. But now, when I try to make any new changes no migration files are created, but the changes do get applied in the db.json file. I’m guessing the error Cannot read properties of undefined (reading 'name') has something to do with it.

after a lot of investigation, we finally found the problem.

it was a complex mixture of using the Pascal Case naming database conversion and recognition of sub tables and multi references due to it.

So it will be all fixed in the next update.

Thank you for the detailed reports!

1 Like

Fixed in Wappler 5.3.3

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