2

Is there any "simple" way of migrating fields and layouts from one setup to another?

Example; Two identical installations/setups have diverged, where some information on certain fields have changed (like descriptive texts and so forth), perhaps there's a SuperTable or Craft Neo field with added blocks, or even a matrix field where there's been blocks added on the one setup, that need to update exactly on the other setup. Perhaps there's been some additions to a structure's field layout. Perhaps something has been removed.

I realize this could possibly be done with some sort of plugin/migration.

The purpose of my question is basically to figure out a) if there's a simple and straight-forward way of doing so programmatically/automated, or b) if there are any plans on, or capability of setting up fields similarly to ACF for WordPress in the theme's function.php—where it can be done programmatically.

A real world usage would be; You build a set of templates (a theme, essentially), and when you update the templates (theme) and you want to apply those updates to a separate install/setup, what is the most efficient and "simple" way of doing so in Craft?

I've looked into the architect plugin, which is great for clean installs, but alas my limited php, or rather sql, knowledge makes it hard to expand into querying for field names rather than ID's. Of course there's the caveat that if you change a field's name, you probably need the ID, but if we forget that rabbit hole for a bit, is anyone sitting on any smart and simple tips for this type of approach?

Anyone had any success with FeedMe or the CraftImport plugins?

1

The Migrations

This is an ongoing issue. My best call is currently, to do the changes on production and to sync the DB locally.

I see a lot of folks, using plugins to "lock" the editing for the time, changes are being made. Sync to local, edit, resync to production.

As this is not satisfying, there was discussion with the Craft Team and the result is, for now, migrations coming to Craft 3.

https://craftcms.com/news/craft-3-content-migrations

This way you basically can create your own migrations from the command line. This should solve your problem, BUT: you should not use Craft 3 in production, yet.

Theming (off topic)

Something like theming is not possible and I think also won't be really in the future.

I solve this by having a Craft CMS dummy on github, which has most setup stuff I usually need (gruntfile, basic partials for matrices I use often). This dummy evolves over time and only includes some dummy files and folders like db.sample.php, general.sample.php and for the app a app.sample folder.

For basic content stuff I also use plugins like architect or the import/export plugin, to set up basic SEO fields and globals I usually use.

But most are missing a way to export groups etc. perfectly, but they do their job.

Hope that helps.

1

I hear ya.

The tricky thing is when it's templates distributed to people/setups for use as a platform for whatever they want to build, without them having the know-how in terms of programming or databases other than HTML/CSS.

Pushing updates in a simple way would be fantastic...

The main thing missing is essentially;

find field, global, structure, user or group or whatever is selected when exporting >

if not exist, create >

if exist compare field settings >

if name, description or type different, change one or all of the above

An easy and straightforward way of doing that...

1

Late to the table but...

I've been working on a Craft 2 site for a client that need to be able to combine a large amount of modules on each page (A matrix with 25+ blocks and counting). I found myself adding lots of complicated fields and then manually copying the information to staging and live... Tedious and dumb.

After trying several json-field import/export plugins with undesirable results (and one complete crash) I finally found Craft-CMS-Migration-Manager. It simply uses Crafts (Or Yii's) builtin migration scripts to keep your database up to sync. Works like a charm!

The plugins seems to be available for Craft 3 as well.

The plugin will generate migration files for you that you can review and commit to your repository. You then deploy to staging and/or live sites where you will be able to run them through the plugin or through the command line if you prefer.

If the migrations fails it will automatically rollback to the previous db.

Seems like the most solid way to keep your databases in sync, and you will have all relevant changes to the db committed to your repository.

Happy migrating!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.