0

I recently started a project where I inherited a fully functional website and the owner asked me to perform some tweaks. I started by making a duplicate of both the codebase and the database into a separate environment for development.

One of the features was to create a new page and add it to the navigation. So I went like this:

  1. Configure the stuff in my development admin panel
  2. Have them validated
  3. Configured the same stuff in the production admin panel
  4. Publish them. Everybody happy

(I am aware that we are skipping a part where a testing environment would be suitable, but that's beyond the point)

On to the next feature, which included some code changes. Upon starting to code, I noticed a change in my project.yaml file from the last feature. So I committed it into Git, since someone from P&T posted that's what I should do :)

So, here I am, applying the change in project.yaml to my production environment (overwriting the file there), and I get this error with the stacktrace pointing to craft\web\Application->_processConfigSyncLogic(). Luckily I have a backup from which I can restore, and then the site is operational again.

I guess I introduced a conflict somewhere by applying the changes both in the production admin portal and in the project.yaml, resulting in different identifiers in the databases and such. This makes sense in retrospect (although I don't like the redundancy that we have here), but since I am still finding my way around Craft CMS, it's a mistake I was bound made and I want to fix.

Could anyone please give me some pointers on how to resolve my problem? Thanks a lot!

EDIT: maybe I should mention that the current CraftCMS version is 3.3.15 - should this issue have been resolved in an update since then. Updating the Craft CMS is on the roadmap after having the urgencies fixed.

1 Answer 1

2

I suggest adopting one environment as the primary, in your case it's probably production, and then use that database and config files as your starting point.

The Craft CMS docs walk through it here: https://craftcms.com/docs/4.x/project-config.html#adopting-project-config

The Craft CMS team created project config to make it simpler to move configuration and settings between environments. Practically speaking, this means you can create a new section and fields in your local development environment, saved in your project config files, and then deploy those changes to another environment without needing to redo work in other environments. Craft checks the config files and applies changes (or you can run a console command to apply them on deploy).

1
  • Hey, thanks for answering. I suppose indeed re-forking the development database and project.yaml from production is the best way to move forward now. Just to make sure: next time, I should apply the changes in the development admin CP, pull the project.yaml into production and Craft will automatically apply them (including the content)?
    – gleerman
    Oct 19, 2022 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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