wintercms / wn-builder-plugin

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

failed database version upgrade #53

Open SledgehammerPL opened 1 year ago

SledgehammerPL commented 1 year ago

Winter CMS Build

1.2

PHP Version

8.1

Database engine

PostgreSQL

Plugins installed

Builder

Issue description

I changed the column (e.g. drop) AND change name of table and tried to apply this upgrade to other system.

But i have some view which forbid to apply patch - but the name of table was changed. This shouldn't work like this. All or nothing. If it break - it should be still old name of table.

Steps to replicate

Changed the column (e.g. drop) AND change name of table and tried to apply this upgrade to other system.

Workaround

I have to change manually name of table and apply patch again

LukeTowers commented 1 year ago

I have absolutely no idea what you're talking about or what the issue is here that you're trying to report.

SledgehammerPL commented 1 year ago

I forgot that Builder isn't part of winter - This is a problem of builder not winter itself

  1. table has name my_table_old_name and has three columns: id, bad_column, good_column
  2. In postgresql there is a view which depends on bad_column
  3. there's a new version of plugin - which changes name my_table_old_name to my_table_new_name and drops bad_column
  4. During the upgrade process sql error appears - upgrade failed because can't drop bad_column (because it is used in view).
  5. Column is not dropped BUT name is changed to my_table_new_name
  6. manualy edit view to resolve problem
  7. Can't upgrade because upgrade can't rename my_table_old_name to my_table_new_name...
  8. manualy reverse renaming - my_table_new_name to my_table_new_name
  9. execute upgrade - SUCCESS!!