Documentation
¶
Overview ¶
Package schema provides a library to organize and deploy your database schema
Index ¶
- type Applier
- type Progressor
- type Schema
- func (s *Schema) Recreate(path string, version string) error
- func (s *Schema) RevertAll(path string) error
- func (s *Schema) RevertLast(path string) error
- func (s *Schema) RevertN(path string, numOfScripts int) error
- func (s *Schema) Upgrade(path string, version string) error
- func (s *Schema) WithProgressBar()
- type Scripter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Applier ¶
type Applier interface { ApplyScript(fileName string) error RevertScript(fileName string) error Init() error ReInit() error }
Applier provides methods to apply sql script to database.
type Progressor ¶
type Progressor interface { Increment() *pb.ProgressBar Finish() *pb.ProgressBar }
Progressor provides methods to steer a progress bar.
type Schema ¶
Schema provides commands to organize your database schema.
func (*Schema) Recreate ¶
Recreate reverts all applied scripts and apply them again. Internally it usues RevertAll() and Upgrade().
func (*Schema) RevertAll ¶
RevertAll reverts the all applied scripts. A path to the sql scripts needs to be provided. It reverts only files with ending ".sql", sub folders are ignored.
func (*Schema) RevertLast ¶
RevertLast reverts the last applied script. If it is repeatedly called, it reverts every time one script: means if you run it twice it reverts the last two scripts and so on. A path to the sql scripts needs to be provided. It reverts only files with ending ".sql", sub folders are ignored.
func (*Schema) RevertN ¶
RevertN reverts the number of n applied scripts. RevertLast() and RevertAll() are just shortcuts to this method. A path to the sql scripts needs to be provided. It reverts only files with ending ".sql", sub folders are ignored. Also the numOfScripts (number of scripts) to reverts needs to be provided. If the number is -1 or greater than the number of files in path it reverts all.
func (*Schema) Upgrade ¶
Upgrade applies new scripts to the database or if executed the first time applies all. A path to the sql scripts needs to be provided. It applies only files with ending ".sql", sub folders are ignored. The version of your application can be provided too, use empty string to ignore it.
func (*Schema) WithProgressBar ¶
func (s *Schema) WithProgressBar()
WithProgressBar activate the progress bar.
type Scripter ¶
type Scripter interface { Add(entry *store.SchemaScript) error GetAll() (store.SchemaScriptCollection, error) Remove(scriptName string) error }
Scripter provides methods to manage the access to log of SQL script executions.
Directories
¶
Path | Synopsis |
---|---|
Package bar provides a fake progress bar to be compatible with the Progressor interface of package schema
|
Package bar provides a fake progress bar to be compatible with the Progressor interface of package schema |
Package initdb provides functionality to initialize your database
|
Package initdb provides functionality to initialize your database |
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
schema_mock
Package schema_mock is a generated GoMock package.
|
Package schema_mock is a generated GoMock package. |
store_mock
Package store_mock is a generated GoMock package.
|
Package store_mock is a generated GoMock package. |
Package sqlfile manage the handling with sql files
|
Package sqlfile manage the handling with sql files |
Package store is responsible to persist the data of schema package
|
Package store is responsible to persist the data of schema package |
utils
|
|
testdb
Package testdb provides functions to setup or tear down integration tests
|
Package testdb provides functions to setup or tear down integration tests |