github.com/adharshmk96/stk@v1.2.3/pkg/sqlMigrator/dbrepo/dbrepo.go (about)

     1  package dbrepo
     2  
     3  import (
     4  	sqlmigrator "github.com/adharshmk96/stk/pkg/sqlMigrator"
     5  	"github.com/spf13/viper"
     6  )
     7  
     8  const (
     9  	MIGRATION_TABLE_NAME = "stk_migrations"
    10  )
    11  
    12  func SelectDBRepo(database sqlmigrator.Database) sqlmigrator.DBRepo {
    13  	switch database {
    14  	case sqlmigrator.SQLiteDB:
    15  		viper.SetDefault("migrator.database.filepath", "migrations.db")
    16  		filePath := viper.GetString("migrator.database.filepath")
    17  		return NewSQLiteRepo(filePath)
    18  	default:
    19  		viper.SetDefault("migrator.database.filepath", "migrations.db")
    20  		filePath := viper.GetString("migrator.database.filepath")
    21  		return NewSQLiteRepo(filePath)
    22  	}
    23  }