Documentation
¶
Index ¶
- Constants
- func ApplyMigrations(db *sql.DB) error
- func CheckIfMigrationExists(db *sql.Tx, migration string, args ...interface{}) (bool, error)
- func GetColumnNames(databaseName string, exclude ...string) []string
- func GetColumnNamesForCSNIs(exclude ...string) []string
- func GetColumnNamesForConnectedEndpoints(exclude ...string) []string
- func GetColumnNamesForTokens(exclude ...string) []string
- func GetColumnNamesForVersions(exclude ...string) []string
- func GetConnection(dc DatabaseConfig, env *env.VarSet) (*sql.DB, error)
- func GetInMemorySQLLiteConnection() (*sql.DB, error)
- func ModifySQLStatement(sql string, databaseProvider string) string
- func NewGooseDBConf(dc DatabaseConfig, env *env.VarSet) (*sql.DB, error)
- func ParseCFEnvs(db *DatabaseConfig, env *env.VarSet) (bool, error)
- func Ping(db *sql.DB) error
- func Up20170818120003(txn *sql.Tx) error
- func Up20170818162837(txn *sql.Tx) error
- func Up20170829154900(txn *sql.Tx) error
- func Up20171108102900(txn *sql.Tx) error
- func Up20180413135700(txn *sql.Tx) error
- func Up20180627111300(txn *sql.Tx) error
- func Up20180703142800(txn *sql.Tx) error
- func Up20180813110300(txn *sql.Tx) error
- func Up20180824092600(txn *sql.Tx) error
- func Up20180831104300(txn *sql.Tx) error
- func Up20180907123000(txn *sql.Tx) error
- func Up20181129140500(txn *sql.Tx) error
- func Up20190305144600(txn *sql.Tx) error
- func Up20190515133200(txn *sql.Tx) error
- func Up20190522121200(txn *sql.Tx) error
- func Up20190621212700(txn *sql.Tx) error
- func Up20190918092300(txn *sql.Tx) error
- func Up20190930092500(txn *sql.Tx) error
- func Up20191008121900(txn *sql.Tx) error
- func Up20200117152200(txn *sql.Tx) error
- func Up20200814140918(txn *sql.Tx) error
- func Up20200902162200(txn *sql.Tx) error
- func Up20201201163100(txn *sql.Tx) error
- func Up20210201110000(txn *sql.Tx) error
- func Up20240818042100(txn *sql.Tx) error
- func WaitForMigrations(db *sql.DB) error
- type DatabaseConfig
- type SSLValidationMode
- type VCAPService
Constants ¶
const ( SERVICES_ENV = "VCAP_SERVICES" STRATOS_TAG = "stratos" URI_POSTGRES = "postgres://" URI_MYSQL = "mysql://" TAG_MYSQL = "mysql" TAG_POSTGRES = "postgresql" DB_URI = "uri" )
const ( // SQLite DB Provider SQLITE string = "sqlite" // PGSQL DB Provider PGSQL = "pgsql" // MYSQL DB Provider MYSQL = "mysql" // TimeoutBoundary is the max time in minutes to wait for the DB Schema to be initialized TimeoutBoundary = 10 )
const ( // PGSQL SSL Modes // SSLDisabled means no checking of SSL SSLDisabled SSLValidationMode = "disable" // SSLRequired requires SSL without validation SSLRequired SSLValidationMode = "require" // SSLVerifyCA verifies the CA certificate SSLVerifyCA SSLValidationMode = "verify-ca" // SSLVerifyFull verifies the certificate and hostname and the CA SSLVerifyFull SSLValidationMode = "verify-full" // SQLiteSchemaFile - SQLite schema file SQLiteSchemaFile = "./deploy/db/sqlite_schema.sql" // SQLiteDatabaseFile - SQLite database file SQLiteDatabaseFile = "console-database.db" // DefaultDatabaseProvider is the efault database provider when not specified DefaultDatabaseProvider = MYSQL )
const ( // UniqueConstraintViolation is the error code for a unique constraint violation UniqueConstraintViolation = 23505 // DefaultConnectionTimeout is the default to timeout on connections DefaultConnectionTimeout = 10 )
Variables ¶
This section is empty.
Functions ¶
func ApplyMigrations ¶
ApplyMigrations will perform the migrations
func CheckIfMigrationExists ¶
func GetColumnNames ¶
func GetColumnNamesForCSNIs ¶
func GetColumnNamesForTokens ¶
func GetConnection ¶
GetConnection returns a database connection to either MySQL, PostgreSQL or SQLite
func GetInMemorySQLLiteConnection ¶
GetInMemorySQLLiteConnection returns an SQLite DB Connection
func ModifySQLStatement ¶
ModifySQLStatement - Modify the given DB statement for the specified provider, as appropraite e.g Postgres uses $1, $2 etc SQLite uses ?
func NewGooseDBConf ¶
NewGooseDBConf creates a new Goose config for database migrations
func ParseCFEnvs ¶
func ParseCFEnvs(db *DatabaseConfig, env *env.VarSet) (bool, error)
Discover cf db services via their 'uri' env var and apply settings to the DatabaseConfig objects
func Up20170818120003 ¶
func Up20170818162837 ¶
func Up20170829154900 ¶
func Up20171108102900 ¶
func Up20180413135700 ¶
func Up20180627111300 ¶
func Up20180703142800 ¶
func Up20180813110300 ¶
func Up20180824092600 ¶
func Up20180831104300 ¶
func Up20180907123000 ¶
func Up20181129140500 ¶
func Up20190305144600 ¶
func Up20190515133200 ¶
func Up20190522121200 ¶
func Up20190621212700 ¶
func Up20190918092300 ¶
func Up20190930092500 ¶
func Up20191008121900 ¶
func Up20200117152200 ¶
func Up20200814140918 ¶
func Up20200902162200 ¶
func Up20201201163100 ¶
func Up20210201110000 ¶
func Up20240818042100 ¶
func WaitForMigrations ¶
WaitForMigrations will wait until all migrations have been applied
Types ¶
type DatabaseConfig ¶
type DatabaseConfig struct { DatabaseProvider string `configName:"DATABASE_PROVIDER"` Username string `configName:"DB_USER"` Password string `configName:"DB_PASSWORD"` Database string `configName:"DB_DATABASE_NAME"` Host string `configName:"DB_HOST"` Port int `configName:"DB_PORT"` SSLMode string `configName:"DB_SSL_MODE"` ConnectionTimeoutInSecs int `configName:"DB_CONNECT_TIMEOUT_IN_SECS"` SSLCertificate string `configName:"DB_CERT"` SSLKey string `configName:"DB_CERT_KEY"` SSLRootCertificate string `configName:"DB_ROOT_CERT"` }
DatabaseConfig represents the connection configuration parameters
func NewDatabaseConnectionParametersFromConfig ¶
func NewDatabaseConnectionParametersFromConfig(dc DatabaseConfig) (DatabaseConfig, error)
NewDatabaseConnectionParametersFromConfig setup database connection parameters based on contents of config struct
type SSLValidationMode ¶
type SSLValidationMode string
SSLValidationMode is the PostgreSQL driver SSL validation modes
type VCAPService ¶
Source Files
¶
- 20170818120003_InitialSchema.go
- 20170818162837_SetupSchema.go
- 20170829154900_TokenDisconnected.go
- 20171108102900_AuthType.go
- 20180413135700_MetricsSchema.go
- 20180627111300_UpdateMetadata.go
- 20180703142800_CFClient.go
- 20180813110300_RemoveStaleTokens.go
- 20180824092600_LinkedTokens.go
- 20180831104300_SSOEndpointFlag.go
- 20180907123000_SSOSetupFlag.go
- 20181129140500_UserFavorites.go
- 20190305144600_EndpointSubtype.go
- 20190515133200_AuthEndpoint.go
- 20190522121200_LocalUsers.go
- 20190621212700_ConfigSchema.go
- 20190918092300_LocalUsersUpdates.go
- 20190930092500_LocalUsersTriggerFix.go
- 20191008121900_PrimaryKeys.go
- 20200117152200_SesssionData.go
- 20200814140918_ApiKeys.go
- 20200902162200_HelmSubtype.go
- 20201201163100_EndpointCACert.go
- 20210201110000_Creator.go
- 20240818042100_RetryEndpointCACert.go
- database_cf_config.go
- datastore.go
- datastore_migrator.go