1

We have previously used the Schematic plugin for database import inside a Docker container for a Python script. This is the command used for the importing,

$/data/craft/craft schematic/export --file=schema.yml

The /data/craft/craft means we run the command inside the preceding folder and the command itself is schematic/export --file=schema.yml. The file schema.yml has the database definition.

How do you import and export the databases using the Craft 3.1.x?

Now we use the Craft 3.1 which doesn't work with the Schematic. I have this project config file after we upgraded to the Craft 3,

dateModified: 1552904208
plugins:
  aws-s3:
    edition: standard
    enabled: true
    schemaVersion: '1.2'
  redactor:
    edition: standard
    enabled: true
    schemaVersion: 2.2.2
  • It depends what you want... do you want to import a database or do you want to sync settings such as sections/categories/product types? Craft has actually nothing to do with your DB interface. You can import a DB via mysql command. mysql -u username -p database_name < file.sql – Robin Schambach Mar 18 at 10:58
  • I would prefer to import and export for this task. However, it would be also great if you tell me how do I sync the settings as well. – Arefe Mar 18 at 11:05
  • We use the MySQL and Postgresql for the databases. So, I guess I will get a SQL file in the local machine after I import the database? – Arefe Mar 18 at 11:06
2

For syncing your database in Craft 3 you can use the Project Config please read the instructions in the link how to use it and what it does

Once that’s enabled, Craft will start storing the project config in a config/project.yaml file. Any time something changes that is managed by the project config, that file will get updated to match. And any time Craft detects that project.yaml has been updated on its own (e.g. if it was changed in a Git commit that was recently pulled down), any changes in it will be propagated to the local Craft install.

So store the file in your directory and Craft will do the rest

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.