Skip to content

Commit 7237bfe

Browse files
committed
docs(mssql): add docs for WithInitSQL
1 parent d664d10 commit 7237bfe

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/modules/mssql.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
4848

4949
When starting the MS SQL Server container, you can pass options in a variadic way to configure it.
5050

51+
#### Init Scripts
52+
53+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
54+
55+
If you need to execute SQL files when the container starts, you can use `mssql.WithInitSQL(files
56+
...io.Reader)` with one or more `*.sql` files. The files will be executed in order after the
57+
container is ready.
58+
59+
<!--codeinclude-->
60+
[Example of SQL script](../../modules/mssql/testdata/seed.sql)
61+
<!--/codeinclude-->
62+
63+
This will:
64+
65+
1. Copy each file into the container.
66+
2. Execute them using `sqlcmd` after the container is ready.
67+
5168
#### Image
5269

5370
If you need to set a different MS SQL Server Docker image, you can set a valid Docker image as the second argument in the `Run` function.

0 commit comments

Comments
 (0)