11// Package migrator represents MySQL database migrator
22//
33// MySQL database migrator designed to run migrations to your features and manage database schema update with intuitive go code.
4- // It is compatible with latest MySQL v8.
4+ // It is compatible with the latest MySQL v8.
55package migrator
66
77import (
@@ -15,20 +15,20 @@ import (
1515const migrationTable = "migrations"
1616
1717var (
18- // ErrTableNotExists returned when migration table not found
19- ErrTableNotExists = errors .New ("Migration table does not exists " )
18+ // ErrTableNotExists returns when migration table not found
19+ ErrTableNotExists = errors .New ("Migration table does not exist " )
2020
21- // ErrNoMigrationDefined returned when no migations defined in the migrations pool
21+ // ErrNoMigrationDefined returns when no migrations defined in the migrations pool
2222 ErrNoMigrationDefined = errors .New ("No migrations defined" )
2323
24- // ErrEmptyRollbackStack returned when nothing can be reverted
24+ // ErrEmptyRollbackStack returns when nothing can be reverted
2525 ErrEmptyRollbackStack = errors .New ("Nothing to rollback, there are no migration executed" )
2626
27- // ErrMissingMigrationName returned when migration name is missing
27+ // ErrMissingMigrationName returns when migration name is missing
2828 ErrMissingMigrationName = errors .New ("Missing migration name" )
2929
30- // ErrNoSQLCommandsToRun returned when migration is invalid and has not commands in the pool
31- ErrNoSQLCommandsToRun = errors .New ("There is no command to be executed" )
30+ // ErrNoSQLCommandsToRun returns when migration is invalid and has no commands in the pool
31+ ErrNoSQLCommandsToRun = errors .New ("There are no commands to be executed" )
3232)
3333
3434type migrationEntry struct {
@@ -38,10 +38,10 @@ type migrationEntry struct {
3838 appliedAt time.Time
3939}
4040
41- // Migrator represents a struct with migrations, that should be executed
41+ // Migrator represents a struct with migrations, that should be executed.
4242//
43- // Default migration table name is `migrations`, but it can be re-defined
44- // Pool is a list of migrations that should be migrated
43+ // Default migration table name is `migrations`, but it can be re-defined.
44+ // Pool is a list of migrations that should be migrated.
4545type Migrator struct {
4646 // Name of the table to track executed migrations
4747 TableName string
@@ -50,7 +50,7 @@ type Migrator struct {
5050 executed []migrationEntry
5151}
5252
53- // Migrate run all migrations from pool and stores in migration table executed migration
53+ // Migrate runs all migrations from pool and stores in migration table executed migration.
5454func (m Migrator ) Migrate (db * sql.DB ) (migrated []string , err error ) {
5555 if len (m .Pool ) == 0 {
5656 return migrated , ErrNoMigrationDefined
@@ -97,7 +97,7 @@ func (m Migrator) Migrate(db *sql.DB) (migrated []string, err error) {
9797 return migrated , nil
9898}
9999
100- // Rollback reverts last executed batch of migratios
100+ // Rollback reverts last executed batch of migrations.
101101func (m Migrator ) Rollback (db * sql.DB ) (reverted []string , err error ) {
102102 if len (m .Pool ) == 0 {
103103 return reverted , ErrNoMigrationDefined
@@ -149,7 +149,7 @@ func (m Migrator) Rollback(db *sql.DB) (reverted []string, err error) {
149149 return reverted , nil
150150}
151151
152- // Revert reverts all executed migration from the pool
152+ // Revert reverts all executed migration from the pool.
153153func (m Migrator ) Revert (db * sql.DB ) (reverted []string , err error ) {
154154 if len (m .Pool ) == 0 {
155155 return reverted , ErrNoMigrationDefined
0 commit comments