Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( LibExecDir = "/usr/libexec" SysConfDir = "/etc" )
These variables exist to allow overwriting the paths using `go build -ldflags "-X ...", see Makefile.
var ErrSchemaNotExists = errors.New("no database schema exists")
ErrSchemaNotExists indicates that no Icinga Notifications database schema has been imported yet.
var Version = version.Version("1.0.0", "$Format:%(describe)$", "$Format:%H$")
Version contains version and Git commit information.
The placeholders are replaced on `git archive` using the `export-subst` attribute.
Functions ¶
func AcquireSchemaLock ¶ added in v1.0.0
AcquireSchemaLock acquires a named lock/advisory lock for the database schema check and import process.
Please do not pass the main database connection to this function, but a dedicated one with a maximum of 1 open connection, as the lock will be held until the connection is closed. This prevents other processes from acquiring the lock while the schema import/check is in progress.
func CheckSchema ¶ added in v1.0.0
CheckSchema verifies that the database schema version matches the expected version for the database driver.
Make sure to call AcquireSchemaLock() before calling this function to prevent concurrent schema imports.
func ImportSchema ¶ added in v1.0.0
ImportSchema imports the initial database schema from schemaDir.
It reads the schema.sql file for the database driver from schemaDir/mysql or schemaDir/pgsql and runs its statements (for PostgreSQL in a single tx). On PostgreSQL, a failed import is fully rolled back. On MySQL, DDL statements commit implicitly, so a failed import may leave a partially created schema behind.
Make sure to call AcquireSchemaLock() before calling this function to prevent concurrent schema imports.
Types ¶
This section is empty.