Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// PoolID is the ID of the pool that this template database belongs to.
PoolID string
// ConnPool is the pgxpool.Pool to use for root database connections.
ConnPool *pgxpool.Pool
// Setup is the function that sets up the template database.
Setup func(context.Context, *pgx.Conn) error
// DatabaseOwner specifies the owner for the template and test databases.
// If empty, uses the default owner (connection user).
DatabaseOwner string
}
type TemplateDB ¶
type TemplateDB struct {
// contains filtered or unexported fields
}
TemplateDB represents the template database.
func New ¶
func New(cfg *Config) (*TemplateDB, error)
New creates a new TemplateDB instance with the given configuration.
func (*TemplateDB) Cleanup ¶
func (t *TemplateDB) Cleanup(ctx context.Context) error
Cleanup drops the template database and releases any resources.
func (*TemplateDB) Create ¶
Create creates a new database using the template database and returns a pgxpool.Pool connected to the new database.
func (*TemplateDB) Name ¶
func (t *TemplateDB) Name() string
Name returns the name of the template database.
func (*TemplateDB) SanitizedName ¶
func (t *TemplateDB) SanitizedName() string
SanitizedName returns the sanitized name of the template database. This is useful for safely using the name in SQL queries.
Click to show internal directories.
Click to hide internal directories.