Documentation
¶
Overview ¶
Integrates with migration tools recognizing the standard "migrate up" and "migrate down" annotations, simplifying asset database schema management and rollbacks in SQLite3.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Migrations ¶
Example ¶
dsn := "test.db"
if v, ok := os.LookupEnv("SQLITE3_DB"); ok {
dsn = v
}
db, err := gorm.Open(sqlite.Open(dsn), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
sqlDb, _ := db.DB()
migrationsSource := migrate.EmbedFileSystemMigrationSource{
FileSystem: Migrations(),
Root: "/",
}
_, err = migrate.Exec(sqlDb, "sqlite3", migrationsSource, migrate.Up)
if err != nil {
panic(err)
}
tables := []string{"entities", "entity_tags", "edges", "edge_tags"}
for _, table := range tables {
fmt.Println(db.Migrator().HasTable(table))
}
err = os.Remove(dsn)
if err != nil {
panic(err)
}
Output: true true true true
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.