atlas-content-modeler
atlas-content-modeler copied to clipboard
Models and taxonomies should be version-controllable as JSON
Is your feature request related to a problem? Please describe.
When defining models and taxonomies, I want to commit those definitions as JSON in version control so that others can confidently replicate the environment without depending on definitions stored in the wp_options
table.
As Atlas Content Modeler is targeting content modeling for headless WP sites, a large portion of the user base will be developers who are keen on committing changes to version control. Without the ability to define and update models in code, teams would:
- Be forced to synchronize databases in order to ensure they are working with the same models as their teammates.
- Struggle to understand when new content models have been created or updated.
- Have a difficult time performing automated testing around content models that only exist in the database.
Describe the solution you'd like
- When a model/taxonomy is created or updated using the plugin UI, those changes are reflected in a corresponding JSON file.
- Each model/taxonomy is stored in its own JSON file to minimize merge conflicts and clarify changes over time.
- e.g. If I have 2 models and 3 taxonomies defined, I should have 5 total JSON files.
- Each JSON file is named with the model/taxonomy ID to make it easier to scan changes committed to version control.
- e.g. If I have content model with a Model ID of
book
, then that model definition is stored inbook.json
. - This recommendation is based on my experience with ACF Local JSON files, which are named using numerical group IDs (
group_12345.json
) and are therefore difficult to scan for changes in commits and pull requests.
- e.g. If I have content model with a Model ID of
- The plugin looks for JSON definitions in a default directory that can be overridden via filter if needed.
- In the event of a mismatch, the plugin has the ability to determine whether the model definition in the database should take precedence over the JSON definition (see ACF Synchronized JSON functionality).
Describe alternatives you've considered
ACF Local JSON with Synchronized JSON
JSON field groups are determined ‘available for sync’ when either the JSON field group does not exist in the DB (field group key is used to match pair), or when the JSON field group contains a higher ‘modified’ value than the DB post’s modified date.
ACF is limited to storing definitions of field groups as JSON and cannot store definitions of post types and taxonomies. Atlas Content Modeler has an opportunity to improve upon this by storing each model and its fields together within a single, easy-to-read JSON file.
Custom Post Types UI Import/Export feature
In contrast to ACF, CPTUI cannot store field groups and is limited to importing/exporting type and taxonomy definitions. Importing/exporting is limited to manual migrations performed in the plugin settings screen, which means there is no JSON file that is updated over time for version control.
Additional context
Prerequisites for this feature include the ability to import/export definitions as JSON which has been mentioned in https://github.com/wpengine/atlas-content-modeler/issues/239.
+1 :slightly_smiling_face:
Internally tracking in : https://wpengine.atlassian.net/browse/MTKA-1358
+1 I love how easy it is to build the models, but that ease is also it's downfall because you're not tracking any changes via migrations. Ideally, there would be a way to "stage" changes, but I think that is probably achieved by the staging/dev env on WP Engine better than it could ever be handled in the plugin.
+++1 This is definitely a must-have. Either JSON or PHP export. With this, ACM will attract many devs who need source control.