doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 8 forks source link

Upgrade from SmartMap creating fields database issue #27

Closed damienbuckley closed 3 years ago

damienbuckley commented 3 years ago

When upgrading from SmartMap to GoogleMaps I'm getting the situation whereby if I then got to Settings > Fields I get this error:-

Argument 1 passed to craft\services\Fields::getGroupById() must be of the type int, null given, called in /Users/…/vendor/craftcms/cms/src/base/Field.php on line 565

I found a similar issue here - https://github.com/craftcms/cms/issues/5530#issuecomment-679314477

I traced back in the db fields row to smart map:- 85 NULL Map Pin mapPin global 0 none NULL doublesecretagency\googlemaps\fields\AddressField {"coordinatesMode":"readOnly","mapOnSearch":"open","mapOnStart":"close","showMap":null,"subfieldConfig":{"street1":{"label":"Street Address","width":100,"enabled":1,"position":1},"street2":{"label":"Apartment or Suite","width":100,"enabled":1,"position":2},"city":{"label":"City","width":50,"enabled":1,"position":3},"state":{"label":"State","width":15,"enabled":1,"position":4},"zip":{"label":"Zip Code","width":35,"enabled":1,"position":5},"country":{"label":"Country","width":100,"enabled":1,"position":6}},"visibilityToggle":"both"} 2019-06-28 03:57:42 2021-04-29 05:23:41 44694f84-ca5c-4e2b-872e-0ae9e2acf089

If I delete this row everything returns to normal but what's the issue here? I have 5 more sites using smartMap I need to update…

Also, assuming that GoogleMaps is migrating data from SmartMap - what is the recommended update and deployment process? If I deploy and upgraded site's project config won't it uninstall SmartMaps before the GoogleMap upgrade?

lindseydiloreto commented 3 years ago

If I deploy and upgraded site's project config won't it uninstall SmartMaps before the GoogleMap upgrade?

Nope, that bug was fixed just before Craft 3.6 launched. Which is part of why the Google Maps plugin requires 3.6. 🙂

When updating from Smart Map to Google Maps, this is all you should need to do:

  1. Install Google Maps. When the installation is done, it will automatically uninstall Smart Map for you.

That said, you may want to leave the composer package for doublesecretagency/craft-smartmap in place until you are confident that everything is working normally across all environments. There are fallback measures in place in case that package is removed too early, but it's probably ideal to let it linger until the transfer is 100% complete in all environments.

It's difficult to say what may have caused your Fields::getGroupById error. Could have been a migration error, or even something more abstract. Feel free to DM me on Discord, and we can try to sort it out together! 👍

damienbuckley commented 3 years ago

Just following up from where we were with this - I got everything deployed and working with one exception - after removing Smart Map on local the Fields issue went away. Once I deployed the project config changes to staging I had the same problem. This may have been my fault however as I forgot to run composer install before removing Smart Map but still I wouldn't have thought that would make much of a difference?

CharlieGentle commented 3 years ago

I had the same error happen when migrating from SmartMap to GoogleMaps. Found in the database that 2 fields had their context changed from a matrix block to global. I copied the correct context from a backup and everything worked fine. Hope that helps someone.

lindseydiloreto commented 3 years ago

Thanks for reporting. I'm currently working on some notable changes to the migration process, which will (hopefully) fix it once and for all. Brandon has steered me towards a better way of handling the field migrations, fingers crossed it squashes this issue for good. 🤞

I'm hoping to have the next release (v4.0.9) out by the end of the week.

lindseydiloreto commented 3 years ago

Just released v4.0.9 which directly fixes this bug, along with several other migration-related issues. At this point, I'm 99% confident that we've solved all possible migration issues, should be smooth sailing for anyone moving forward.

For the record, the bug fix only applies to new migrations, it won't do anything for migrations which have already been run.