Documentation
¶
Overview ¶
Package dbcheck provides utilities for classifying database errors.
Index ¶
Constants ¶
const ( DBTypePostgres = "postgres" DBTypePostgreSQL = "postgresql" DBTypeOracle = "oracle" DBTypeMySQL = "mysql" DBTypeSQLServer = "sqlserver" DBTypeSQLite = "sqlite" )
Database type constants used across the package.
Variables ¶
This section is empty.
Functions ¶
func ExpectedTableNames ¶
func ExpectedTableNames() []string
ExpectedTableNames returns the list of table names that TMI expects to exist. This is a hardcoded list derived from api/models — kept in sync manually. Using a hardcoded list avoids importing the models package (which pulls in GORM) and makes this package lightweight for use in both the server and dbtool. SEM@e93cc27eac1d842461899300fefcaebc977cb3db: return the hardcoded list of table names the application schema requires (pure)
func IsPermissionError ¶
IsPermissionError returns true if the given error indicates insufficient database privileges for DDL operations (CREATE TABLE, ALTER TABLE, etc.).
This is used by the server startup to distinguish "schema needs migration but user lacks DDL permissions" from other migration errors. SEM@e93cc27eac1d842461899300fefcaebc977cb3db: validate whether a DB error represents insufficient DDL privileges for the given database type (pure)
Types ¶
type SchemaHealthResult ¶
type SchemaHealthResult struct {
DatabaseType string `json:"database_type"`
DatabaseVersion string `json:"database_version"`
ExpectedTables int `json:"expected_tables"`
PresentTables int `json:"present_tables"`
MissingTables []string `json:"missing_tables,omitempty"`
}
SchemaHealthResult reports the state of the database schema. SEM@e93cc27eac1d842461899300fefcaebc977cb3db: report of expected vs present database tables and the database version (pure)
func CheckSchemaHealth ¶
func CheckSchemaHealth(sqlDB *sql.DB, dbType string) (*SchemaHealthResult, error)
CheckSchemaHealth queries the database to determine which expected tables exist. Works across PostgreSQL, Oracle, MySQL, SQL Server, and SQLite. SEM@e93cc27eac1d842461899300fefcaebc977cb3db: query the database to identify missing schema tables and return a health report (reads DB)
func (*SchemaHealthResult) IsCurrent ¶
func (r *SchemaHealthResult) IsCurrent() bool
IsCurrent returns true if all expected tables are present. SEM@e93cc27eac1d842461899300fefcaebc977cb3db: report whether all expected schema tables are present (pure)