Skip to content

Latest commit

 

History

History
executable file
·
16 lines (12 loc) · 1.35 KB

persistent-database-snapshot.md

File metadata and controls

executable file
·
16 lines (12 loc) · 1.35 KB

Persistent database snapshot

Sometimes it can be useful and necessery to import initial database entries to the WordPress database. The boilerplate comes with a mechanism that allows you to define tables, they get dumped into a single file and are imported automatically with the next WordPress installation.

{% hint style="info" %} It can be extremely helpful using initial imports for E2E tests. {% endhint %}

Here is a simple scenario you can adopt to your use case:

  1. yarn docker:start to start your WordPress installation
  2. Login to your WordPress instance and create a new post
  3. Define tables you want to snapshot for the startup in package.json#db:snapshot like this "db:snapshot": ["wp_posts", "wp_postmeta"]
  4. yarn db:snapshot-import-on-startup to export the defined database tables into a file in devops/scripts/startup.sql
  5. yarn docker:purge removes your current WordPress installation completely
  6. yarn docker:start again and you will see that post is immediatly available