Documentation ¶
Overview ¶
Package store is responsible to persist the data of schema package
Index ¶
Constants ¶
const ( // StatusSuccess is the status name for 'success' StatusSuccess = "success" // StatusError is the status name for 'error' StatusError = "error" )
const (
// DateTimeFormat represents the default sql datetime format.
DateTimeFormat = "2006-01-02T15:04:05Z"
)
Variables ¶
var ( // ErrNoDataset is used if no data for row is provided ErrNoDataset = errors.New("dataset must be provided") // ErrNoID is used if no or wrong id was provided ErrNoID = errors.New("id must be greater than zero") // ErrNoScript is used if no script name was provided ErrNoScript = errors.New("script name must be provided") )
Functions ¶
This section is empty.
Types ¶
type DatabaseConnector ¶
type DatabaseConnector interface { sqlx.Execer Select(dest interface{}, query string, args ...interface{}) error Get(dest interface{}, query string, args ...interface{}) error io.Closer Rebind(string) string }
DatabaseConnector provides methods to interact with a database.
type SchemaScript ¶
type SchemaScript struct { ID int64 `db:"id"` ScriptName string `db:"script_name"` ExecutedAt time.Time `db:"executed_at"` Status string `db:"execution_status"` ErrorMsg string `db:"error_msg"` AppVersion string `db:"app_version"` }
SchemaScript represents the version information stored in the database.
func NewSchemaScriptError ¶
func NewSchemaScriptError(scriptName string, appVersion string, errorMsg string) *SchemaScript
NewSchemaScriptError returns a new SchemaScript struct prepared for failed execution.
func NewSchemaScriptSuccess ¶
func NewSchemaScriptSuccess(scriptName string, appVersion string) *SchemaScript
NewSchemaScriptSuccess returns a new SchemaScript struct prepared for successful execution.
type SchemaScriptCollection ¶
type SchemaScriptCollection []*SchemaScript
SchemaScriptCollection represent an array of SchemaScript providing useful functions.
func (SchemaScriptCollection) Len ¶
func (s SchemaScriptCollection) Len() int
Len returns number of elements in collection.
func (SchemaScriptCollection) ScriptExecuted ¶
func (s SchemaScriptCollection) ScriptExecuted(scriptName string) bool
ScriptExecuted returns true if the given scriptName was already executed successful.
type SchemaScriptMapper ¶
type SchemaScriptMapper struct {
// contains filtered or unexported fields
}
SchemaScriptMapper is responsible for mapping and storing SchemaScript struct in database.
func NewSchemaScriptMapper ¶
func NewSchemaScriptMapper(db DatabaseConnector) *SchemaScriptMapper
NewSchemaScriptMapper returns a new SchemaScriptMapper.
func (SchemaScriptMapper) Add ¶
func (ssm SchemaScriptMapper) Add(entry *SchemaScript) error
Add adds a new row to the table.
func (SchemaScriptMapper) GetAll ¶
func (ssm SchemaScriptMapper) GetAll() (SchemaScriptCollection, error)
GetAll returns all SchemaScript entries.
func (SchemaScriptMapper) GetByID ¶
func (ssm SchemaScriptMapper) GetByID(id int64) (*SchemaScript, error)
GetByID returns the SchemaScript entry found for provided id.
func (*SchemaScriptMapper) Remove ¶
func (ssm *SchemaScriptMapper) Remove(scriptName string) error
Remove deletes an entry from table based on scriptName.