-
Notifications
You must be signed in to change notification settings - Fork 65
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
Trying to update to Craft 4 but getting issues with LinkField #230
Comments
I reverted back to a working version with Craft cms 3.7, and tried to update again and migrate the DB again, but with different results. I have checked a few of these fields and they are not inside a supertable field. They are simply a Link field, some entries have a link on them, some leave it blank. Not sure what to do from here.
The SQL being executed was: INSERT INTO 25 from 26 migrations were applied. Migration failed. The rest of the migrations are canceled. |
We're also getting this error during |
+1, getting the exact same error. |
@mateostabio There was an error reported like this before and as far as I remember a fix has been created. Which version do you try to update to? Could you check your content table whether there is a column named 'field_cta' or wether it has some suffix? I think the second error was triggered because the table |
+1 I have Linkfields in Supertable fields.
|
+1 here. In doing some digging if it helps, we been able to recreate the following a few times. When we we run the migration the first time after running composer update which includes Craft 4.2.1.1 and "sebastianlenz/linkfield": "2.1.3-rc". We consistently get and that kills the migration. If we try to run it again we get a different error
The "Link Field" mentioned here is inside of a matrix block. If we look back at the output from the first attempt at migration we see
So the second error makes sense since the column was removed in the first migration attempt before it errored. Thanks! |
+1 |
There are at least two separate issues here.
No idea, but I suspect those are results of failed updates (for whatever reason) and the database/project config files weren't reverted to their pre-update attempt states before another update was attempted.
The root cause is there are orphaned rows in the respective content tables (matrix, super table, etc.) that don't have a matching element id in the elements table. There is a PR here that should resolve it: #235 This doesn't clean up the orphaned rows but does ensure that the migration is only working with valid data. |
Hi @sebastian-lenz ! Any update on this bug? |
I've released version 2.1.4 which contains the fix supplied by angrybrad. |
We are encountering the same issue:
etc... And this is with: Craft 4.1.1.1 LMK if you'd like a copy of my DB & project config. |
Actually, scratch that. I think our issue was re-playing the upgrade on a database that already had the |
@johndwells So you got it to work? If so, how did you get passed the error? |
@mateostabio Because I run these upgrades locally and multiple times, what must have happened was that in one upgrade attempt, Link Field's migration adds the So basically my "fix" was making sure that |
@johndwells I tried to make this work, but no luck. Still throwing me this error, even though I removed anything to do with 'lenz_linkfield' |
Same issue here, have been trying to upgrade for the last 3 hours, tried every different combination, resaving entries before upgrade, migrates the tables and then comes up with an error. Any ideas of what else I can try to get this to finish the migration? *** applying m190417_202153_migrateDataToTable |
@glenwith1n I had the same error with the try { While running The plugin expects the data in $row[$columnName] to be a JSON string formatted like Important note: This particular error will put your database in a non recoverable state, so each time before trying the migrate/all command, ensure your database is restored to a previously working state. |
I had success upgrading to Craft 4 by deleting the table |
The table My guess is that folks that run into that situation usually have the development enabled and when applying the migration issues like deprecation errors break the transaction safety net. However, this is really difficult to debug. |
Our Craft installation is almost 3 years old and we've been using the linkfield plugin since then. From what I can tell the In any case, just deleting the |
I confirm that my site is also about 3 years old and has been using this link field plugin for a long time. I will try and see if I can delete this table and get it to work. |
Another crucial point for people who might stumble onto this: If you use Craft's own db commands to backup and restore your database, ie. So if you ever (even a few years ago) ran a LinkField migration and it failed for whatever reason, you will have a @sebastian-lenz one thing I don't understand yet is that you create the |
@ marktundra Thank you this worked for me managed to get the site upgraded |
We're in the process of updating a site to Craft 4 and have hit the same issue here. I've tried the above making sure the This is the first site I've had a go updating to Craft 4 with this particular plugin. The error I get is:
I've tried getting an output like @marktundra but the migration fails further up than the JSON line.
<> |
Ran in to this problem today on a small project of mine. Fumbled around for a bit but managed to solve in the end so incase this is helpful for anyone... Started by downloading a copy of the prod database and ran my Craft 4 update locally, in DDEV with MySQL 5.7. I used LinneaHarts fork initially, which ensured the migrations completed successfully. Everything seemed fine. Then I merrily deployed to production before a MySQL error on migrations again ( Thought this was weird because I was repeating the same steps that I had just completed locally. Then discovered production was on MySQL 8 🤦. So I just uploaded my local copy of the database and everything was fine. Not entirely sure if the MySQL version was making a difference but perhaps it is to others 🙃 |
+1 same issue here - migrate/all results in a SQL-error. |
This fixed it for me in the end #261 thanks @ItsSeanvD |
Hello, I just completed all the steps to update to Craft 4, and as I completed I tried to run nitro craft migrate/all
But these are the errors I am getting. I have a feeling this is an issue regarding Linkfields inside of a SuperTable field.
*** applying m190417_202153_migrateDataToTable
> update in {{%fields}} ... done (time: 0.002s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.001s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.000s)
> update in {{%fields}} ... done (time: 0.000s)
Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_cta' in 'field list'
The SQL being executed was: SELECT
elementId
,siteId
,field_cta
FROM
stc_businesssoftwarebox
(/app/vendor/yiisoft/yii2/db/Schema.php:676)#0 /app/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'SELECT
element...') #1 /app/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT
element...')#2 /app/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /app/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /app/vendor/craftcms/cms/src/db/Query.php(153): yii\db\Query->all(NULL)
#5 /app/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(138): craft\db\Query->all()
#6 /app/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(91): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateLinkField(Object(lenz\linkfield\fields\LinkField), '{{%stc_business...', '')
#7 /app/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(224): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateField(Object(lenz\linkfield\fields\LinkField), '{{%stc_business...')
#8 /app/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(95): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateSuperTable(Object(verbb\supertable\fields\SuperTableField))
#9 /app/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(55): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateField(Object(verbb\supertable\fields\SuperTableField), '{{%content}}')
#10 /app/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(31): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateAllFields()
#11 /app/vendor/craftcms/cms/src/db/Migration.php(49): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->safeUp()
#12 /app/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#13 /app/vendor/craftcms/cms/src/console/controllers/MigrateController.php(360): yii\console\controllers\BaseMigrateController->migrateUp('m190417_202153_...')
#14 [internal function]: craft\console\controllers\MigrateController->actionAll()
#15 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#16 /app/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#17 /app/vendor/yiisoft/yii2/console/Controller.php(182): yii\base\Controller->runAction('all', Array)
#18 /app/vendor/yiisoft/yii2/base/Module.php(552): yii\console\Controller->runAction('all', Array)
#19 /app/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#20 /app/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('migrate/all', Array)
#21 /app/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#22 /app/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest(Object(craft\console\Request))
#23 /app/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#24 /app/craft(22): yii\base\Application->run()
#25 {main}
*** failed to apply m190417_202153_migrateDataToTable (time: 0.241s)
0 from 1 migrations were applied.
Migration failed. The rest of the migrations are canceled.
Error: exit status 1
The text was updated successfully, but these errors were encountered: