package database import ( "github.com/jinzhu/gorm" // SQLite dialect for gorm _ "github.com/jinzhu/gorm/dialects/sqlite" ) // Betriebsstelle defines the database model of the Betriebsstelle table type Betriebsstelle struct { gorm.Model Code string `gorm:"unique_index"` Name string } // Db is the GORM database handle var Db *gorm.DB // Open opens the database connection with given dialect and connection string func Open(dialect string, connection string) (err error) { Db, err = gorm.Open(dialect, connection) if err != nil { return err } Db.AutoMigrate(&Betriebsstelle{}) return nil } // Close closes the GORM database handle func Close() { Db.Close() Db = nil }