Overview
When you create a new Statamic site, it will ask if you want to store content in flat files or in a database. If you change your mind, maybe for performance or workflow reasons, it's really easy to switch.
Moving content to the database
-
First things first, ensure your database is configured correctly. By default, Statamic sites are configured to use a SQLite database. However, you're free to change this in your
.env
:DB_CONNECTION=sqlite# DB_HOST=127.0.0.1# DB_PORT=3306# DB_DATABASE=laravel# DB_USERNAME=root# DB_PASSWORD= -
Run
php please install:eloquent-driver
. It'll install the Eloquent Driver addon, publish it's configuration file and prompt you to select the repositories you wish to move to the database.You might find it useful to keep "configuration" repositories as flat files, whilst storing the actual content in the database. For example: moving
entries
to the database but leavingcollections
flat-file. -
And that's you done! Wasn't that easy?
Change your mind?
If you change your mind about moving content to the database, you can always move it back. Just use one of the following commands to export your content back into flat-files:
- Assets:
php please eloquent:export-assets
- Blueprints and Fieldsets:
php please eloquent:export-blueprints
- Collections:
php please eloquent:export-collections
- Entries:
php please eloquent:export-entries
- Forms:
php please eloquent:export-forms
- Globals:
php please eloquent:export-globals
- Navs:
php please eloquent:export-navs
- Revisions:
php please eloquent:export-revisions
- Taxonomies:
php please eloquent:export-taxonomies
- Sites:
php please eloquent:export-sites