Documentation
¶
Index ¶
- Constants
- func GetDialector(dialect, dsn string) (gorm.Dialector, error)
- func LoadLocalMigrations(path string) (map[string]LocalMigration, error)
- func RollbackMigrations(db *gorm.DB, cfg Config, steps int) error
- func RunMigrations(db *gorm.DB, cfg Config) error
- type Config
- type LocalMigration
- type MigrationRecord
Constants ¶
View Source
const ( StatusSuccess = "success" StatusRollback = "rollback" StatusFailed = "failed" )
Status constants
Variables ¶
This section is empty.
Functions ¶
func GetDialector ¶
GetDialector returns the appropriate GORM dialector based on the dialect string
func LoadLocalMigrations ¶
func LoadLocalMigrations(path string) (map[string]LocalMigration, error)
func RollbackMigrations ¶
RollbackMigrations runs down scripts in reverse order. Steps=0 means rollback all.
Types ¶
type LocalMigration ¶
Helper struct for local files
type MigrationRecord ¶
type MigrationRecord struct {
ID uint `gorm:"primaryKey"`
Version string `gorm:"index"`
Name string
UpScript string `gorm:"type:text"`
DownScript string `gorm:"type:text"`
Status string `gorm:"index"`
AppliedAt time.Time
Message string
}
MigrationRecord represents a migration record in the database
Click to show internal directories.
Click to hide internal directories.