Documentation
¶
Index ¶
- Variables
- func AutoMigration(db *sql.DB, databaseName string, migrationUrl string)
- func GetMigrationVersion(mig *migrate.Migrate) (uint, bool)
- func MigrateDown(mig *migrate.Migrate)
- func MigrateTo(mig *migrate.Migrate, version uint)
- func MigrateUp(mig *migrate.Migrate)
- func NewMigratedMemoryDB(pathToMigrations string) *sql.DB
- func NewMigration(db *sql.DB, databaseName string, migrationUrl string) *migrate.Migrate
- func OpenDb(name string) *sql.DB
- func OpenMemoryDb() (*sql.DB, string)
- type Dialect
- type DialectConfig
- type FactoryFunc
- type IdSetter
- type RevisionStore
- type ScanFunc
- type Store
- type StoreAdapter
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrFirstFieldMustBeAutoIncrInteger = errors.New("Expected first field in structure to be an int64")
View Source
var FlagDatabasePath string = "app.sqlite"
View Source
var FlagMigrationPath string = "migration"
View Source
var MigrateCmd = &cobra.Command{ Use: "migrate", Short: "Migrates the database of the service", Long: `Migrates the database of the service`, Run: func(cmd *cobra.Command, args []string) { d := OpenDb(FlagDatabasePath) defer d.Close() mig := NewMigration(d, FlagDatabasePath, FlagMigrationPath) GetMigrationVersion(mig) }, }
MigrateCmd represents the migrate command
Functions ¶
func MigrateDown ¶
func NewMigratedMemoryDB ¶
func NewMigration ¶
func OpenMemoryDb ¶
Types ¶
type Dialect ¶ added in v1.0.2
type Dialect interface { Qt(exp string) string QtAll(exp ...string) []string QtPtr(exp *string) *string }
func NewDialect ¶ added in v1.0.2
func NewDialect() Dialect
type DialectConfig ¶ added in v1.0.2
type DialectConfig struct {
// contains filtered or unexported fields
}
func (*DialectConfig) Qt ¶ added in v1.0.2
func (d *DialectConfig) Qt(exp string) string
func (*DialectConfig) QtAll ¶ added in v1.0.2
func (d *DialectConfig) QtAll(exp ...string) []string
func (*DialectConfig) QtPtr ¶ added in v1.0.2
func (d *DialectConfig) QtPtr(exp *string) *string
type FactoryFunc ¶ added in v1.0.2
type FactoryFunc func() any
type RevisionStore ¶ added in v1.0.2
type RevisionStore interface { GetRev(key string) (int64, error) IncrRev(key string) (int64, error) Close() }
func NewRevisionStore ¶ added in v1.0.2
func NewRevisionStore(db *sql.DB) RevisionStore
type Store ¶ added in v1.0.2
type Store interface { Insert(row any) error InsertAll(rows ...any) error Update(row any) error UpdateAll(row ...any) error SelectFirst(where string, args ...any) (any, error) SelectById(id int64) (any, error) SelectAll(where string, args ...any) ([]any, error) SelectAllBy(column string, key any) ([]any, error) SelectAllByPage(offset *int64, limit *int64, orderBy *string, sortDir *string, search *string) ([]any, int64, error) DeleteById(id int64) (bool, error) Delete(where string, args ...any) (int64, error) DeleteAllBy(column string, key any) (int64, error) DeleteFromBy(table string, column string, key any) (int64, error) CountAll() (int64, error) Count(where string, args ...any) (int64, error) CountBy(column string, key any) (int64, error) Exists(where string, args ...any) (bool, error) ExistsById(id int64) (bool, error) ExistsBy(column string, key any) (bool, error) IncrRev() (int64, error) GetRev() (int64, error) Close() error }
func NewStore ¶ added in v1.0.2
func NewStore(config StoreAdapter) Store
type StoreAdapter ¶ added in v1.0.2
Click to show internal directories.
Click to hide internal directories.