wintercms / wn-builder-plugin

GUI for building plugins in Winter CMS
MIT License
34 stars 12 forks source link

Refresh the database view after migration #24

Open multiwebinc opened 2 years ago

multiwebinc commented 2 years ago

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.

bennothommo commented 2 years ago

@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 commented 2 years ago

@LukeTowers any thoughts on the above comment?

LukeTowers commented 2 years ago

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

bennothommo commented 2 years ago

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

LukeTowers commented 2 years ago

@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.

multiwebinc commented 2 years ago

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