Let's learn what content migrations are and when we can use them in Craft CMS.
Content migrations in Craft CMS are data migrations that are project-specific. You create them to be run on an instance of Craft CMS and to do something like add content, create users, sections, fields, and more.
Content migrations are different from Craft’s app migrations, which allow Craft to run database changes during updates and upgrade to the application. Content migrations are also different from plugin migrations, which is how the plugins you have installed alter your database during installation and removal and change their database tables during an update.
Think about content migrations as migrations that you fully control as part of your project. All of them are based on Yii’s migrations, but Craft has three different types, so different use cases can be met.
What are some examples of what I’d use content migrations for?
For this course we’re going to learn how to use Content Migrations while building a set of migrations to set up a contact form in our Craft installation.
Our contact form will consist of:
When we are done we will have a single migration file that will bundle up the entire contact form functionality (outside of the front-end template implementation) so it’s easy to install in a Craft project.
Let’s get started by building our first migration file.