Skip to content

Update insert-test-data-db.md #2020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/go/primitives/insert-test-data-db.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ This can be done is several ways depending on your use case.

A straightforward way to insert test data is to conditionally insert it on startup using `go:embed` in combination with Encore's [metadata API](/docs/go/develop/metadata) control in which environments the data gets inserted. E.g. only in your local environment.

It's important to be aware that **a service has to be running** in order to connect to the database, so you **cannot perform database operations, like seeding, outside of a service**.

### Example

Create a file with your test data named `fixtures.sql`.
Then, for the service where you want to insert test data, add the following to its `.go` file in order to run on startup.

Next, for the service where you want to insert test data, add the following to its `.go` file in order to run on startup.

```
import (
Expand Down