Skip to content

Commit e3c479e

Browse files
committed
docs(mssql): add docs for WithScripts and GetSQLCmdPath
1 parent 7714a24 commit e3c479e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/modules/mssql.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ 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+
#### Scripts
52+
53+
If you need to execute SQL scripts when the container starts, you can use `mssql.WithScripts` with one or more script file paths. The scripts will be executed in order after the container is ready.
54+
55+
```golang
56+
mssql.WithScripts("/path/to/schema.sql", "/path/to/data.sql")
57+
```
58+
59+
This will:
60+
1. Copy each script into the container
61+
2. Execute them using `sqlcmd` after the container is ready
62+
63+
#### SQL Command Path
64+
65+
The `mssql.GetSQLCmdPath` helper function returns the appropriate path to the `sqlcmd` executable based on the MS SQL Server image being used. This is used internally by the `WithScripts` option but can also be used directly if needed.
66+
67+
```golang
68+
path := mssql.GetSQLCmdPath("mcr.microsoft.com/mssql/server:2022-latest")
69+
```
70+
5171
#### Image
5272

5373
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)