Documentation
¶
Index ¶
- func GetDBMigrationDir() string
- func GetDBURL() string
- type Database
- type DatabaseImplementation
- func (base *DatabaseImplementation) CreateMigrationTable(schema string) error
- func (base *DatabaseImplementation) CreateSchema(schema string) error
- func (base *DatabaseImplementation) DeleteMigrationLog(schema string, batch string) error
- func (base *DatabaseImplementation) DoMigrationTableExists(schema string) (bool, error)
- func (base *DatabaseImplementation) DoesSchemaExists(schema string) (bool, error)
- func (base *DatabaseImplementation) ExecuteMigration(schema string, command string) error
- func (base *DatabaseImplementation) GetLatestBatch(schema string) (string, error)
- func (base *DatabaseImplementation) GetMaxSequence(schema string) (int, error)
- func (base *DatabaseImplementation) GetSequenceByBatch(schema string, batch string) ([]int, error)
- func (base *DatabaseImplementation) InsertMigrationLog(schema string, version int, name string, batch string) error
- type MigrationQueries
- type Postgres
- func (p Postgres) CountMigrationTableSQL() string
- func (p Postgres) CountSchemaSQL() string
- func (p Postgres) CreateMigrationTableSQL(schema string) string
- func (p Postgres) CreateSchemaSQL(schema string) string
- func (p Postgres) DeleteMigrationLogSQL(schema string) string
- func (p Postgres) GetLatestBatchSQL(schema string) string
- func (p Postgres) GetMaxSequenceSQL(schema string) string
- func (p Postgres) GetSequenceByBatchSQL(schema string) string
- func (p Postgres) InsertMigrationLogSQL(schema string) string
- func (p Postgres) SetSchemaSQL(schema string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDBMigrationDir ¶ added in v0.1.4
func GetDBMigrationDir() string
GetDBDir return migration dir
Types ¶
type Database ¶
type Database interface { DoMigrationTableExists(schema string) (bool, error) CreateMigrationTable(schema string) error GetMaxSequence(schema string) (int, error) GetLatestBatch(schema string) (string, error) InsertMigrationLog(schema string, version int, name string, batch string) error DeleteMigrationLog(schema string, batch string) error ExecuteMigration(schema string, command string) error GetSequenceByBatch(schema string, batch string) ([]int, error) DoesSchemaExists(schema string) (bool, error) CreateSchema(schema string) error }
type DatabaseImplementation ¶
DatabaseImplementation to access the database
func GetDatabase ¶
func GetDatabase() (*DatabaseImplementation, error)
GetDatabase returns DB implementation
func (*DatabaseImplementation) CreateMigrationTable ¶
func (base *DatabaseImplementation) CreateMigrationTable(schema string) error
CreateMigrationTable Create a migration table
func (*DatabaseImplementation) CreateSchema ¶
func (base *DatabaseImplementation) CreateSchema(schema string) error
CreateSchema Create the schema
func (*DatabaseImplementation) DeleteMigrationLog ¶
func (base *DatabaseImplementation) DeleteMigrationLog(schema string, batch string) error
DeleteMigrationLog Deletes a batch of migration logs
func (*DatabaseImplementation) DoMigrationTableExists ¶
func (base *DatabaseImplementation) DoMigrationTableExists(schema string) (bool, error)
DoMigrationTableExists Check if migration table exsists
func (*DatabaseImplementation) DoesSchemaExists ¶
func (base *DatabaseImplementation) DoesSchemaExists(schema string) (bool, error)
DoesSchemaExists Check if schema exists
func (*DatabaseImplementation) ExecuteMigration ¶
func (base *DatabaseImplementation) ExecuteMigration(schema string, command string) error
ExecuteMigration executes the given SQL as script
func (*DatabaseImplementation) GetLatestBatch ¶
func (base *DatabaseImplementation) GetLatestBatch(schema string) (string, error)
GetLatestBatch Gets the latest batch in the schema
func (*DatabaseImplementation) GetMaxSequence ¶
func (base *DatabaseImplementation) GetMaxSequence(schema string) (int, error)
GetMaxSequence Gets the max sequence in the schema
func (*DatabaseImplementation) GetSequenceByBatch ¶
func (base *DatabaseImplementation) GetSequenceByBatch(schema string, batch string) ([]int, error)
GetSequenceByBatch get the sequence ids by batch
func (*DatabaseImplementation) InsertMigrationLog ¶
func (base *DatabaseImplementation) InsertMigrationLog(schema string, version int, name string, batch string) error
InsertMigrationLog inserts a migration log
type MigrationQueries ¶
type MigrationQueries interface { CountMigrationTableSQL() string CreateMigrationTableSQL(schema string) string GetMaxSequenceSQL(schema string) string GetLatestBatchSQL(schema string) string InsertMigrationLogSQL(schema string) string DeleteMigrationLogSQL(schema string) string SetSchemaSQL(schema string) string GetSequenceByBatchSQL(schema string) string CountSchemaSQL() string CreateSchemaSQL(schema string) string }
MigrationQueries interface to get all the required queries.
type Postgres ¶
type Postgres struct{}
Postgres struct to return Postgres queries
func (Postgres) CountMigrationTableSQL ¶
CountMigrationTableSQL query to check if migration table exists
func (Postgres) CountSchemaSQL ¶
GetSequenceByBatchSQL query to return sequences by batch
func (Postgres) CreateMigrationTableSQL ¶
CreateMigrationTableSQL query to create migration table
func (Postgres) CreateSchemaSQL ¶
CreateSchemaSQL query to check if migration schema exists
func (Postgres) DeleteMigrationLogSQL ¶
DeleteMigrationLogSQL query to delete migration
func (Postgres) GetLatestBatchSQL ¶
GetLatestBatchSQL query to return latest batch name in the schema
func (Postgres) GetMaxSequenceSQL ¶
GetMaxSequenceSQL query to return Max sequence in the schema
func (Postgres) GetSequenceByBatchSQL ¶
GetSequenceByBatchSQL query to return sequences by batch
func (Postgres) InsertMigrationLogSQL ¶
InsertMigrationLogSQL query to insert a migration
func (Postgres) SetSchemaSQL ¶
SetSchemaSQL sets the schema to correct folder