Problems after renaming database table or columns

Brian… OMG… this is a huge issue! :open_mouth:

How on earth can you evolve a design like this?

So what is the methodology if you choose to add/remove/modify a table column?

Where is the documentation about how to do this?

:astonished:

What you can do now is - delete the query, then recreate it and save your server action.

We will be improving the checks for renamed or/and deleted tables/columns so such problems will be avoided, instead you will get notified that the column/table doesn’t exist.

Anyway - the best thing you can do is to plan well your database structure before you begin adding database management actions. It’s always a bad idea to rename a table/column in a working environment.

Also it is really important that you pick your database tables and column names wisely initially.
Renaming afterwards will always give you a lot of troubles because:

  • next to the query you have maybe used the server action on many pages
  • on those pages you have populated the data under the old name in various expressions

We don’t have a magical wand to know all places and expressions you have used the column name, so we can’t just rename all the source code.

So when renaming a database table or column name - next to renaming it in the Query Builder and Database Updater, you will also have to go through all pages that use those actions and manually change all the references and expression that contain the old name to the new one.

So that is a lot of work! And very error prone!

So it is better to think twice in the beginning when you design your database and directly pick the right names!

Thanks for the update @Teodor! I will make those changes, and I am happy to hear you will be making those checks in the future.

Yes, in some kind of ideal world then the database is fully defined first… and in my case I am very lucky because I had almost completely finished my app in Bubble before moving to Wappler.

However in the real world of app design, the methodology goes:

  • Create a design
  • Try it out and learn from the user experience
  • Make changes

and so we go round and round and round that loop forever… and of course that involves database changes too.

@George, I hear what you are saying! However, I think you need to be aware that you are getting more and more users from Bubble where they have completely removed this issue in a beautiful and elegant way…

You literally just go to the database tab, add, remove or rename a field, and :champagne: magically everything changes throughout your entire design.

For me, coming from such a powerful, easy and time saving database management tool (which became “normal” for me!) to one where database changes are more difficult to make can feel like quite a step down in productivity as the design goes into the user experience phase…

So yes, all the possibilities you can add to warn of the issues or gradually remove them as Brian suggests will be an amazing upgrade to Wappler!

Best wishes,
Antony.

1 Like

It’s not unique to wappler, if you change a field name then you also have to change all references to the old one in any queries so you need to be aware of which queries use which fields in which tables. That’s not a Wappler issue, it’s a requirement for any development platform. For example if you rename a field name in a WordPress database table would you expect Wordpress to still work?

George’s initial advice is a good start.

  1. Try to ensure you get the name correct first time
  2. Use field aliases in query. That way if you have to change a field name you wont need to worry about the corresponding changes in app connect, the name can remain the same
  3. If you don’t have to change the name, don’t, use aliasing and don’t forget you can add table and field comments to a Mysql database structure, really handy for clarifying cryptic field names

Nothing beats good documentation, it may seem a waste of time initially but when you come back to something a long time after you will thank yourself for doing it

HOWEVER it would be a massive help if you could open a query with an error (with a corresponding message if possible) rather than it refusing to open

2 Likes

Hey Brian, many thanks for your perspectives and ideas!

This is all quite an adjustment from my 2 years working with Bubble…

I like for names to be consistent and to speak for themselves, so my preference is to go through some initial pain to make the changes rather than alias and comment them. It’s a personal thing!

Yes, the query opening with an error would be a massive improvement…

I think Bubble has shown that a no code environment is much more productive when names can be globally changed in one place, so I’m looking forward to that being a possibility with Wappler in the future.

Thanks for all your input and help Brian - much appreciated!

Best wishes,

Antony.

This will be possible in this weeks update, so no more not-responding query button :slight_smile:

the way bubble’s “database” and bindings work is totally different than connecting to a real, hosted, remote database server :slight_smile:

2 Likes

I suspect Bubble runs totally on aliases internally so that probably explains things

This has been fixed in the latest update. You can now edit the queries even if the tables or columns are removed in the database.

1 Like

Yippee, thank you folks! :slight_smile: