Cloning & Seeding Databases

Cloning Your Database

You can clone an existing database to create a seed file. Here’s how to create one:

$ mysqldump --all-databases -u mysql -p > seed.sql
$ pg_dump -U postgres -Fc postgres -f seed.dump

Note: The default password is mysql.

You are now the proud owner of a seed.sqlseed.dump file.

Seeding Your Database

If you’re using Compose, follow the databases for Compose guide to seed your database.

  1. Open the configuration for your database by clicking the gear icon next to its name, and select the Dockerfile tab.

  2. Open the file menu by clicking the + icon in the file browser and select Upload File.

  3. Select and upload your seed.sqlseed.dump file to your container.

  4. In the file editor, uncomment the ADD command and replace [src] with the path to your dump file, relative to your Dockerfile:

ADD [src] /seed.sql
ADD [src] /seed.dump

Note: Do not modify the destination /seed.sql/seed.dump; it’s required to for the initialization script.

Your seeded database will now be created for all new builds.

What’s Next?