Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayEqual(arrayA, arrayB []int) bool
- func ClearHTTPAuthProxyUsers() error
- func ClearTable(table string) error
- func ExecuteBatchSQL(sqls []string)
- func GetOrmer() orm.Ormer
- func InitDatabase(database *models.Database) error
- func JoinNumberConditions(ids []int) string
- func NewMigrator(database *models.PostGreSQL) (*migrate.Migrate, error)
- func PrepareTestData(clearSqls []string, initSqls []string)
- func PrepareTestForPostgresSQL()
- func PrepareTestForSQLite()
- func UpgradeSchema(database *models.Database) error
- type Database
Constants ¶
const (
// NonExistUserID : if a user does not exist, the ID of the user will be 0.
NonExistUserID = 0
)
Variables ¶
var ErrDupRows = errors.New("sql: duplicate row in DB")
ErrDupRows is returned by DAO when inserting failed with error "duplicate key value violates unique constraint"
Functions ¶
func ClearHTTPAuthProxyUsers ¶
func ClearHTTPAuthProxyUsers() error
ClearHTTPAuthProxyUsers remove the records from harbor_users to delete all user imported via HTTP Auth Proxy
func ClearTable ¶
ClearTable is the shortcut for test cases, it should be called only in test cases.
func InitDatabase ¶
InitDatabase registers the database
func JoinNumberConditions ¶
JoinNumberConditions - To join number condition into string,used in sql query
func NewMigrator ¶
func NewMigrator(database *models.PostGreSQL) (*migrate.Migrate, error)
NewMigrator creates a migrator base on the information
func PrepareTestData ¶
PrepareTestData -- Clean and Create data
func PrepareTestForPostgresSQL ¶
func PrepareTestForPostgresSQL()
PrepareTestForPostgresSQL is for test only.
func UpgradeSchema ¶
UpgradeSchema will call the internal migrator to upgrade schema based on the setting of database.
Types ¶
type Database ¶
type Database interface { // Name returns the name of database Name() string // String returns the details of database String() string // Register registers the database which will be used Register(alias ...string) error // UpgradeSchema upgrades the DB schema to the latest version UpgradeSchema() error }
Database is an interface of different databases