From aa7cf294b6fabb553200c7b509347fdca0d14ec9 Mon Sep 17 00:00:00 2001 From: Richard McSharry Date: Tue, 29 Jul 2025 11:08:51 +0200 Subject: [PATCH] Update insert-test-data-db.md Make it clear that operations using the db at startup must still happen inside a service --- docs/go/primitives/insert-test-data-db.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/go/primitives/insert-test-data-db.md b/docs/go/primitives/insert-test-data-db.md index da4f14faf0..675fe6c3f1 100644 --- a/docs/go/primitives/insert-test-data-db.md +++ b/docs/go/primitives/insert-test-data-db.md @@ -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 (