-
Notifications
You must be signed in to change notification settings - Fork 641
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
Running multiple content migrations fails when fields are added #2597
Comments
As a related aside, I know that I'm an early adopter here but content migrations have been pretty painful to get working with our workflow so far. At Upstatement we have a pretty smooth process with WordPress / Advanced Custom Fields that involves multiple engineers and designers working in local environments, iterating on content schemas and sync'ing them up to staging / production environments. With Craft 2 we got by with Schematic (it wasn't perfect), and I was hopeful that content migrations might be a reliable solution with Craft 3. Migrations with Django and other web frameworks are painless because they're generated from model definitions -- without that layer of abstraction it requires a lot of code and knowledge of Craft internals to be productive. Creating new sections and fields is relatively straightforward, but it gets ugly fast when you attempt to update existing field layouts, especially with more complicated field types like matrix. I threw up my hands in defeat when I was told we needed to update a matrix field in a Super Table block type in a matrix field. :) I know I'm not the first person to encounter this (#1429, #807, and more I'm sure) but FWIW I'd love to see the Craft equivalent of ACF's Local JSON feature -- multiple developers can make field / section / settings updates through the GUI, and serialize to disk and version control for synchronization, ideally both through the GUI and CLI for CI. Easily defining them in code would be nice, too, but does create a higher bar for entry, for better or worse. I'd be happy to contribute to this with code, thoughts, documentation, moral support, etc. |
@mgburns does this help? https://github.com/Pennebaker/craft-architect re: a Schematic equivalent? |
@lukeholder It's similar but lacks a few critical features for us -- namely running from the CLI. We went with Schematic over Architect for Craft 2 for many of the same reasons outlined in Pennebaker/craft-architect#7 (comment). One of the biggest gotchas with Schematic was its use of handles to uniquely identify fields. This prevents you from being able to rename existing fields. It could be worked around if you were aware of it, but I believe a complete solution to the problem should use something less volatile like a UUID. |
FWIW we are planning on making this stuff better in Craft 3.1, by moving more config stuff into config files (e.g. #1429) and using content migrations when a thing is added/removed, or its handle changes. |
Description
I'm unable to run multiple content migrations that add fields to entry type field layouts and create entries of that type successfully.
Steps to reproduce
Create two content migrations: m180317_193558_add_home_page.php and m180317_193559_add_contact_page.php
Attempt to run both of them with
php craft migrate
On the first attempt, the second migration fails:
If you run it again, the second migration will appear to have succeeded:
But the entry field content is not actually saved for either entries.
I discovered that if I switch from
$entry->{fieldHandle} = 'value'
to$entry->setFieldValue('fieldHandle', 'value')
for setting entry field content both migrations succeed on the first run, but still none of the field content appears to be saved to the content table. Possibly related: #1865.Additional info
3.0.0-RC15
7.0.27
MySQL 5.7.21
The text was updated successfully, but these errors were encountered: