common

package
v1.6.66-0...-d8d7c7a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCEDBVersion

func CheckCEDBVersion(dc *DBConfig) error

func CheckCEDBVersionTableExists

func CheckCEDBVersionTableExists(dc *DBConfig) (bool, error)

func CheckDBVersion

func CheckDBVersion(dc *DBConfig, tableName string, expectedVersion string) error

func CheckTableExists

func CheckTableExists(dc *DBConfig, tableName string) (bool, error)

func CreateDatabase

func CreateDatabase(dc *DBConfig) error

func CreateDatabaseIfNotExists

func CreateDatabaseIfNotExists(dc *DBConfig) (bool, error)

func DropDatabase

func DropDatabase(dc *DBConfig) error

func DropDatabaseIfInitTablesFailed

func DropDatabaseIfInitTablesFailed(dc *DBConfig, editionFunc EditionInitTablesFunc) error

func ExecuteCEIssues

func ExecuteCEIssues(dc *DBConfig, curVersion string) error

func ExecuteIssues

func ExecuteIssues(dc *DBConfig, curVersion string, rawSqlDir string) error

func GetCEDBVersion

func GetCEDBVersion(dc *DBConfig) (string, error)

func GetDBVersion

func GetDBVersion(dc *DBConfig, tableName string) (string, error)

func GetDBVersionDDLFile

func GetDBVersionDDLFile(rawSqlDir string) string

GetDBVersionDDLFile returns the *_db_version.sql file path in the rawSqlDir.

func GetSortedSQLFiles

func GetSortedSQLFiles(parentDir string, defaultDB bool) []string

AI code GetSortedSQLFiles returns the .sql files in the target directory sorted by these rules: 1. Files starting with ddl_ come before files starting with dml_. 2. Within ddl_ files: those containing create_table run first, those containing create_trigger run last, any other ddl_* files are in between. 3. If defaultDB is true, only files starting with default_db_ are considered; that prefix is stripped for applying the same sorting rules.

func InitCETables

func InitCETables(dc *DBConfig) error

func InitDBVersionTable

func InitDBVersionTable(dc *DBConfig, rawSqlDir string) error

func InitTables

func InitTables(dc *DBConfig, rawSqlDir string) error

func InsertDBVersion

func InsertDBVersion(dc *DBConfig, tableName string, version string) error

func LogDBName

func LogDBName(databaseName string, format string, a ...any) string

func ReadAndExecuteSqlFile

func ReadAndExecuteSqlFile(dc *DBConfig, sqlFile string) error

Types

type DBConfig

type DBConfig struct {
	DB     *gorm.DB
	Config config.Config
	SqlFmt types.SQLAdapter
}

func NewDBConfig

func NewDBConfig(db *gorm.DB, cfg config.Config) *DBConfig

func (*DBConfig) GetDatabaseName

func (dc *DBConfig) GetDatabaseName() string

func (*DBConfig) SetConfig

func (dc *DBConfig) SetConfig(c config.Config)

func (*DBConfig) SetDB

func (dc *DBConfig) SetDB(db *gorm.DB)

type EditionInitTablesFunc

type EditionInitTablesFunc func(dc *DBConfig) error // TODO

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL