Skip to content

Commit

Permalink
Remove jsonfile and add tag capability
Browse files Browse the repository at this point in the history
  • Loading branch information
josephspurrier committed Jan 13, 2019
1 parent da69c71 commit 73afabc
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 484 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ Commands:
down <count> <file>
Apply a specific number of rollbacks to the database.
tag <name> <file>
Apply a tag to the latest changeset in the database.
status
Output the list of migrations already applied to the database.
```
Expand Down
10 changes: 9 additions & 1 deletion cmd/rove/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ var (
cDBDownCount = cDBDown.Arg("count", "Number of rollbacks [int].").Required().Int()
cDBDownFile = cDBDown.Arg("file", "Filename of the migration file [string].").Required().String()

cDBTag = app.Command("tag", "Apply a tag to the latest changeset in the database.")
cDBTagName = cDBTag.Arg("name", "Name of the tag [string].").Required().String()
cDBTagFile = cDBTag.Arg("file", "Filename of the migration file [string].").Required().String()

cDBStatus = app.Command("status", "Output the list of migrations already applied to the database.")
)

Expand Down Expand Up @@ -66,8 +70,12 @@ func main() {
r := rove.NewFileMigration(db, *cDBDownFile)
r.Verbose = true
err = r.Reset(*cDBDownCount)
case cDBTag.FullCommand():
r := rove.NewFileMigration(db, *cDBTagFile)
r.Verbose = true
err = r.Tag(*cDBTagName)
case cDBStatus.FullCommand():
r := rove.NewFileMigration(db, *cDBDownFile)
r := rove.NewFileMigration(db, "")
r.Verbose = true
_, err = r.Status()
}
Expand Down
11 changes: 7 additions & 4 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ type Changelog interface {
// Initialize should perform any work to set up the changelog or return an
// error.
Initialize() error
// BeginTx should start a transaction on the changelog.
BeginTx() (Transaction, error)
// ChangesetApplied should return the checksum from the changelog of a
// matching changeset, an error, or a blank string if the changeset doesn't
// exist in the changelog.
ChangesetApplied(id string, author string, filename string) (checksum string, err error)
// BeginTx should start a transaction on the changelog.
BeginTx() (Transaction, error)
// Changesets should return a list of the changesets or return an error.
Changesets(reverse bool) ([]Changeset, error)
// Count should return the number of changesets in the changelog or return
// an error.
Count() (count int, err error)
// Insert should add a new changeset to the changelog or return an error.
Insert(id, author, filename string, count int, checksum, description, version string) error
// Changesets should return a list of the changesets or return an error.
Changesets(reverse bool) ([]Changeset, error)
// Delete should remove the changeset from the changelog or return an error.
Delete(id, author, filename string) error
// Tag should add a tag to the latest changeset in the database or return
// an error.
Tag(id, author, filename, tag string) error
}

// Transaction represents a changelog transaction.
Expand Down
36 changes: 0 additions & 36 deletions pkg/adapter/mysql/jsonfile/io.go

This file was deleted.

168 changes: 0 additions & 168 deletions pkg/adapter/mysql/jsonfile/jsonfile.go

This file was deleted.

Loading

0 comments on commit 73afabc

Please sign in to comment.