Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install Maps after updating Craft 2.6 migration to Craft 3.7 #327

Open
pbmills opened this issue Oct 10, 2021 · 4 comments
Open

Can't install Maps after updating Craft 2.6 migration to Craft 3.7 #327

pbmills opened this issue Oct 10, 2021 · 4 comments
Labels

Comments

@pbmills
Copy link

pbmills commented Oct 10, 2021

Description

After updating Craft 2 to Craft 3 can't install Maps.
Steps to reproduce

Install Maps
Settings > Plugins shows Not installed

Additional info

Craft version:3.7

Here's what I get when I ./craft install/plugin simplemap :

 > create table {{%maps}} ...Exception: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'craft_maps' already exists
The SQL being executed was: CREATE TABLE `craft_maps` (
        `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),
        `dateCreated` datetime(0) NOT NULL,
        `dateUpdated` datetime(0) NOT NULL,
        `uid` char(36) NOT NULL DEFAULT '0'
) ENGINE = InnoDb DEFAULT CHARACTER SET = utf8 (/Users/premills/Sites/clinic-website/vendor/yiisoft/yii2/db/Schema.php:678)
@alexjcollins
Copy link
Member

@reachpriti12 Was Maps already installed when running Craft 2.6? Or were you installing it fresh on 3.7?

@Tam Tam added the Craft 3 label Jul 11, 2022
@parryhuang
Copy link

Same issue here.
Trying to upgrade from craft 2.9.2 to craft 3.7.40

Database Exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'my-database.craft_simplemaps' doesn't exist
The SQL being executed was: SELECT ownerId, ownerSiteId, fieldId, lat, lng, zoom, address, parts
FROM craft_simplemaps

Migration: ether\simplemap\migrations\m190226_143809_craft3_upgrade

Output:
    > create table {{%maps}} ... done (time: 0.028s)
    > create unique index craft_idx_ajkhgqjrymguqnelxjusqmcmaayerwilpdoh on {{%maps}} (ownerId,ownerSiteId,fieldId) ... done (time: 0.028s)
    > create index craft_idx_cqtidkezdxlzstbgseulfhyohkyknrtdqncv on {{%maps}} (lat) ... done (time: 0.027s)
    > create index craft_idx_afixcepetjasxtxvjymxjurpgxiyuzkfmsiv on {{%maps}} (lng) ... done (time: 0.026s)
    > add foreign key craft_fk_ynozryuhwnfemapdvvsrwmhjbokmatqemuqk: {{%maps}} (ownerId) references {{%elements}} (id) ... done (time: 0.034s)
    > add foreign key craft_fk_apgkeypmweczhyrduprjfummbldtosluwcfy: {{%maps}} (ownerSiteId) references {{%sites}} (id) ... done (time: 0.033s)
    > add foreign key craft_fk_ingvtsdcwbmxmucsvknsdxfenattnyudpbsf: {{%maps}} (fieldId) references {{%fields}} (id) ... done (time: 0.035s)
    > delete from {{%plugins}} ... done (time: 0.001s)
    > Start map data upgrade
    > Upgrade map value ......
    // abunch of map value update ...
    > drop table {{%simplemap_maps}} ... done (time: 0.002s)
    > Upgrade map field type upgrade
    > Upgrade map field gpsLocation
    > Upgrade map field gpsLocation
    > Upgrade Maps settings
    > Start map data upgrade
Exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'my-database.craft_simplemaps' doesn't exist
The SQL being executed was: SELECT ownerId, ownerSiteId, fieldId, lat, lng, zoom, address, parts
FROM craft_simplemaps (/Users/project/vendor/yiisoft/yii2/db/Schema.php:676)
#0 /Users/project/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'SELECT ownerId...')
#1 /Users/project/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT ownerId...')
#2 /Users/project/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /Users/project/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /Users/project/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#5 /Users/project/vendor/ether/simplemap/src/migrations/m190226_143809_craft3_upgrade.php(174): craft\db\Query->all()
#6 /Users/project/vendor/ether/simplemap/src/migrations/m190226_143809_craft3_upgrade.php(50): ether\simplemap\migrations\m190226_143809_craft3_upgrade->_upgrade3()
#7 /Users/project/vendor/craftcms/cms/src/db/Migration.php(53): ether\simplemap\migrations\m190226_143809_craft3_upgrade->safeUp()
#8 /Users/project/vendor/craftcms/cms/src/db/MigrationManager.php(232): craft\db\Migration->up(true)
#9 /Users/project/vendor/craftcms/cms/src/db/MigrationManager.php(148): craft\db\MigrationManager->migrateUp(Object(ether\simplemap\migrations\m190226_143809_craft3_upgrade))
#10 /Users/project/vendor/craftcms/cms/src/services/Updates.php(250): craft\db\MigrationManager->up()
#11 /Users/project/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(532): craft\services\Updates->runMigrations(Array)
#12 /Users/project/vendor/craftcms/cms/src/controllers/UpdaterController.php(201): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#13 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#14 /Users/project/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#15 /Users/project/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#16 /Users/project/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('migrate', Array)
#17 /Users/project/vendor/craftcms/cms/src/web/Application.php(293): yii\base\Module->runAction('updater/migrate', Array)
#18 /Users/projectvendor/craftcms/cms/src/web/Application.php(690): craft\web\Application->runAction('updater/migrate')
#19 /Users/project/vendor/craftcms/cms/src/web/Application.php(250): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#20 /Users/project/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#21 /Users/project/index.php(26): yii\base\Application->run()
#22 {main}

After I noticed migration failed, I only had "craft_maps" table in database, with the column:

'id','int(11)','NO','PRI',NULL,'auto_increment'
'ownerId','int(11)','NO','MUL',NULL,''
'ownerSiteId','int(11)','YES','MUL',NULL,''
'fieldId','int(11)','NO','MUL',NULL,''
'lat','decimal(11,9)','YES','MUL',NULL,''
'lng','decimal(12,9)','YES','MUL',NULL,''
'dateCreated','datetime','NO','',NULL,''
'dateUpdated','datetime','NO','',NULL,''
'uid','char(36)','NO','','0',''

And I had two previous migrations from simple map in craft_migrations table
m160606_162300_simpleMap_updateFieldStorage
m171027_173900_simpleMap_addLatLngIndexes

@parryhuang
Copy link

By passed by manually update source code at:


to

else if($this->db->tableExists(MapRecord::OldTableName))

Not sure if this is the correct way.

Now getting a new error:

Database Exception: SQLSTATE[HY000]: General error: 1553 Cannot drop index 'craft_idx_nnywmybwyiheszqlwuexciublrlwebrsxrgz': needed in a foreign key constraint
The SQL being executed was: DROP INDEX craft_idx_nnywmybwyiheszqlwuexciublrlwebrsxrgz ON craft_maps

Migration: ether\simplemap\migrations\m190712_104805_new_data_format

Output:

1. Creating Maps content columns
- Create content column for GPS location in content table
> alter column field_gpsLocation in table {{%content}} to text ... done (time: 0.027s)
2. Creating new Maps table
> drop index craft_idx_nnywmybwyiheszqlwuexciublrlwebrsxrgz on {{%maps}} ...Exception: SQLSTATE[HY000]: General error: 1553 Cannot drop index 'craft_idx_nnywmybwyiheszqlwuexciublrlwebrsxrgz': needed in a foreign key constraint
The SQL being executed was: DROP INDEX craft_idx_nnywmybwyiheszqlwuexciublrlwebrsxrgz ON craft_maps (/Users/project/vendor/yiisoft/yii2/db/Schema.php:676)
#0 /Users/project/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'DROP INDEX cra...')
#1 /Users/project/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command->internalExecute('DROP INDEX cra...')
#2 /Users/project/vendor/yiisoft/yii2/db/Migration.php(507): yii\db\Command->execute()
#3 /Users/project/vendor/ether/simplemap/src/migrations/m190712_104805_new_data_format.php(238): yii\db\Migration->dropIndex('craft_idx_nnywm...', '{{%maps}}')
#4 /Users/project/vendor/craftcms/cms/src/db/Migration.php(53): ether\simplemap\migrations\m190712_104805_new_data_format->safeUp()
#5 /Users/project/vendor/craftcms/cms/src/db/MigrationManager.php(232): craft\db\Migration->up(true)
#6 /Users/project/vendor/craftcms/cms/src/db/MigrationManager.php(148): craft\db\MigrationManager->migrateUp(Object(ether\simplemap\migrations\m190712_104805_new_data_format))
#7 /Users/project/vendor/craftcms/cms/src/services/Updates.php(250): craft\db\MigrationManager->up()
#8 /Users/project/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(532): craft\services\Updates->runMigrations(Array)
#9 /Users/project/vendor/craftcms/cms/src/controllers/UpdaterController.php(201): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#10 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#11 /Users/project/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /Users/project/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#13 /Users/project/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('migrate', Array)
#14 /Users/project/vendor/craftcms/cms/src/web/Application.php(293): yii\base\Module->runAction('updater/migrate', Array)
#15 /Users/project/vendor/craftcms/cms/src/web/Application.php(690): craft\web\Application->runAction('updater/migrate')
#16 /Users/project/vendor/craftcms/cms/src/web/Application.php(250): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#17 /Users/project/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /Users/project/index.php(26): yii\base\Application->run()
#19 {main}

@alexjcollins
Copy link
Member

I'd guess there's an issue jumping straight to 3.7 from Craft 2.
I know it's probably super-tedious, but would you be able to try incrementally updating Craft and the Plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants