wn-builder-plugin icon indicating copy to clipboard operation
wn-builder-plugin copied to clipboard

Refresh the database view after migration

Open multiwebinc opened this issue 3 years ago • 6 comments

When a migration is applied or rolled back in the backend, the list of tables in the Database tab is not updated in real time. A manual refresh needs to be performed to view any changes. I suggest automatically refreshing the view any time a migration is applied or rolled back.

multiwebinc avatar Feb 16 '22 15:02 multiwebinc

@multiwebinc I've taken a look at this, and I think this has highlighted a workflow flaw with the Builder plugin more than anything.

If you rollback a migration, the database is automatically updated based on the migrations and reflects the state of the database at that version. However, the database editor - when saving changes - is set to create a new version at the end of the upgrade path. For example, if I have a plugin at 1.0.5, and roll it back to 1.0.4 and then make an edit to the database tables, it will create a migration to run at 1.0.6 (ie. after the latest version), which may result in issues if were to make an edit to a table that is dropped in 1.0.5.

The main issue is that the database table list reads the database tables direct from the database, so it doesn't consider that there may be some migrations that are not yet applied.

The way I see it, we have two options - we either update the database editor to always reflect the latest version, which may mean parsing through the migrations and generating the list from that data, or alternatively, we change the database editor so that if you rollback to a previous version and make edits, it creates a new version history from that point and deletes any future migrations.

bennothommo avatar Mar 09 '22 06:03 bennothommo

@LukeTowers any thoughts on the above comment?

bennothommo avatar Mar 09 '22 06:03 bennothommo

I don't think this plugin should be actively deleting any files or code if it can help it.

LukeTowers avatar Mar 09 '22 07:03 LukeTowers

Well that's gonna make my latest branch stick out like a sore thumb... 😅

bennothommo avatar Mar 09 '22 08:03 bennothommo

@bennothommo 😂 I meant moreso that we shouldn't be deleting files automatically without even allowing the user to make the decision. Explicitly triggered deletion is fine.

LukeTowers avatar Mar 09 '22 16:03 LukeTowers

What about disabling the database tab if there are pending migrations?

multiwebinc avatar Mar 09 '22 18:03 multiwebinc