# WithCreationScript

- Module: [Aspire.Hosting.PostgreSQL](/reference/api/go/aspire.hosting.postgresql.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`PostgresDatabaseResource`](/reference/api/go/aspire.hosting.postgresql/postgresdatabaseresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Defines the SQL script used to create the database.

## Remarks

The script can only contain SQL statements applying to the default database like CREATE DATABASE. Custom statements like table creation
and data insertion are not supported since they require a distinct connection to the newly created database.
Default script is
```
CREATE DATABASE "<QUOTED_DATABASE_NAME>"
```

## Definition

```go
func (PostgresDatabaseResource) WithCreationScript(script string) PostgresDatabaseResource
```

## Parameters

- `script` (`string`) -- The SQL script used to create the database.

## Returns

[`PostgresDatabaseResource`](/reference/api/go/aspire.hosting.postgresql/postgresdatabaseresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`PostgresDatabaseResource`](/reference/api/go/aspire.hosting.postgresql/postgresdatabaseresource.md)
