ethercreative / simplemap

A beautifully simple map field type for Craft CMS.
Other
136 stars 48 forks source link

Craft 2 > 3 Migration Error Integrity constraint violation #153

Closed davist11 closed 5 years ago

davist11 commented 5 years ago

Description

I'm getting an error upgrading from a Craft 2 site

Integrity constraint violation: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3-1-1' for key 'craft_simplemaps_ownerId_ownerSiteId_fieldId_unq_idx'
The SQL being executed was: INSERT INTO craft_simplemaps (id, ownerId, ownerSiteId, fieldId, lat, lng, zoom, address, parts, dateCreated, uid, dateUpdated) VALUES (4343, 3, 1, 1, '44.13688460', '-73.86267190', 7, 'Gothics Trek, Keene Valley, NY 12943, USA', '{\"administrative_area_level_1\":\"New York\",\"administrative_area_level_2\":\"Essex County\",\"administrative_area_level_3\":\"Keene\",\"administrative_area_level_4\":null,\"administrative_area_level_5\":null,\"airport\":null,\"bus_station\":null,\"colloquial_area\":null,\"establishment\":null,\"floor\":null,\"intersection\":null,\"locality\":\"Keene Valley\",\"natural_feature\":null,\"neighborhood\":null,\"park\":null,\"parking\":null,\"point_of_interest\":null,\"political\":null,\"post_box\":null,\"postal_code\":\"12943\",\"postal_code_prefix\":null,\"postal_town\":null,\"premise\":null,\"room\":null,\"route\":\"Gothics Trek\",\"street_address\":null,\"street_number\":null,\"sublocality\":null,\"sublocality_level_1\":null,\"sublocality_level_2\":null,\"sublocality_level_3\":null,\"sublocality_level_4\":null,\"sublocality_level_5\":null,\"subpremise\":null,\"train_station\":null,\"transit_station\":null,\"administrative_area_level_1_short\":\"NY\",\"administrative_area_level_2_short\":\"Essex County\",\"administrative_area_level_3_short\":\"Keene\",\"administrative_area_level_4_short\":null,\"administrative_area_level_5_short\":null,\"airport_short\":null,\"bus_station_short\":null,\"colloquial_area_short\":null,\"establishment_short\":null,\"floor_short\":null,\"intersection_short\":null,\"locality_short\":\"Keene Valley\",\"natural_feature_short\":null,\"neighborhood_short\":null,\"park_short\":null,\"parking_short\":null,\"point_of_interest_short\":null,\"political_short\":null,\"post_box_short\":null,\"postal_code_short\":\"12943\",\"postal_code_prefix_short\":null,\"postal_town_short\":null,\"premise_short\":null,\"room_short\":null,\"route_short\":\"Gothics Trek\",\"street_address_short\":null,\"street_number_short\":null,\"sublocality_short\":null,\"sublocality_level_1_short\":null,\"sublocality_level_2_short\":null,\"sublocality_level_3_short\":null,\"sublocality_level_4_short\":null,\"sublocality_level_5_short\":null,\"subpremise_short\":null,\"train_station_short\":null,\"transit_station_short\":null,\"number\":\"\",\"address\":\"Gothics Trek\",\"city\":\"Keene Valley\",\"postcode\":\"12943\",\"county\":\"Essex County\",\"state\":\"New York\",\"country\":\"United States\",\"country_short\":\"US\"}', '2019-04-05 16:53:48', '64b7c9e9-2b4c-4990-8973-48f38f41faca', '2019-04-05 16:53:48')

Migration: ether\simplemap\migrations\m190226_143809_craft3_upgrade

Output:

> delete from {{%plugins}} ... done (time: 0.003s)
> Start map data upgrade
> Upgrade map value Gothics Trek, Keene Valley, NY 12943, USA
Exception: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3-1-1' for key 'craft_simplemaps_ownerId_ownerSiteId_fieldId_unq_idx'
The SQL being executed was: INSERT INTO craft_simplemaps (id, ownerId, ownerSiteId, fieldId, lat, lng, zoom, address, parts, dateCreated, uid, dateUpdated) VALUES (4343, 3, 1, 1, '44.13688460', '-73.86267190', 7, 'Gothics Trek, Keene Valley, NY 12943, USA', '{\"administrative_area_level_1\":\"New York\",\"administrative_area_level_2\":\"Essex County\",\"administrative_area_level_3\":\"Keene\",\"administrative_area_level_4\":null,\"administrative_area_level_5\":null,\"airport\":null,\"bus_station\":null,\"colloquial_area\":null,\"establishment\":null,\"floor\":null,\"intersection\":null,\"locality\":\"Keene Valley\",\"natural_feature\":null,\"neighborhood\":null,\"park\":null,\"parking\":null,\"point_of_interest\":null,\"political\":null,\"post_box\":null,\"postal_code\":\"12943\",\"postal_code_prefix\":null,\"postal_town\":null,\"premise\":null,\"room\":null,\"route\":\"Gothics Trek\",\"street_address\":null,\"street_number\":null,\"sublocality\":null,\"sublocality_level_1\":null,\"sublocality_level_2\":null,\"sublocality_level_3\":null,\"sublocality_level_4\":null,\"sublocality_level_5\":null,\"subpremise\":null,\"train_station\":null,\"transit_station\":null,\"administrative_area_level_1_short\":\"NY\",\"administrative_area_level_2_short\":\"Essex County\",\"administrative_area_level_3_short\":\"Keene\",\"administrative_area_level_4_short\":null,\"administrative_area_level_5_short\":null,\"airport_short\":null,\"bus_station_short\":null,\"colloquial_area_short\":null,\"establishment_short\":null,\"floor_short\":null,\"intersection_short\":null,\"locality_short\":\"Keene Valley\",\"natural_feature_short\":null,\"neighborhood_short\":null,\"park_short\":null,\"parking_short\":null,\"point_of_interest_short\":null,\"political_short\":null,\"post_box_short\":null,\"postal_code_short\":\"12943\",\"postal_code_prefix_short\":null,\"postal_town_short\":null,\"premise_short\":null,\"room_short\":null,\"route_short\":\"Gothics Trek\",\"street_address_short\":null,\"street_number_short\":null,\"sublocality_short\":null,\"sublocality_level_1_short\":null,\"sublocality_level_2_short\":null,\"sublocality_level_3_short\":null,\"sublocality_level_4_short\":null,\"sublocality_level_5_short\":null,\"subpremise_short\":null,\"train_station_short\":null,\"transit_station_short\":null,\"number\":\"\",\"address\":\"Gothics Trek\",\"city\":\"Keene Valley\",\"postcode\":\"12943\",\"county\":\"Essex County\",\"state\":\"New York\",\"country\":\"United States\",\"country_short\":\"US\"}', '2019-04-05 16:53:48', '64b7c9e9-2b4c-4990-8973-48f38f41faca', '2019-04-05 16:53:48') (/Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/Schema.php:664)
#0 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/Command.php(1295): yii\db\Schema->convertException(Object(PDOException), 'INSERT INTO cr...')
#1 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/Command.php(1091): yii\db\Command->internalExecute('INSERT INTO cr...')
#2 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/Schema.php(433): yii\db\Command->execute()
#3 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/ActiveRecord.php(600): yii\db\Schema->insert('{{%simplemaps}}', Array)
#4 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/ActiveRecord.php(566): yii\db\ActiveRecord->insertInternal(NULL)
#5 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/BaseActiveRecord.php(678): yii\db\ActiveRecord->insert(false, NULL)
#6 /Users/tdavis/sites/osi/vendor/ether/simplemap/src/services/MapService.php(148): yii\db\BaseActiveRecord->save(false)
#7 /Users/tdavis/sites/osi/vendor/ether/simplemap/src/elements/Map.php(173): ether\simplemap\services\MapService->saveRecord(Object(ether\simplemap\elements\Map), '3', '1', '1', true)
#8 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/services/Elements.php(515): ether\simplemap\elements\Map->afterSave(true)
#9 /Users/tdavis/sites/osi/vendor/ether/simplemap/src/migrations/m190226_143809_craft3_upgrade.php(103): craft\services\Elements->saveElement(Object(ether\simplemap\elements\Map), false)
#10 /Users/tdavis/sites/osi/vendor/ether/simplemap/src/migrations/m190226_143809_craft3_upgrade.php(48): ether\simplemap\migrations\m190226_143809_craft3_upgrade->_upgrade2()
#11 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/db/Migration.php(56): ether\simplemap\migrations\m190226_143809_craft3_upgrade->safeUp()
#12 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)
#13 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/db/MigrationManager.php(163): craft\db\MigrationManager->migrateUp(Object(ether\simplemap\migrations\m190226_143809_craft3_upgrade))
#14 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/services/Updates.php(225): craft\db\MigrationManager->up()
#15 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(521): craft\services\Updates->runMigrations(Array)
#16 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/controllers/UpdaterController.php(209): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#17 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#18 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#19 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#20 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('migrate', Array)
#21 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('migrate', Array)
#22 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('updater/migrate', Array)
#23 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/web/Application.php(683): craft\web\Application->runAction('updater/migrate')
#24 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/web/Application.php(223): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#25 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#26 /Users/tdavis/sites/osi/public/index.php(21): yii\base\Application->run()
#27 {main}

Additional info

davist11 commented 5 years ago

Thanks for the speedy update, but I'm still getting the same error after updating to 3.4.11

davist11 commented 5 years ago

Just wanted to flag :point_up: to make sure it was still noted (since the issue is closed)

Tam commented 5 years ago

Sounds like you've got multiple records in your craft_simplemap_maps table for field ID 1, site ID 1, element ID 3. Could you check to see if this is the case?

davist11 commented 5 years ago

I only see one record with ownerId = 3

image

Tam commented 5 years ago

Can you send me a database dump? You can email it to dev@ethercreative.co.uk.

davist11 commented 5 years ago

Sent, thanks!

Tam commented 5 years ago

What's your upgrade process, because I was able to upgrade successfully by running the craft upgrade first then installing Maps?

davist11 commented 5 years ago

With that DB backup

  1. Run ./craft migrate/all
  2. Login to the CP
  3. Install non-installed plugins (Maps is one of them)
  4. See error that Maps couldn't be installed
Tam commented 5 years ago

Could you try running the following:

  1. ./craft migrate/all
  2. composer require ether/simplemap
  3. ./craft install/plugin simplemap
davist11 commented 5 years ago
~/sites/osi (craft3): ./craft migrate/all
Yii Migration Tool (based on Yii v2.0.17)

Migrated up successfully.
~/sites/osi (craft3): composer require ether/simplemap
Using version ^3.4 for ether/simplemap
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating optimized autoload files
~/sites/osi (craft3): ./craft install/plugin simplemap
*** installing simplemap
    > create table {{%simplemaps}} ...Exception: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'craft_simplemaps' already exists
The SQL being executed was: CREATE TABLE `craft_simplemaps` (
    `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `ownerId` int(11) NOT NULL,
    `ownerSiteId` int(11),
    `fieldId` int(11) NOT NULL,
    `lat` decimal(11,9),
    `lng` decimal(12,9),
    `zoom` int(2),
    `address` varchar(255),
    `parts` text,
    `dateCreated` datetime(0) NOT NULL,
    `dateUpdated` datetime(0) NOT NULL,
    `uid` char(36) NOT NULL DEFAULT '0'
) ENGINE=InnoDb DEFAULT CHARSET=utf8 (/Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/Schema.php:664)
#0 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/Command.php(1295): yii\db\Schema->convertException(Object(PDOException), 'CREATE TABLE `c...')
#1 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/Command.php(1091): yii\db\Command->internalExecute('CREATE TABLE `c...')
#2 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/db/Migration.php(323): yii\db\Command->execute()
#3 /Users/tdavis/sites/osi/vendor/ether/simplemap/src/migrations/Install.php(44): yii\db\Migration->createTable('{{%simplemaps}}', Array)
#4 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/db/Migration.php(56): ether\simplemap\migrations\Install->safeUp()
#5 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)
#6 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/base/Plugin.php(152): craft\db\MigrationManager->migrateUp(Object(ether\simplemap\migrations\Install))
#7 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/services/Plugins.php(520): craft\base\Plugin->install()
#8 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/console/controllers/InstallController.php(191): craft\services\Plugins->installPlugin('simplemap')
#9 [internal function]: craft\console\controllers\InstallController->actionPlugin('simplemap')
#10 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#12 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('plugin', Array)
#13 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('plugin', Array)
#14 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('install/plugin', Array)
#15 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application->runAction('install/plugin', Array)
#16 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('install/plugin', Array)
#17 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#18 /Users/tdavis/sites/osi/craft(22): yii\base\Application->run()
#19 {main}
*** installed simplemap successfully (time: 0.036s)

~/sites/osi (craft3): 

Then, if I visit the CP, the plugin is not installed

Tam commented 5 years ago

@davist11 Did you run those commands using your Craft 2 database, or after you'd upgraded to Craft 3? If you ran them after you'd upgraded to Craft 3, could you try running them on your Craft 2 database?

davist11 commented 5 years ago

So to confirm, you want me to import my craft 2 DB, then run those commands? Wouldn't running ./craft migrate/all run the Craft 3 upgrade?

Tam commented 5 years ago

Yes, and yes. In your previous attempt it looked like you had already tried to upgrade Maps once so the second attempt failed.

davist11 commented 5 years ago

Ok, different error this time

~/sites/osi (craft3): ./craft install/plugin simplemap
*** installing simplemap
    > create table {{%simplemaps}} ... done (time: 0.023s)
    > create unique index craft_simplemaps_ownerId_ownerSiteId_fieldId_unq_idx on {{%simplemaps}} (ownerId,ownerSiteId,fieldId) ... done (time: 0.013s)
    > create index craft_simplemaps_lat_idx on {{%simplemaps}} (lat) ... done (time: 0.029s)
    > create index craft_simplemaps_lng_idx on {{%simplemaps}} (lng) ... done (time: 0.016s)
    > add foreign key craft_simplemaps_id_fk: {{%simplemaps}} (id) references {{%elements}} (id) ... done (time: 0.022s)
    > add foreign key craft_simplemaps_ownerId_fk: {{%simplemaps}} (ownerId) references {{%elements}} (id) ... done (time: 0.021s)
    > add foreign key craft_simplemaps_ownerSiteId_fk: {{%simplemaps}} (ownerSiteId) references {{%sites}} (id) ... done (time: 0.026s)
    > add foreign key craft_simplemaps_fieldId_fk: {{%simplemaps}} (fieldId) references {{%fields}} (id) ... done (time: 0.021s)
    > delete from {{%plugins}} ... done (time: 0.001s)
    > Start map data upgrade
    > Upgrade map value Gothics Trek, Keene Valley, NY 12943, USA
    > Upgrade map value Adirondack Park Preserve, Newcomb, NY 12852, USA
    > Upgrade map value Fontaine Hall, 350 North Rd, Poughkeepsie, NY 12601, USA
    > Upgrade map value 1566 Worlds Edge Rd, Mill Spring, NC 28756, USA
    > Upgrade map value Clarence Fahnestock State Park, Putnam Valley, NY 10579, USA
    > Upgrade map value 123 Little Peck Hollow Rd, Big Indian, NY 12410, USA
    > Upgrade map value 104 Broadway, Watervliet, NY 12189, USA
    > Upgrade map value 477 Beaverkill Rd, Olivebridge, NY 12461, USA
    > Upgrade map value 42 Arden House Rd, Harriman, NY 10926, USA
    > Upgrade map value 61 Lower Station Rd, Garrison, NY 10524, USA
    > Upgrade map value 26 V F W Rd, Wurtsboro, NY 12790, USA
    > Upgrade map value 932 Oliverea Rd, Big Indian, NY 12410, USA
    > Upgrade map value 127 Warren Landing Rd, Garrison, NY 10524, USA
    > Upgrade map value 744 Sly Pond Rd, Fort Ann, NY 12827, USA
    > Upgrade map value 3150 Maggie Hoag Rd, Delancey, NY 13752, USA
    > Upgrade map value 34 West St, Cold Spring, NY 10516, USA
    > Upgrade map value 84 Fort Ti Rd, Ticonderoga, NY 12883, USA
    > Upgrade map value 881 NY-9D, Garrison, NY 10524, USA
    > Upgrade map value 96 Lower Station Rd, Garrison, NY 10524, USA
    > Upgrade map value 90 Mystery Point Rd, Garrison, NY 10524, USA
    > Upgrade map value 2948 US-209, Wurtsboro, NY 12790, USA
    > Upgrade map value 320 Railroad Pl, North Creek, NY 12853, USA
    > Upgrade map value Overlook Mountain Trail, Bearsville, NY 12409, USA
    > Upgrade map value 3 Malcom Gordon Rd, Garrison, NY 10524, USA
    > Upgrade map value Adirondack Park Preserve, Lewis, NY 12950, USA
    > Upgrade map value 595 Broadway, Watervliet, NY 12189, USA
    > Upgrade map value 165 Game Farm Rd, Berne, NY 12023, USA
    > Upgrade map value 145 Sterling St, Beacon, NY 12508, USA
    > Upgrade map value 84 Liberty St, Newburgh, NY 12550, USA
    > Upgrade map value 86 Buckberg Rd, Tomkins Cove, NY 10986, USA
    > Upgrade map value 15 Cramer Rd, Pine Bush, NY 12566, USA
    > Upgrade map value 388 Main St, Kingston, NY 12401, USA
    > Upgrade map value 3401-3411 US-209, Stone Ridge, NY 12484, USA
    > Upgrade map value Sand Spring Bridge, Cold Spring, NY 10516, USA
    > Upgrade map value 25 Ash St, Port Jervis, NY 12771, USA
    > Upgrade map value 13 W End Ave, Rosendale, NY 12472, USA
    > Upgrade map value 153 Huguenot St, New Paltz, NY 12561, USA
    > Upgrade map value 45 Phillies Bridge Rd, New Paltz, NY 12561, USA
    > Upgrade map value 101-111 Trapps Rd, Gardiner, NY 12525, USA
    > Upgrade map value Shawangunk Ridge Trail, Pine Bush, NY 12566, USA
    > Upgrade map value 159 Sullivan St, Wurtsboro, NY 12790, USA
    > Upgrade map value 3240 NY-9D, Cold Spring, NY 10516, USA
    > Upgrade map value 2570 Staats Island Rd, Castleton-On-Hudson, NY 12033, USA
    > Upgrade map value 210 W Barnard St, Glennville, GA 30427, USA
    > Upgrade map value 322 W Main St, Monteagle, TN 37356, USA
    > Upgrade map value 69 Co Rd 9, Estillfork, AL 35745, USA
    > Upgrade map value 431 Main St, Chimney Rock, NC 28720, USA
    > Upgrade map value Appalachian Trail, Hampton, TN 37658, USA
    > Upgrade map value 112 Mountains Blvd, Lake Lure, NC 28746, USA
    > Upgrade map value 4076 VT-105, Jay, VT 05859, USA
    > Upgrade map value 4 Water St, Grand Lake Stream, ME 04637, USA
    > Upgrade map value 497 VT-44, Brownsville, VT 05037, USA
    > Upgrade map value Appalachian Trail, Carrabassett Valley, ME 04947, USA
    > Upgrade map value Newell Brook Rd, Milan, NH 03588, USA
    > Upgrade map value 38 Dunbarton Rd, Concord, NH 03301, USA
    > Upgrade map value Murray D. Lincoln Campus Center, Campus Center Way, Amherst, MA 01003, USA
    > Upgrade map value 4520 Horseshoe Pike, Honey Brook, PA 19344, USA
    > Upgrade map value 1450 County Rd 532, Chatsworth, NJ 08019, USA
    > Upgrade map value 1 Mountain Rd, Columbia, PA 07832, USA
    > Upgrade map value 10 Bog Rd, East Stroudsburg, PA 18301, USA
    > Upgrade map value 320 Cross Junction Rd, Cross Junction, VA 22625, USA
    > Upgrade map value 7515 US-17, Awendaw, SC 29429, USA
    > Upgrade map value 1214 Lula Lake Rd, Lookout Mountain, GA 30750, USA
    > Upgrade map value 2 Rue de Vale Perkins, Mansonville, QC J0E 1X0, Canada
    > Upgrade map value 175-179 Milton Hall Dr, Georgetown, SC 29440, USA
    > Upgrade map value 250 Taxter Rd, Elmsford, NY 10523, USA
    > Upgrade map value 277 Bennetts Ln, Somerset, NJ 08873, USA
    > Upgrade map value 23 Springtown Rd, New Paltz, NY 12561, USA
    > Upgrade map value 7 Lyons Creek Ln, Gardiner, NY 12525, USA
    > Upgrade map value Unnamed Road, South Pittsburg, TN 37380, USA
    > Upgrade map value 65 Reservoir Rd, Cornwall, NY 12518, USA
    > Upgrade map value 342 Gale Hill Rd, East Chatham, NY 12060, USA
    > Upgrade map value John Boyd Thacher State Park, Voorheesville, NY 12186, USA
    > Upgrade map value 3865 Fiery Gizzard Rd, South Pittsburg, TN 37380, USA
    > Upgrade map value 16 Old Manitou Rd, Garrison, NY 10524, USA
    > Upgrade map value 73 Park Rd W, Castile, NY 14427, USA
    > Upgrade map value 47 Rabbit Run Ln, Wilkes-Barre, PA 18702, USA
    > Upgrade map value 349 Greene Rd, Greenfield Center, NY 12833, USA
    > Upgrade map value Little River Rd, Grand Lake Stream, ME 04637, USA
    > Upgrade map value 3 Meadow Rd, Raymond, ME 04071, USA
    > Upgrade map value 232 Sheppard Davis Rd, Cedarville, NJ 08311, USA
    > Upgrade map value 41 Sunset Lake Rd, Bridgeton, NJ 08302, USA
    > Upgrade map value 82 School House Rd, Orient, ME 04471, USA
    > Upgrade map value 11 Lyons Creek Ln, Gardiner, NY 12525, USA
    > Upgrade map value 856 Lakeshore Rd, Essex, NY 12936, USA
    > Upgrade map value 7479 NY-28, Schuyler Lake, NY 13457, USA
    > Upgrade map value 340 Otterkill Rd, Salisbury Mills, NY 12577, USA
    > Upgrade map value 99 Campsite Rd, Livingston Manor, NY 12758, USA
    > Upgrade map value 116 Old Forge Rd, Tuxedo Park, NY 10987, USA
    > Upgrade map value 4097 Albany Post Rd, Hyde Park, NY 12538, USA
    > Upgrade map value Breakneck Ridge Trail, Cold Spring, NY 10516, USA
    > Upgrade map value 713 Berry Brook Rd, Roscoe, NY 12776, USA
    > Upgrade map value 641 County Rd 174, Monticello, NY 12701, USA
    > Upgrade map value 73 Park Rd W, Castile, NY 14427, USA
    > Upgrade map value Pine Meadow Rd, Stony Point, NY 10980, USA
    > Upgrade map value I-95, Benedicta, ME 04733, USA
    > Upgrade map value 533 Wilbur Ave, Greenwich, NY 12834, USA
    > Upgrade map value 342 Altamont Rd, Altamont, NY 12009, USA
    > Upgrade map value 66 Breezy Ridge Rd, Kinderhook, NY 12106, USA
    > Upgrade map value 605 Old Saratoga Rd, Gansevoort, NY 12831, USA
    > Upgrade map value 756 US-4, Stillwater, NY 12170, USA
    > Upgrade map value 343 Spier Falls Rd, Corinth, NY 12822, USA
    > Upgrade map value 939 Elting Rd, Rosendale, NY 12472, USA
    > Upgrade map value 377 Lofton Ct, McClellanville, SC 29458, USA
    > Upgrade map value 400 Sams Point Rd, Cragsmoor, NY 12420, USA
    > Upgrade map value 18-97 Main St, Machias, ME 04654, USA
    > Upgrade map value Face Chutes, North Troy, VT 05859, USA
    > Upgrade map value 1337 NB-16, Jolicure, NB E4L 2P7, Canada
    > Upgrade map value 400 Big Valley Ln, Barton, VT 05822, USA
    > Upgrade map value 1760 Wheelbarrow Rd, Sparta, TN 38583, USA
    > Upgrade map value 8303 Sewanee Hwy, Cowan, TN 37318, USA
    > Upgrade map value 6838 Lost Creek Rd, Sparta, TN 38583, USA
    > Upgrade map value 783 S Bay Trail, Pittsburg, NH 03592, USA
    > Upgrade map value 6 Main St, Errol, NH 03579, USA
    > Upgrade map value Eames Rd, Errol, NH 03579, USA
    > Upgrade map value 196 Echo Valley Rd, Phillips, ME 04966, USA
    > Upgrade map value Appalachian Trail, Carrabassett Valley, ME 04947, USA
    > Upgrade map value Appalachian Trail, Jonestown, PA 17038, USA
    > Upgrade map value Dodge Dr, Madison, NJ 07940, USA
    > Upgrade map value 831 Razorback Ridge Rd, Great Cacapon, WV 25422, USA
    > Upgrade map value 431 Main St, Chimney Rock, NC 28720, USA
    > Upgrade map value 518 T515, East Stroudsburg, PA 18301, USA
    > Upgrade map value 4779 Co Rd 140, Estillfork, AL 35745, USA
    > Upgrade map value 1523 Sugar Cove Rd, Huntland, TN 37345, USA
    > Upgrade map value 12020 AL-65, Hollytree, AL 35751, USA
    > Upgrade map value 1450 County Rd 532, Chatsworth, NJ 08019, USA
    > Upgrade map value 1450 County Rd 532, Chatsworth, NJ 08019, USA
    > Upgrade map value 1450 County Rd 532, Chatsworth, NJ 08019, USA
    > Upgrade map value 5 Realty Rd, Ashland, ME 04732, USA
    > Upgrade map value 23E Overbrook Hamlet Way, Lincoln, NH 03251, USA
    > Upgrade map value Gothics Trek, Keene Valley, NY 12943, USA
    > Upgrade map value 244 S Main St, Marion, VA 24354, USA
    > Upgrade map value 175-179 Milton Hall Dr, Georgetown, SC 29440, USA
    > Upgrade map value 61 Chester Turnpike, Hooksett, NH 03106, USA
    > Upgrade map value 36 French Rd, Nottingham, NH 03290, USA
    > Upgrade map value 31 Farrwood Dr, Hooksett, NH 03106, USA
    > Upgrade map value 1 Montague Rd, Leverett, MA 01054, USA
    > Upgrade map value Russell / Middle, Hadley, MA 01035, USA
    > Upgrade map value 1981 Roaring Creek Rd, Newland, NC 28657, USA
    > Upgrade map value 844 Powdermill Creek Rd, Newland, NC 28657, USA
    > Upgrade map value Appalachian Trail, Hampton, TN 37658, USA
    > Upgrade map value 810 Greenfield Rd, Leyden, MA 01337, USA
    > Upgrade map value 5 School St, Alton, NH 03809, USA
    > Upgrade map value 174-186 Central St, Millinocket, ME 04462, USA
    > Upgrade map value 75th Rd, Whiting, ME 04691, USA
    > Upgrade map value 3470 Horseshoe Pike, Honey Brook, PA 19344, USA
    > Upgrade map value 3550 Conestoga Rd, Glenmoore, PA 19343, USA
    > Upgrade map value 2362 Phlox Ct, Jamison, PA 18929, USA
    > Upgrade map value 19013 GA-193, Chickamauga, GA 30707, USA
    > Upgrade map value 777 Deerfield Rd, Chickamauga, GA 30707, USA
    > Upgrade map value 174 Lost Lake Dr, Troy, NC 27371, USA
    > Upgrade map value 3573 Glady Fork Rd, Brevard, NC 28712, USA
    > Upgrade map value 830 Thacher Park Rd, Voorheesville, NY 12186, USA
    > Upgrade map value 6 Hudson St, Warrensburg, NY 12885, USA
    > Upgrade map value 12 A Flint Hill Rd, Troy, NC 27371, USA
    > Upgrade map value 35 Garrisons Landing, Garrison, NY 10524, USA
    > Upgrade map value Reservoir Rd, Haydenville, MA 01039, USA
    > Upgrade map value 1322 Bridgeton Rd, Greenwich, NJ 08323, USA
    > Upgrade map value 676-824 Mace Chasm Rd, Keeseville, NY 12944, USA
    > Upgrade map value 16124 NW 320th St, Okeechobee, FL 34972, USA
    > Upgrade map value 372 Watson Hollow Rd, West Shokan, NY 12494, USA
    > Upgrade map value Unnamed Road, Indian Lake, NY 12842, USA
    > Upgrade map value 1699 Jersey St, Essex, NY 12936, USA
    > Upgrade map value 801 Mace Chasm Rd, Keeseville, NY 12944, USA
    > Upgrade map value 3311 Essex Rd, Willsboro, NY 12996, USA
    > Upgrade map value 2217 Jersey St, Essex, NY 12936, USA
    > Upgrade map value 1037 Stevenson Rd, Westport, NY 12993, USA
    > Upgrade map value 327 Walker Rd, Essex, NY 12936, USA
    > Upgrade map value 206 Trembleau Rd, Keeseville, NY 12944, USA
    > Upgrade map value 73 Barnard Ridge Rd, Meredith, NH 03253, USA
    > Upgrade map value 160 Joseph Ln, Summerville, SC 29485, USA
    > Upgrade map value Lazy Hill Rd, Chester, NY 10918, USA
    > Upgrade map value 728 US-40, Pilesgrove, NJ 08098, USA
    > Upgrade map value 340 Youngs Mountain Dr, Lake Lure, NC 28746, USA
    > Upgrade map value 33 E Main St, Richmond, VT 05477, USA
    > Upgrade map value Unnamed Road, Newfoundland, PA 18445, USA
    > Upgrade map value 2-298 Windmill Hill Trail, Brookline, VT 05345, USA
    > Upgrade map value 128 Newcut Rd, Bearsville, NY 12409, USA
    > Upgrade map value 27 Wexton St, Woodbine, NJ 08270, USA
    > Upgrade map value 1688 Wild Acres Rd, Marion, NC 28752, USA
    > Upgrade map value 220 Park Rd, Caryville, TN 37714, USA
    > Upgrade map value 117 State Preserve Rd, Middleburgh, NY 12122, USA
    > Upgrade map value 154 Mountain Rd, Delaware Water Gap, PA 18327, USA
    > Upgrade map value 608 Ramapo Valley Rd, Oakland, NJ 07436, USA
    > Upgrade map value Sebago Lake, ME 04084, USA
    > Upgrade map value 3 Stevens Rd, Harriman, NY 10926, USA
    > Upgrade map value 24 Worden Dr, Bloomingburg, NY 12721, USA
    > Upgrade map value Appalachian Trail, Carrabassett Valley, ME 04947, USA
    > Upgrade map value 107 11th St, Watkins Glen, NY 14891, USA
    > Upgrade map value 4°46”21.717”N, 86°20’26,359W
    > Upgrade map value 255 Roberts Rd, Georgetown, SC 29440, USA
    > Upgrade map value 3001 S Mountain Park, Connelly Springs, NC 28612, USA
    > Upgrade map value Unnamed Road, Lake Waccamaw, NC 28450, USA
    > Upgrade map value 2501 Mistletoe Ln, Millville, NJ 08332, USA
    > Upgrade map value Unnamed Road, Canton, NC 28716, USA
    > Upgrade map value Minnewaska State Park Preserve, 5281 Route 44-55, Kerhonkson, NY 12446, USA
    > Upgrade map value 1895 Swisher Hollow Rd, Springfield, WV 26763, USA
    > Upgrade map value 5100 Co Hwy 2190, Sparta, TN 38583, USA
    > Upgrade map value 3300 NC-108, Columbus, NC 28722, USA
    > Upgrade map value 209 State Rd, Plymouth, MA 02360, USA
    > Upgrade map value 122 Main St, Andover, NJ 07821, USA
    > Upgrade map value Unnamed Road, East Corinth, VT 05040, USA
    > drop table {{%simplemap_maps}} ... done (time: 0.003s)
    > Upgrade map field type upgrade
    > Upgrade map field location
    > Upgrade Maps settings
Exception: Undefined index: serverApiKey (/Users/tdavis/sites/osi/vendor/ether/simplemap/src/migrations/m190226_143809_craft3_upgrade.php:305)
#0 /Users/tdavis/sites/osi/vendor/ether/simplemap/src/migrations/m190226_143809_craft3_upgrade.php(305): yii\base\ErrorHandler->handleError(8, 'Undefined index...', '/Users/tdavis/s...', 305, Array)
#1 /Users/tdavis/sites/osi/vendor/ether/simplemap/src/migrations/m190226_143809_craft3_upgrade.php(145): ether\simplemap\migrations\m190226_143809_craft3_upgrade->updatePluginSettings()
#2 /Users/tdavis/sites/osi/vendor/ether/simplemap/src/migrations/m190226_143809_craft3_upgrade.php(48): ether\simplemap\migrations\m190226_143809_craft3_upgrade->_upgrade2()
#3 /Users/tdavis/sites/osi/vendor/ether/simplemap/src/migrations/Install.php(110): ether\simplemap\migrations\m190226_143809_craft3_upgrade->safeUp()
#4 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/db/Migration.php(56): ether\simplemap\migrations\Install->safeUp()
#5 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)
#6 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/base/Plugin.php(152): craft\db\MigrationManager->migrateUp(Object(ether\simplemap\migrations\Install))
#7 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/services/Plugins.php(520): craft\base\Plugin->install()
#8 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/console/controllers/InstallController.php(191): craft\services\Plugins->installPlugin('simplemap')
#9 [internal function]: craft\console\controllers\InstallController->actionPlugin('simplemap')
#10 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#12 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('plugin', Array)
#13 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('plugin', Array)
#14 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('install/plugin', Array)
#15 /Users/tdavis/sites/osi/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application->runAction('install/plugin', Array)
#16 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('install/plugin', Array)
#17 /Users/tdavis/sites/osi/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#18 /Users/tdavis/sites/osi/craft(22): yii\base\Application->run()
#19 {main}
*** installed simplemap successfully (time: 3.448s)
davist11 commented 5 years ago

Just wanted to see if there was any update here or any other information I can provide.

engram-design commented 5 years ago

Also seeing this issue on a Craft 2 upgrade. Have also followed the steps:

2019-07-25 21:55:50 [-][1][-][error][craft\db\MigrationManager::migrateUp] Failed to apply Install (time: 0.274s). Output:
    > create table {{%maps}} ... done (time: 0.042s)
    > create unique index maps_ownerId_ownerSiteId_fieldId_unq_idx on {{%maps}} (ownerId,ownerSiteId,fieldId) ... done (time: 0.008s)
    > create index maps_lat_idx on {{%maps}} (lat) ... done (time: 0.011s)
    > create index maps_lng_idx on {{%maps}} (lng) ... done (time: 0.025s)
    > add foreign key maps_ownerId_fk: {{%maps}} (ownerId) references {{%elements}} (id) ... done (time: 0.018s)
    > add foreign key maps_ownerSiteId_fk: {{%maps}} (ownerSiteId) references {{%sites}} (id) ... done (time: 0.042s)
    > add foreign key maps_fieldId_fk: {{%maps}} (fieldId) references {{%fields}} (id) ... done (time: 0.106s)
    > delete from {{%plugins}} ... done (time: 0.000s)
    > Start map data upgrade
    > Upgrade map value 252 Gnangara Rd, Landsdale WA 6065, Australia
Exception: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'ownerId' cannot be null
The SQL being executed was: INSERT INTO `maps` (`ownerId`, `ownerSiteId`, `fieldId`, `lat`, `lng`, `dateCreated`, `dateUpdated`, `uid`) VALUES (NULL, NULL, NULL, '-31.80023600', '115.84445910', '2019-07-25 09:55:50', '2019-07-25 09:55:50', '164966ec-1763-49d9-9285-d4c41ccf5826') (/Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/db/Schema.php:664)
#0 /Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/db/Command.php(1295): yii\db\Schema->convertException(Object(PDOException), 'INSERT INTO `ma...')
#1 /Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/db/Command.php(1091): yii\db\Command->internalExecute('INSERT INTO `ma...')
#2 /Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/db/Schema.php(433): yii\db\Command->execute()
#3 /Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/db/ActiveRecord.php(600): yii\db\Schema->insert('{{%maps}}', Array)
#4 /Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/db/ActiveRecord.php(566): yii\db\ActiveRecord->insertInternal(NULL)
#5 /Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/db/BaseActiveRecord.php(678): yii\db\ActiveRecord->insert(false, NULL)
#6 /Users/joshcrawford/public_html/site/vendor/ether/simplemap/src/services/MapService.php(117): yii\db\BaseActiveRecord->save(false)
#7 /Users/joshcrawford/public_html/site/vendor/ether/simplemap/src/migrations/m190226_143809_craft3_upgrade.php(97): ether\simplemap\services\MapService->saveRecord(Object(ether\simplemap\models\Map), true)
#8 /Users/joshcrawford/public_html/site/vendor/ether/simplemap/src/migrations/m190226_143809_craft3_upgrade.php(47): ether\simplemap\migrations\m190226_143809_craft3_upgrade->_upgrade2()
#9 /Users/joshcrawford/public_html/site/vendor/ether/simplemap/src/migrations/Install.php(98): ether\simplemap\migrations\m190226_143809_craft3_upgrade->safeUp()
#10 /Users/joshcrawford/public_html/site/vendor/craftcms/cms/src/db/Migration.php(56): ether\simplemap\migrations\Install->safeUp()
#11 /Users/joshcrawford/public_html/site/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)
#12 /Users/joshcrawford/public_html/site/vendor/craftcms/cms/src/base/Plugin.php(152): craft\db\MigrationManager->migrateUp(Object(ether\simplemap\migrations\Install))
#13 /Users/joshcrawford/public_html/site/vendor/craftcms/cms/src/services/Plugins.php(520): craft\base\Plugin->install()
#14 /Users/joshcrawford/public_html/site/vendor/craftcms/cms/src/controllers/PluginsController.php(53): craft\services\Plugins->installPlugin('simplemap', 'standard')
#15 [internal function]: craft\controllers\PluginsController->actionInstallPlugin()
#16 /Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#17 /Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#18 /Users/joshcrawford/public_html/site/vendor/craftcms/cms/src/web/Controller.php(187): yii\base\Controller->runAction('install-plugin', Array)
#19 /Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('install-plugin', Array)
#20 /Users/joshcrawford/public_html/site/vendor/craftcms/cms/src/web/Application.php(299): yii\base\Module->runAction('plugins/install...', Array)
#21 /Users/joshcrawford/public_html/site/vendor/craftcms/cms/src/web/Application.php(566): craft\web\Application->runAction('plugins/install...', Array)
#22 /Users/joshcrawford/public_html/site/vendor/craftcms/cms/src/web/Application.php(278): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#23 /Users/joshcrawford/public_html/site/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#24 /Users/joshcrawford/public_html/site/public_html/index.php(29): yii\base\Application->run()
#25 {main}
engram-design commented 5 years ago

Diving into it, is seems that in m190226_143809_craft3_upgrade.php there's this code:

$map = new Map([
    'ownerId'     => $row['ownerId'],
    'ownerSiteId' => $site->id,
    'fieldId'     => $row['fieldId'],
    'lat'         => $row['lat'],
    'lng'         => $row['lng'],
]);

Which these values are all correct and populated. However, looking at models/Map.php, there's the following code:

foreach (['id', 'ownerId', 'ownerSiteId', 'fieldId'] as $key)
    if (array_key_exists($key, $config))
        unset($config[$key]);

\Craft::dd($config);

parent::__construct($config);

Which strips out the important information like ownerId, etc before passing to the parent constructor. As you can see, using a print statement, showing:

ether\simplemap\models\Map#1
(
    [id] => null
    [ownerId] => null
    [ownerSiteId] => null
    [fieldId] => null
    [lat] => '-31.80023600'
    [lng] => '115.84445910'
    [zoom] => 15
    [address] => ''
...

Is that all correct? To work around this, I've modified the migration code to be:

$map = new Map();
$map->ownerId = $row['ownerId'];
$map->ownerSiteId = $site->id;
$map->fieldId = $row['fieldId'];
$map->lat = $row['lat'];
$map->lng = $row['lng'];