Closed shyam-icode-developer closed 4 years ago
@shyam089 which version of Craft and which version of Migration Manager are you running.
craft cms(3.5.8) and migration assistant(3.1.9)
in your log file can you find the error and send me the details above that line that point to the file/line number.
Also, what type of field are you trying to migrate? Or it this happening with all of them?
Its happening with all kinds of fields. Whenever we link any field in section and try to migrate both. Its not migrating in other systems. Can you tell me which log file should I look for this error?
storage/logs/web.log
Is this happening when you are creating the migrations on the source system or when you are running the migration on the destination system?
Its coming when we run the migrations in the destination system. Give me a minute I'm sending the logs.
2020-09-04 07:20:33 [-][1][88nbcnhn7p2ta4ejmns9le7te7][trace][yii\db\Transaction::rollBack] Roll back transaction 2020-09-04 07:20:33 [-][1][88nbcnhn7p2ta4ejmns9le7te7][error][craft\db\MigrationManager::migrateUp] Failed to apply m200902_052941_migration_lunch_tips (time: 0.107s). Output: Exception: Setting unknown property: craft\fieldlayoutelements\CustomField::fieldHandle (/var/www/html/bleckmann_pwa/backend/vendor/yiisoft/yii2/base/BaseObject.php:163)
These are the logs I found where the transaction was rolled back to previous state. Let me know if you need some more information.
I would really appreciate your help.
Has the destination system been updated to latest Craft version before running the migrations?
Yes both systems are running on same craft version.
Can you provide more lines from the log files, after lines #0 - #8 so I can see where the error is originating.
Below is the track till #32, it's having.
2020-09-04 07:20:33 [-][1][88nbcnhn7p2ta4ejmns9le7te7][trace][yii\db\Transaction::rollBack] Roll back transaction 2020-09-04 07:20:33 [-][1][88nbcnhn7p2ta4ejmns9le7te7][error][craft\db\MigrationManager::migrateUp] Failed to apply m200902_052941_migration_lunch_tips (time: 0.107s). Output: Exception: Setting unknown property: craft\fieldlayoutelements\CustomField::fieldHandle (/var/www/html/bleckmann_pwa/backend/vendor/yiisoft/yii2/base/BaseObject.php:163)
@shyam089 try release 3.2.0
thanks @dgrigg , I will install and try once. Really appreciate your help and time.
Hi @dgrigg , I tried your latest release 3.2.0 but its showing something else now.. An error occurred while executing the "craft\contentmigrations\m200904_090855_migration_mail_template migration: Trying to get property 'uid' of non-object
Below you can find the stack trace for the same, 2020-09-04 22:59:27 [-][1][-][error][craft\db\MigrationManager::migrateUp] Failed to apply m200904_090855_migration_mail_template (time: 0.515s). Output: Exception: Trying to get property 'uid' of non-object (/var/www/html/bcrew_test/backend/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php:98)
@shyam089 does the field(s) that are in the section you are trying to migrate exist on the destination site? Is it possible you are doing a section migration before migrating the fields?
I created the single migration file by selecting fields as well as there respective sections also from both tabs. I'm not sure if plugin is applying the sections handler first while importing.
try doing two separate migrations, one for the fields first and then one for the sections second
OK, Just give me 2 mins.I will try that one.
@dgrigg , I tried doing it separately but its working only if my fields are not linked to the sections, In case If its linked already then even if we do migrations seprately, its throwing error like that section is missing.
In this scenario, what happens we need to link our fields manually then in the destination system. But previously with craft 3.4.8 and migration-assistant 3.1.8 it used migrate both simultaneously without issues.
Let me see what I can do. Craft 3.5 has introduced a few changes that are proving tricky to work around.
Yes, I too saw some database changes has come, so I was in contact with one of the craft support member as well, if he can help me. I would really be thankful for your help and support.
One more question. Is the field that links to a section, linking to the section that it is a field in (like a circular reference).
ie Field['sectionField']['section'] = 'SectionA'
Section['SectionA']['fields'] = ['title', 'sectionField', 'someOtherField']
@dgrigg , No Its not circular linking in my case, But if I see my migrations files which I created only for fields, its mentioned "typesettings":{"sources":["tokenSection"] , like the field is linked to some section, hence if I run migrations first for the field, it will throw error that section is not found so I have to first run for sections then only fields will be migrated.
For refrence you can check my both fields and sections migrations here.
{"settings":{"dependencies":[],"elements":{"fields":[{"group":"Email Templates","name":"Mail Template Handler","handle":"mailTemplateHandler","instructions":"","translationMethod":"language","translationKeyFormat":null,"required":null,"searchable":true,"type":"craft\fields\PlainText","typesettings":{"uiMode":"normal","placeholder":"handler name","code":"","multiline":"","initialRows":"4","charLimit":null,"byteLimit":null,"columnType":null}},{"group":"Email Templates","name":"MailContent","handle":"mailcontent","instructions":"","translationMethod":"site","translationKeyFormat":null,"required":null,"searchable":true,"type":"craft\fields\Matrix","typesettings":{"minBlocks":"1","maxBlocks":"1","contentTable":"{{%matrixcontent_mailcontent}}","propagationMethod":"all","blockTypes":{"new1":{"name":"Mail Content Section","handle":"mailcontentblock","fields":{"new1":{"name":"Subject","handle":"subject","instructions":"","required":true,"type":"craft\fields\PlainText","translationMethod":"language","translationKeyFormat":null,"typesettings":{"uiMode":"normal","placeholder":"Add your subject","code":"","multiline":"","initialRows":"4","charLimit":null,"byteLimit":null,"columnType":null}},"new2":{"name":"Body","handle":"body","instructions":"","required":false,"type":"craft\redactor\Field","translationMethod":"language","translationKeyFormat":null,"typesettings":{"uiMode":"enlarged","redactorConfig":"Standard.json","purifierConfig":"","cleanupHtml":true,"removeInlineStyles":"","removeEmptyTags":"","removeNbsp":"","purifyHtml":"","columnType":"text","availableVolumes":"","availableTransforms":"","showUnpermittedVolumes":false,"showUnpermittedFiles":false,"showHtmlButtonForNonAdmins":true,"configSelectionMode":"choose","manualConfig":"","defaultTransform":""}},"new3":{"name":"MailContentTokens","handle":"mailcontenttokens","instructions":"","required":false,"type":"craft\fields\Entries","translationMethod":"site","translationKeyFormat":null,"typesettings":{"sources":["tokenSection"],"source":null,"targetSiteId":null,"viewMode":null,"limit":"","selectionLabel":"Select token","showSiteMenu":true,"localizeRelations":false,"validateRelatedElements":false,"allowSelfRelations":false}}}}}}},{"group":"Email Templates","name":"Token Description","handle":"tokenDescription","instructions":"","translationMethod":"language","translationKeyFormat":null,"required":null,"searchable":true,"type":"craft\fields\PlainText","typesettings":{"uiMode":"normal","placeholder":"Add token (starts with ! , ex: !url)","code":"","multiline":"","initialRows":"4","charLimit":null,"byteLimit":null,"columnType":null}}]}}}
Next this one is for the sections: {"settings":{"dependencies":{"sections":[{"name":"Mail Content Section","handle":"mailContentSection","type":"channel","enableVersioning":true,"propagationMethod":"all","sites":{"default":{"site":"default","hasUrls":true,"uriFormat":"mail-content-section/{slug}","enabledByDefault":true,"template":null},"bcrewNl":{"site":"bcrewNl","hasUrls":true,"uriFormat":"mail-content-section/{slug}","enabledByDefault":true,"template":null},"bcrewFr":{"site":"bcrewFr","hasUrls":true,"uriFormat":"mail-content-section/{slug}","enabledByDefault":true,"template":null}},"entrytypes":[{"sectionHandle":"mailContentSection","hasTitleField":true,"name":"Mail Content Section","handle":"mailContentSection","requiredFields":[],"fieldLayouts":{"tabs":[{"name":"Content","sortOrder":1,"elements":[{"type":"craft\fieldlayoutelements\EntryTitleField","autocomplete":false,"class":null,"size":null,"name":null,"autocorrect":true,"autocapitalize":true,"disabled":false,"readonly":false,"title":null,"placeholder":null,"step":null,"min":null,"max":null,"requirable":false,"id":null,"containerAttributes":[],"inputContainerAttributes":[],"labelAttributes":[],"orientation":null,"label":"Mail template","instructions":"","tip":null,"warning":null,"width":100}]}]}}]},{"name":"Token Section","handle":"tokenSection","type":"channel","enableVersioning":true,"propagationMethod":"all","sites":{"default":{"site":"default","hasUrls":true,"uriFormat":"token-section/{slug}","enabledByDefault":true,"template":null},"bcrewNl":{"site":"bcrewNl","hasUrls":true,"uriFormat":"token-section/{slug}","enabledByDefault":true,"template":null},"bcrewFr":{"site":"bcrewFr","hasUrls":true,"uriFormat":"token-section/{slug}","enabledByDefault":true,"template":null}},"entrytypes":[{"sectionHandle":"tokenSection","hasTitleField":true,"titleFormat":"{tokens}","name":"Tokens","handle":"tokens","requiredFields":[],"fieldLayouts":{"tabs":[{"name":"token content","sortOrder":1,"elements":[{"type":"craft\fieldlayoutelements\EntryTitleField","autocomplete":false,"class":null,"size":null,"name":null,"autocorrect":true,"autocapitalize":true,"disabled":false,"readonly":false,"title":null,"placeholder":null,"step":null,"min":null,"max":null,"requirable":false,"id":null,"containerAttributes":[],"inputContainerAttributes":[],"labelAttributes":[],"orientation":null,"label":"Token","instructions":"Start with !","tip":null,"warning":null,"width":100}]}]}}]}]},"elements":{"sections":[{"name":"Mail Content Section","handle":"mailContentSection","type":"channel","enableVersioning":true,"propagationMethod":"all","sites":{"default":{"site":"default","hasUrls":true,"uriFormat":"mail-content-section/{slug}","enabledByDefault":true,"template":null},"bcrewNl":{"site":"bcrewNl","hasUrls":true,"uriFormat":"mail-content-section/{slug}","enabledByDefault":true,"template":null},"bcrewFr":{"site":"bcrewFr","hasUrls":true,"uriFormat":"mail-content-section/{slug}","enabledByDefault":true,"template":null}},"entrytypes":[{"sectionHandle":"mailContentSection","hasTitleField":true,"name":"Mail Content Section","handle":"mailContentSection","requiredFields":[],"fieldLayouts":{"tabs":[{"name":"Content","sortOrder":1,"elements":[{"type":"craft\fieldlayoutelements\EntryTitleField","autocomplete":false,"class":null,"size":null,"name":null,"autocorrect":true,"autocapitalize":true,"disabled":false,"readonly":false,"title":null,"placeholder":null,"step":null,"min":null,"max":null,"requirable":false,"id":null,"containerAttributes":[],"inputContainerAttributes":[],"labelAttributes":[],"orientation":null,"label":"Mail template","instructions":"","tip":null,"warning":null,"width":100}]}]}}]},{"name":"Token Section","handle":"tokenSection","type":"channel","enableVersioning":true,"propagationMethod":"all","sites":{"default":{"site":"default","hasUrls":true,"uriFormat":"token-section/{slug}","enabledByDefault":true,"template":null},"bcrewNl":{"site":"bcrewNl","hasUrls":true,"uriFormat":"token-section/{slug}","enabledByDefault":true,"template":null},"bcrewFr":{"site":"bcrewFr","hasUrls":true,"uriFormat":"token-section/{slug}","enabledByDefault":true,"template":null}},"entrytypes":[{"sectionHandle":"tokenSection","hasTitleField":true,"titleFormat":"{tokens}","name":"Tokens","handle":"tokens","requiredFields":[],"fieldLayouts":{"tabs":[{"name":"token content","sortOrder":1,"elements":[{"type":"craft\fieldlayoutelements\EntryTitleField","autocomplete":false,"class":null,"size":null,"name":null,"autocorrect":true,"autocapitalize":true,"disabled":false,"readonly":false,"title":null,"placeholder":null,"step":null,"min":null,"max":null,"requirable":false,"id":null,"containerAttributes":[],"inputContainerAttributes":[],"labelAttributes":[],"orientation":null,"label":"Token","instructions":"Start with !","tip":null,"warning":null,"width":100}]}]}}]}]}}}
@shyam089 I just pushed some updates (3.2.1). I think the issue is the order of migrations. I was able to make the error happen locally and following the steps below worked to prevent the error. The problem is the order of fields/sections existing in Craft and what happens internally if a field/section fails validation when saving.
Try the following in instances where you have a field that contains a reference to a section.
On the destination server run each migration independently by selecting each one (in the order from above) and running it in the 'Pending Migrations' list.
@dgrigg , Thanks for your time, I will try it the way the you suggested to see if its successfully migrating.
@dgrigg , Thank you much the issue is resolved now and its migrating again.
Hi Team,
We are facing issues when we upgrade our craft to the latest version and also the migration assistant but there seems to be some incompatibility in between the two.
We are always getting the below issue: The site has been restored to the state it was in before the attempted migration.
An error occurred while executing the "craft\contentmigrations\m200903_004207_migration_navigation_items migration: Setting unknown property: craft\fieldlayoutelements\CustomField::fieldHandle
This issue has been seen mainly when we link fields with layouts and then try to migrate the changes.
Please can you help us in resolving this issue.
Many thanks in advance.