Database Manager: changing the name of a table breaks the database manager

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

Expected behavior

Table name should change.

Actual behavior

An error was throw about UUID on table. I don’t recall the exact error. The table only had two fields and it was referenced on one table.
image

Company table with reference to files table.
image

How to reproduce

  1. Create a table named files
  2. Create a table named company
  3. Add files reference on company table
  4. Attempt to rename Files table to File.

Well when renaming a database table there is no automatic rename of all referencing tables.

Not only relations needs to be renamed but also keys.

So it is quite a lot and generally not really recommended to do a lot of renaming afterwards because next to the database you will also have to refactor all server connect actions and data bindings using the old name.

Anyway we will see if we can improve at least the database manager part.

So I’m now at a point again where I’m unable to continue using Wappler. Something as simple as trying to change a database name should not make Wappler unusable.

How do I fix the issue without starting from scratch?

You can do renames of tables just fine, but you just have to go and select the new table name also in all reference fields from other tables that reference it. As I said it is not done automatically.

The change of the name failed. I don’t care about all of the references at the moment.

Could you be more specific on that? What error did you got? We have to know the exact error in order to investigate further.

I’ll have to try to replicate the issue since there’s no log of errors?

Maybe this is another area for Wappler to improve?

yes or if those changes are still pending, just try to apply them again and inspect the generated file next to also reporting the exact error.

When I try to apply the changes it says there’s nothing to do.

Maybe try to refresh the database schema, select the tables node and choose refresh schema from the context menu.

Please see my DM.

To discard all pending changes you need to refresh the schema for the tables from the context menu.

image

@George I had a similar issue yesterday when I tried to delete a table that was referenced somewhere else. So that failed and afterwards refreshing the schema etc did not get rid of the pending changes. I tried to restart Wappler as well. So the db.json did not get updated. I had to git reset, clear the last migrations inside the db and adjust the db.json.

I had a similar issue (but more because of a mistake on my side, I edit my database data with external tools) and messed up with the structure. At the same time, I had some changes pending in Wappler, and couldn’t apply them, but after a couple of “refreshing the schema” the pending changes went awauy.

But, to be honest, one of the biggest rooms for improvements I see in Refactoring Support, especially in an environment like Wappler where the IDE has almost complete control on the code generation (and the ability to track references)

As @george has specified, you have to use the refresh on the table element. Attempting to use the “refresh schema” at the “db” element or using the refresh button at the top right of the database manager does not refresh the tables.

This is very confusing, but it solved my issue.

1 Like

That did not work for me but glad it did for you.

Will improve the refresh from the toolbar to be also for the selected connection and force you to select one if you haven’t

2 Likes

Fixed in Wappler 5.4