migrator

package
v0.0.0-testrgm6 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: AGPL-3.0 Imports: 16 Imported by: 556

Documentation

Index

Constants

View Source
const (
	Postgres = "postgres"
	SQLite   = "sqlite3"
	MySQL    = "mysql"
	MSSQL    = "mssql"
)
View Source
const (
	IndexType = iota + 1
	UniqueIndex
)

Variables

View Source
var (
	ErrLockDB        = fmt.Errorf("failed to obtain lock")
	ErrReleaseLockDB = fmt.Errorf("failed to release lock")
)
View Source
var (
	ErrMigratorIsLocked   = fmt.Errorf("migrator is locked")
	ErrMigratorIsUnlocked = fmt.Errorf("migrator is unlocked")
)
View Source
var (
	DB_Bit       = "BIT"
	DB_TinyInt   = "TINYINT"
	DB_SmallInt  = "SMALLINT"
	DB_MediumInt = "MEDIUMINT"
	DB_Int       = "INT"
	DB_Integer   = "INTEGER"
	DB_BigInt    = "BIGINT"

	DB_Set = "SET"

	DB_Char       = "CHAR"
	DB_Varchar    = "VARCHAR"
	DB_NVarchar   = "NVARCHAR"
	DB_TinyText   = "TINYTEXT"
	DB_Text       = "TEXT"
	DB_MediumText = "MEDIUMTEXT"
	DB_LongText   = "LONGTEXT"
	DB_Uuid       = "UUID"

	DB_Date       = "DATE"
	DB_DateTime   = "DATETIME"
	DB_Time       = "TIME"
	DB_TimeStamp  = "TIMESTAMP"
	DB_TimeStampz = "TIMESTAMPZ"

	DB_Decimal = "DECIMAL"
	DB_Numeric = "NUMERIC"

	DB_Real   = "REAL"
	DB_Float  = "FLOAT"
	DB_Double = "DOUBLE"

	DB_Binary     = "BINARY"
	DB_VarBinary  = "VARBINARY"
	DB_TinyBlob   = "TINYBLOB"
	DB_Blob       = "BLOB"
	DB_MediumBlob = "MEDIUMBLOB"
	DB_LongBlob   = "LONGBLOB"
	DB_Bytea      = "BYTEA"

	DB_Bool = "BOOL"

	DB_Serial    = "SERIAL"
	DB_BigSerial = "BIGSERIAL"
)

Functions

This section is empty.

Types

type AddColumnMigration

type AddColumnMigration struct {
	MigrationBase
	// contains filtered or unexported fields
}

func NewAddColumnMigration

func NewAddColumnMigration(table Table, col *Column) *AddColumnMigration

func (*AddColumnMigration) Column

func (m *AddColumnMigration) Column(col *Column) *AddColumnMigration

func (*AddColumnMigration) SQL

func (m *AddColumnMigration) SQL(dialect Dialect) string

func (*AddColumnMigration) Table

func (m *AddColumnMigration) Table(tableName string) *AddColumnMigration

type AddIndexMigration

type AddIndexMigration struct {
	MigrationBase
	// contains filtered or unexported fields
}

func NewAddIndexMigration

func NewAddIndexMigration(table Table, index *Index) *AddIndexMigration

func (*AddIndexMigration) SQL

func (m *AddIndexMigration) SQL(dialect Dialect) string

func (*AddIndexMigration) Table

func (m *AddIndexMigration) Table(tableName string) *AddIndexMigration

type AddTableMigration

type AddTableMigration struct {
	MigrationBase
	// contains filtered or unexported fields
}

func NewAddTableMigration

func NewAddTableMigration(table Table) *AddTableMigration

func (*AddTableMigration) SQL

func (m *AddTableMigration) SQL(d Dialect) string

type BaseDialect

type BaseDialect struct {
	// contains filtered or unexported fields
}

func (*BaseDialect) AddColumnSQL

func (b *BaseDialect) AddColumnSQL(tableName string, col *Column) string

func (*BaseDialect) AndStr

func (b *BaseDialect) AndStr() string

func (*BaseDialect) CleanDB

func (b *BaseDialect) CleanDB(engine *xorm.Engine) error

func (*BaseDialect) ColString

func (b *BaseDialect) ColString(col *Column) string

func (*BaseDialect) ColStringNoPk

func (b *BaseDialect) ColStringNoPk(col *Column) string

func (*BaseDialect) ColumnCheckSQL

func (b *BaseDialect) ColumnCheckSQL(tableName, columnName string) (string, []interface{})

func (*BaseDialect) CopyTableData

func (b *BaseDialect) CopyTableData(sourceTable string, targetTable string, sourceCols []string, targetCols []string) string

func (*BaseDialect) CreateIndexSQL

func (b *BaseDialect) CreateIndexSQL(tableName string, index *Index) string

func (*BaseDialect) CreateTableSQL

func (b *BaseDialect) CreateTableSQL(table *Table) string

func (*BaseDialect) DateTimeFunc

func (b *BaseDialect) DateTimeFunc(value string) string

func (*BaseDialect) Default

func (b *BaseDialect) Default(col *Column) string

func (*BaseDialect) DriverName

func (b *BaseDialect) DriverName() string

func (*BaseDialect) DropIndexSQL

func (b *BaseDialect) DropIndexSQL(tableName string, index *Index) string

func (*BaseDialect) DropTable

func (b *BaseDialect) DropTable(tableName string) string

func (*BaseDialect) EqStr

func (b *BaseDialect) EqStr() string

func (*BaseDialect) GetDBName

func (b *BaseDialect) GetDBName(_ string) (string, error)

func (*BaseDialect) LikeStr

func (b *BaseDialect) LikeStr() string

func (*BaseDialect) Limit

func (b *BaseDialect) Limit(limit int64) string

func (*BaseDialect) LimitOffset

func (b *BaseDialect) LimitOffset(limit int64, offset int64) string

func (*BaseDialect) Lock

func (b *BaseDialect) Lock(_ LockCfg) error

func (*BaseDialect) NoOpSQL

func (b *BaseDialect) NoOpSQL() string

func (*BaseDialect) OrStr

func (b *BaseDialect) OrStr() string

func (*BaseDialect) OrderBy

func (b *BaseDialect) OrderBy(order string) string

func (*BaseDialect) PostInsertId

func (b *BaseDialect) PostInsertId(table string, sess *xorm.Session) error

func (*BaseDialect) PreInsertId

func (b *BaseDialect) PreInsertId(table string, sess *xorm.Session) error

func (*BaseDialect) QuoteColList

func (b *BaseDialect) QuoteColList(cols []string) string

func (*BaseDialect) RenameColumn

func (b *BaseDialect) RenameColumn(table Table, column *Column, newName string) string

func (*BaseDialect) RenameTable

func (b *BaseDialect) RenameTable(oldName string, newName string) string

func (*BaseDialect) ShowCreateNull

func (b *BaseDialect) ShowCreateNull() bool

func (*BaseDialect) TruncateDBTables

func (b *BaseDialect) TruncateDBTables(engine *xorm.Engine) error

func (*BaseDialect) Unlock

func (b *BaseDialect) Unlock(_ LockCfg) error

func (*BaseDialect) UpdateTableSQL

func (b *BaseDialect) UpdateTableSQL(tableName string, columns []*Column) string

func (*BaseDialect) UpsertSQL

func (b *BaseDialect) UpsertSQL(tableName string, keyCols, updateCols []string) string

UpsertSQL returns empty string

type CodeMigration

type CodeMigration interface {
	Migration
	Exec(sess *xorm.Session, migrator *Migrator) error
}

type Column

type Column struct {
	Name            string
	Type            string
	Length          int
	Length2         int
	Nullable        bool
	IsPrimaryKey    bool
	IsAutoIncrement bool
	IsLatin         bool
	Default         string
}

func (*Column) String

func (col *Column) String(d Dialect) string

func (*Column) StringNoPk

func (col *Column) StringNoPk(d Dialect) string

type ColumnType

type ColumnType string
const (
	DB_TYPE_STRING ColumnType = "String"
)

type CopyTableDataMigration

type CopyTableDataMigration struct {
	MigrationBase
	// contains filtered or unexported fields
}

func NewCopyTableDataMigration

func NewCopyTableDataMigration(targetTable string, sourceTable string, colMap map[string]string) *CopyTableDataMigration

func (*CopyTableDataMigration) SQL

type Dialect

type Dialect interface {
	DriverName() string
	Quote(string) string
	AndStr() string
	AutoIncrStr() string
	OrStr() string
	EqStr() string
	ShowCreateNull() bool
	SQLType(col *Column) string
	SupportEngine() bool
	LikeStr() string
	Default(col *Column) string
	BooleanStr(bool) string
	DateTimeFunc(string) string
	BatchSize() int

	OrderBy(order string) string

	CreateIndexSQL(tableName string, index *Index) string
	CreateTableSQL(table *Table) string
	AddColumnSQL(tableName string, col *Column) string
	CopyTableData(sourceTable string, targetTable string, sourceCols []string, targetCols []string) string
	DropTable(tableName string) string
	DropIndexSQL(tableName string, index *Index) string

	// RenameTable is deprecated, its use cause breaking changes
	// so, it should no longer be used. Kept for legacy reasons.
	RenameTable(oldName string, newName string) string
	// RenameColumn is deprecated, its use cause breaking changes
	// so, it should no longer be used. Kept for legacy reasons.
	RenameColumn(table Table, column *Column, newName string) string

	UpdateTableSQL(tableName string, columns []*Column) string

	IndexCheckSQL(tableName, indexName string) (string, []interface{})
	ColumnCheckSQL(tableName, columnName string) (string, []interface{})
	// UpsertSQL returns the upsert sql statement for a dialect
	UpsertSQL(tableName string, keyCols, updateCols []string) string
	UpsertMultipleSQL(tableName string, keyCols, updateCols []string, count int) (string, error)

	ColString(*Column) string
	ColStringNoPk(*Column) string

	Limit(limit int64) string
	LimitOffset(limit int64, offset int64) string

	PreInsertId(table string, sess *xorm.Session) error
	PostInsertId(table string, sess *xorm.Session) error

	CleanDB(engine *xorm.Engine) error
	TruncateDBTables(engine *xorm.Engine) error
	NoOpSQL() string

	IsUniqueConstraintViolation(err error) bool
	ErrorMessage(err error) string
	IsDeadlock(err error) bool
	Lock(LockCfg) error
	Unlock(LockCfg) error

	GetDBName(string) (string, error)
}

func NewDialect

func NewDialect(driverName string) Dialect

func NewMysqlDialect

func NewMysqlDialect() Dialect

func NewPostgresDialect

func NewPostgresDialect() Dialect

func NewSQLite3Dialect

func NewSQLite3Dialect() Dialect

type DropIndexMigration

type DropIndexMigration struct {
	MigrationBase
	// contains filtered or unexported fields
}

func NewDropIndexMigration

func NewDropIndexMigration(table Table, index *Index) *DropIndexMigration

func (*DropIndexMigration) SQL

func (m *DropIndexMigration) SQL(dialect Dialect) string

type DropTableMigration

type DropTableMigration struct {
	MigrationBase
	// contains filtered or unexported fields
}

func NewDropTableMigration

func NewDropTableMigration(tableName string) *DropTableMigration

func (*DropTableMigration) SQL

func (m *DropTableMigration) SQL(d Dialect) string

type ExistsMigrationCondition

type ExistsMigrationCondition struct{}

func (*ExistsMigrationCondition) IsFulfilled

func (c *ExistsMigrationCondition) IsFulfilled(results []map[string][]byte) bool

type IfColumnNotExistsCondition

type IfColumnNotExistsCondition struct {
	NotExistsMigrationCondition
	TableName  string
	ColumnName string
}

func (*IfColumnNotExistsCondition) SQL

func (c *IfColumnNotExistsCondition) SQL(dialect Dialect) (string, []interface{})

type IfIndexExistsCondition

type IfIndexExistsCondition struct {
	ExistsMigrationCondition
	TableName string
	IndexName string
}

func (*IfIndexExistsCondition) SQL

func (c *IfIndexExistsCondition) SQL(dialect Dialect) (string, []interface{})

type IfIndexNotExistsCondition

type IfIndexNotExistsCondition struct {
	NotExistsMigrationCondition
	TableName string
	IndexName string
}

func (*IfIndexNotExistsCondition) SQL

func (c *IfIndexNotExistsCondition) SQL(dialect Dialect) (string, []interface{})

type Index

type Index struct {
	Name string
	Type int
	Cols []string
}

func (*Index) XName

func (index *Index) XName(tableName string) string

type LockCfg

type LockCfg struct {
	Session *xorm.Session
	Key     string
	Timeout int
}

type Migration

type Migration interface {
	SQL(dialect Dialect) string
	Id() string
	SetId(string)
	GetCondition() MigrationCondition
	// SkipMigrationLog is used by dashboard alert migration to Grafana 8 Alerts
	// for skipping recording it in the migration_log so that it can run several times.
	// For all the other migrations it should be false.
	SkipMigrationLog() bool
}

type MigrationBase

type MigrationBase struct {
	Condition MigrationCondition
	// contains filtered or unexported fields
}

func (*MigrationBase) GetCondition

func (m *MigrationBase) GetCondition() MigrationCondition

func (*MigrationBase) Id

func (m *MigrationBase) Id() string

func (*MigrationBase) SetId

func (m *MigrationBase) SetId(id string)

func (*MigrationBase) SkipMigrationLog

func (m *MigrationBase) SkipMigrationLog() bool

type MigrationCondition

type MigrationCondition interface {
	SQL(dialect Dialect) (string, []interface{})
	IsFulfilled(results []map[string][]byte) bool
}

type MigrationLog

type MigrationLog struct {
	Id          int64
	MigrationID string `xorm:"migration_id"`
	SQL         string `xorm:"sql"`
	Success     bool
	Error       string
	Timestamp   time.Time
}

type Migrator

type Migrator struct {
	DBEngine *xorm.Engine
	Dialect  Dialect

	Logger log.Logger
	Cfg    *setting.Cfg
	// contains filtered or unexported fields
}

func NewMigrator

func NewMigrator(engine *xorm.Engine, cfg *setting.Cfg) *Migrator

func NewScopedMigrator

func NewScopedMigrator(engine *xorm.Engine, cfg *setting.Cfg, scope string) *Migrator

NewScopedMigrator should only be used for the transition to a new storage engine

func (*Migrator) AddCreateMigration

func (mg *Migrator) AddCreateMigration()

AddCreateMigration adds the initial migration log table -- this should likely be automatic and first, but enough tests exists that do not expect that we can keep it explicit

func (*Migrator) AddMigration

func (mg *Migrator) AddMigration(id string, m Migration)

func (*Migrator) GetMigrationIDs

func (mg *Migrator) GetMigrationIDs(excludeNotLogged bool) []string

func (*Migrator) GetMigrationLog

func (mg *Migrator) GetMigrationLog() (map[string]MigrationLog, error)

func (*Migrator) InTransaction

func (mg *Migrator) InTransaction(callback dbTransactionFunc) error

func (*Migrator) MigrationsCount

func (mg *Migrator) MigrationsCount() int

func (*Migrator) RemoveMigrationLogs

func (mg *Migrator) RemoveMigrationLogs(migrationsIDs ...string)

func (*Migrator) Start

func (mg *Migrator) Start(isDatabaseLockingEnabled bool, lockAttemptTimeout int) (err error)

type MySQLDialect

type MySQLDialect struct {
	BaseDialect
}

func (*MySQLDialect) AutoIncrStr

func (db *MySQLDialect) AutoIncrStr() string

func (*MySQLDialect) BatchSize

func (db *MySQLDialect) BatchSize() int

func (*MySQLDialect) BooleanStr

func (db *MySQLDialect) BooleanStr(value bool) string

func (*MySQLDialect) CleanDB

func (db *MySQLDialect) CleanDB(engine *xorm.Engine) error

func (*MySQLDialect) ColumnCheckSQL

func (db *MySQLDialect) ColumnCheckSQL(tableName, columnName string) (string, []interface{})

func (*MySQLDialect) ErrorMessage

func (db *MySQLDialect) ErrorMessage(err error) string

func (*MySQLDialect) GetDBName

func (db *MySQLDialect) GetDBName(dsn string) (string, error)

func (*MySQLDialect) IndexCheckSQL

func (db *MySQLDialect) IndexCheckSQL(tableName, indexName string) (string, []interface{})

func (*MySQLDialect) IsDeadlock

func (db *MySQLDialect) IsDeadlock(err error) bool

func (*MySQLDialect) IsUniqueConstraintViolation

func (db *MySQLDialect) IsUniqueConstraintViolation(err error) bool

func (*MySQLDialect) Lock

func (db *MySQLDialect) Lock(cfg LockCfg) error

func (*MySQLDialect) Quote

func (db *MySQLDialect) Quote(name string) string

func (*MySQLDialect) RenameColumn

func (db *MySQLDialect) RenameColumn(table Table, column *Column, newName string) string

func (*MySQLDialect) SQLType

func (db *MySQLDialect) SQLType(c *Column) string

func (*MySQLDialect) SupportEngine

func (db *MySQLDialect) SupportEngine() bool

func (*MySQLDialect) TruncateDBTables

func (db *MySQLDialect) TruncateDBTables(engine *xorm.Engine) error

TruncateDBTables truncates all the tables. A special case is the dashboard_acl table where we keep the default permissions.

func (*MySQLDialect) Unlock

func (db *MySQLDialect) Unlock(cfg LockCfg) error

func (*MySQLDialect) UpdateTableSQL

func (db *MySQLDialect) UpdateTableSQL(tableName string, columns []*Column) string

func (*MySQLDialect) UpsertMultipleSQL

func (db *MySQLDialect) UpsertMultipleSQL(tableName string, keyCols, updateCols []string, count int) (string, error)

func (*MySQLDialect) UpsertSQL

func (db *MySQLDialect) UpsertSQL(tableName string, keyCols, updateCols []string) string

UpsertSQL returns the upsert sql statement for MySQL dialect

type NotExistsMigrationCondition

type NotExistsMigrationCondition struct{}

func (*NotExistsMigrationCondition) IsFulfilled

func (c *NotExistsMigrationCondition) IsFulfilled(results []map[string][]byte) bool

type PostgresDialect

type PostgresDialect struct {
	BaseDialect
}

func (*PostgresDialect) AutoIncrStr

func (db *PostgresDialect) AutoIncrStr() string

func (*PostgresDialect) BatchSize

func (db *PostgresDialect) BatchSize() int

func (*PostgresDialect) BooleanStr

func (db *PostgresDialect) BooleanStr(value bool) string

func (*PostgresDialect) CleanDB

func (db *PostgresDialect) CleanDB(engine *xorm.Engine) error

func (*PostgresDialect) DropIndexSQL

func (db *PostgresDialect) DropIndexSQL(tableName string, index *Index) string

func (*PostgresDialect) ErrorMessage

func (db *PostgresDialect) ErrorMessage(err error) string

func (*PostgresDialect) GetDBName

func (db *PostgresDialect) GetDBName(dsn string) (string, error)

func (*PostgresDialect) IndexCheckSQL

func (db *PostgresDialect) IndexCheckSQL(tableName, indexName string) (string, []interface{})

func (*PostgresDialect) IsDeadlock

func (db *PostgresDialect) IsDeadlock(err error) bool

func (*PostgresDialect) IsUniqueConstraintViolation

func (db *PostgresDialect) IsUniqueConstraintViolation(err error) bool

func (*PostgresDialect) LikeStr

func (db *PostgresDialect) LikeStr() string

func (*PostgresDialect) Lock

func (db *PostgresDialect) Lock(cfg LockCfg) error

func (*PostgresDialect) OrderBy

func (db *PostgresDialect) OrderBy(order string) string

OrderBy normalizes ordering so that nulls end up last in sorting, which they do by default in both sqlite and mysql but not postgres order should be a string like `dashboard.id ASC`

func (*PostgresDialect) PostInsertId

func (db *PostgresDialect) PostInsertId(table string, sess *xorm.Session) error

func (*PostgresDialect) Quote

func (db *PostgresDialect) Quote(name string) string

func (*PostgresDialect) SQLType

func (db *PostgresDialect) SQLType(c *Column) string

func (*PostgresDialect) SupportEngine

func (db *PostgresDialect) SupportEngine() bool

func (*PostgresDialect) TruncateDBTables

func (db *PostgresDialect) TruncateDBTables(engine *xorm.Engine) error

TruncateDBTables truncates all the tables. A special case is the dashboard_acl table where we keep the default permissions.

func (*PostgresDialect) Unlock

func (db *PostgresDialect) Unlock(cfg LockCfg) error

func (*PostgresDialect) UpdateTableSQL

func (db *PostgresDialect) UpdateTableSQL(tableName string, columns []*Column) string

func (*PostgresDialect) UpsertMultipleSQL

func (db *PostgresDialect) UpsertMultipleSQL(tableName string, keyCols, updateCols []string, count int) (string, error)

UpsertMultipleSQL returns the upsert sql statement for PostgreSQL dialect

func (*PostgresDialect) UpsertSQL

func (db *PostgresDialect) UpsertSQL(tableName string, keyCols, updateCols []string) string

UpsertSQL returns the upsert sql statement for PostgreSQL dialect

type RawSQLMigration

type RawSQLMigration struct {
	MigrationBase
	// contains filtered or unexported fields
}

func NewRawSQLMigration

func NewRawSQLMigration(sql string) *RawSQLMigration

NewRawSQLMigration should be used carefully, the usage of SQL statements that cause breaking changes like renaming a table or a column, or changing a column type should not be used.

func (*RawSQLMigration) Default

func (m *RawSQLMigration) Default(sql string) *RawSQLMigration

func (*RawSQLMigration) Mssql

func (m *RawSQLMigration) Mssql(sql string) *RawSQLMigration

func (*RawSQLMigration) Mysql

func (m *RawSQLMigration) Mysql(sql string) *RawSQLMigration

func (*RawSQLMigration) Postgres

func (m *RawSQLMigration) Postgres(sql string) *RawSQLMigration

func (*RawSQLMigration) SQL

func (m *RawSQLMigration) SQL(dialect Dialect) string

func (*RawSQLMigration) SQLite

func (m *RawSQLMigration) SQLite(sql string) *RawSQLMigration

func (*RawSQLMigration) Set

func (m *RawSQLMigration) Set(dialect string, sql string) *RawSQLMigration

type RenameColumnMigration

type RenameColumnMigration struct {
	MigrationBase
	// contains filtered or unexported fields
}

func NewRenameColumnMigration

func NewRenameColumnMigration(table Table, column *Column, newName string) *RenameColumnMigration

NewRenameColumnMigration may cause breaking changes. DEPRECATED: It should no longer be used. Kept only for legacy reasons.

func (*RenameColumnMigration) Column

func (*RenameColumnMigration) Rename

func (*RenameColumnMigration) SQL

func (*RenameColumnMigration) Table

type RenameTableMigration

type RenameTableMigration struct {
	MigrationBase
	// contains filtered or unexported fields
}

func NewRenameTableMigration

func NewRenameTableMigration(oldName string, newName string) *RenameTableMigration

NewRenameTableMigration may cause breaking changes. DEPRECATED: It should no longer be used. Kept only for legacy reasons.

func (*RenameTableMigration) Rename

func (m *RenameTableMigration) Rename(oldName string, newName string) *RenameTableMigration

func (*RenameTableMigration) SQL

type SQLType

type SQLType string

type SQLite3

type SQLite3 struct {
	BaseDialect
}

func (*SQLite3) AutoIncrStr

func (db *SQLite3) AutoIncrStr() string

func (*SQLite3) BatchSize

func (db *SQLite3) BatchSize() int

func (*SQLite3) BooleanStr

func (db *SQLite3) BooleanStr(value bool) string

func (*SQLite3) CleanDB

func (db *SQLite3) CleanDB(engine *xorm.Engine) error

func (*SQLite3) DateTimeFunc

func (db *SQLite3) DateTimeFunc(value string) string

func (*SQLite3) DropIndexSQL

func (db *SQLite3) DropIndexSQL(tableName string, index *Index) string

func (*SQLite3) ErrorMessage

func (db *SQLite3) ErrorMessage(err error) string

func (*SQLite3) IndexCheckSQL

func (db *SQLite3) IndexCheckSQL(tableName, indexName string) (string, []interface{})

func (*SQLite3) IsDeadlock

func (db *SQLite3) IsDeadlock(err error) bool

func (*SQLite3) IsUniqueConstraintViolation

func (db *SQLite3) IsUniqueConstraintViolation(err error) bool

func (*SQLite3) Quote

func (db *SQLite3) Quote(name string) string

func (*SQLite3) SQLType

func (db *SQLite3) SQLType(c *Column) string

func (*SQLite3) SupportEngine

func (db *SQLite3) SupportEngine() bool

func (*SQLite3) TruncateDBTables

func (db *SQLite3) TruncateDBTables(engine *xorm.Engine) error

TruncateDBTables deletes all data from all the tables and resets the sequences. A special case is the dashboard_acl table where we keep the default permissions.

func (*SQLite3) UpsertMultipleSQL

func (db *SQLite3) UpsertMultipleSQL(tableName string, keyCols, updateCols []string, count int) (string, error)

UpsertMultipleSQL returns the upsert sql statement for PostgreSQL dialect

func (*SQLite3) UpsertSQL

func (db *SQLite3) UpsertSQL(tableName string, keyCols, updateCols []string) string

UpsertSQL returns the upsert sql statement for SQLite dialect

type Table

type Table struct {
	Name        string
	Columns     []*Column
	PrimaryKeys []string
	Indices     []*Index
}

type TableCharsetMigration

type TableCharsetMigration struct {
	MigrationBase
	// contains filtered or unexported fields
}

func NewTableCharsetMigration

func NewTableCharsetMigration(tableName string, columns []*Column) *TableCharsetMigration

func (*TableCharsetMigration) SQL

Jump to

Keyboard shortcuts

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