Skip to content

Commit

Permalink
docs(mssql): add docs for WithScripts and GetSQLCmdPath
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasMTS committed Feb 18, 2025
1 parent f8ce3e2 commit 9b6362b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/modules/mssql.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom

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

#### Scripts

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.

```golang
mssql.WithScripts("/path/to/schema.sql", "/path/to/data.sql")
```

This will:
1. Copy each script into the container
2. Execute them using `sqlcmd` after the container is ready

#### SQL Command Path

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.

```golang
path := mssql.GetSQLCmdPath("mcr.microsoft.com/mssql/server:2022-latest")
```

#### Image

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.
Expand Down

0 comments on commit 9b6362b

Please sign in to comment.