Skip to content

Commit 8a062c3

Browse files
committed
Rename migrations to revisions
1 parent 553f922 commit 8a062c3

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

cmd/internal/add.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
var (
14-
migrationsDir = "migrations"
14+
revisionsDir = "revisions"
1515

1616
AddCmd = &Command{
1717
Usage: "add [comment]",
@@ -22,7 +22,7 @@ var (
2222
)
2323

2424
func revisionPath(id string) string {
25-
return filepath.Join(migrationsDir, id+".sql")
25+
return filepath.Join(revisionsDir, id+".sql")
2626
}
2727

2828
func openInEditor(path string) error {
@@ -46,8 +46,8 @@ func addCmd(cmd *Command, args []string) {
4646
comment = args[1]
4747
}
4848

49-
if err := os.MkdirAll(migrationsDir, os.FileMode(0755)); err != nil {
50-
fmt.Fprintf(os.Stderr, "%s %s: failed to create %s directory: %s", cmd.Argv0, args[0], migrationsDir, err)
49+
if err := os.MkdirAll(revisionsDir, os.FileMode(0755)); err != nil {
50+
fmt.Fprintf(os.Stderr, "%s %s: failed to create %s directory: %s", cmd.Argv0, args[0], revisionsDir, err)
5151
os.Exit(1)
5252
}
5353

@@ -59,7 +59,7 @@ func addCmd(cmd *Command, args []string) {
5959
}
6060

6161
rev := mgrt.NewRevision(author, comment)
62-
path := filepath.Join(migrationsDir, rev.ID+".sql")
62+
path := filepath.Join(revisionsDir, rev.ID+".sql")
6363

6464
f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, os.FileMode(0644))
6565

cmd/internal/cat.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func catCmd(cmd *Command, args []string) {
3131
os.Exit(1)
3232
}
3333

34-
info, err := os.Stat(migrationsDir)
34+
info, err := os.Stat(revisionsDir)
3535

3636
if err != nil {
3737
if os.IsNotExist(err) {
@@ -43,7 +43,7 @@ func catCmd(cmd *Command, args []string) {
4343
}
4444

4545
if !info.IsDir() {
46-
fmt.Fprintf(os.Stderr, "%s %s: %s is not a directory\n", cmd.Argv0, argv0, migrationsDir)
46+
fmt.Fprintf(os.Stderr, "%s %s: %s is not a directory\n", cmd.Argv0, argv0, revisionsDir)
4747
os.Exit(1)
4848
}
4949

cmd/internal/ls.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var LsCmd = &Command{
1616
}
1717

1818
func lsCmd(cmd *Command, args []string) {
19-
info, err := os.Stat(migrationsDir)
19+
info, err := os.Stat(revisionsDir)
2020

2121
if err != nil {
2222
if os.IsNotExist(err) {
@@ -28,15 +28,15 @@ func lsCmd(cmd *Command, args []string) {
2828
}
2929

3030
if !info.IsDir() {
31-
fmt.Fprintf(os.Stderr, "%s %s: %s is not a directory\n", cmd.Argv0, args[0], migrationsDir)
31+
fmt.Fprintf(os.Stderr, "%s %s: %s is not a directory\n", cmd.Argv0, args[0], revisionsDir)
3232
os.Exit(1)
3333
}
3434

3535
pad := 0
3636

3737
revs := make([]*mgrt.Revision, 0)
3838

39-
err = filepath.Walk(migrationsDir, func(path string, info os.FileInfo, err error) error {
39+
err = filepath.Walk(revisionsDir, func(path string, info os.FileInfo, err error) error {
4040
if err != nil {
4141
return err
4242
}

cmd/internal/run.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ sqlite3 however will accept a filepath, or the :memory: string, for example,
4040
}
4141

4242
func runCmd(cmd *Command, args []string) {
43-
info, err := os.Stat(migrationsDir)
43+
info, err := os.Stat(revisionsDir)
4444

4545
if err != nil {
4646
if os.IsNotExist(err) {
@@ -52,7 +52,7 @@ func runCmd(cmd *Command, args []string) {
5252
}
5353

5454
if !info.IsDir() {
55-
fmt.Fprintf(os.Stderr, "%s %s: %s is not a directory\n", cmd.Argv0, args[0], migrationsDir)
55+
fmt.Fprintf(os.Stderr, "%s %s: %s is not a directory\n", cmd.Argv0, args[0], revisionsDir)
5656
os.Exit(1)
5757
}
5858

@@ -93,7 +93,7 @@ func runCmd(cmd *Command, args []string) {
9393
}
9494

9595
if len(revs) == 0 {
96-
err := filepath.Walk(migrationsDir, func(path string, info os.FileInfo, err error) error {
96+
err := filepath.Walk(revisionsDir, func(path string, info os.FileInfo, err error) error {
9797
if err != nil {
9898
return err
9999
}

cmd/internal/sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func syncCmd(cmd *Command, args []string) {
7272

7373
defer db.Close()
7474

75-
if err := os.MkdirAll(migrationsDir, os.FileMode(0755)); err != nil {
75+
if err := os.MkdirAll(revisionsDir, os.FileMode(0755)); err != nil {
7676
fmt.Fprintf(os.Stderr, "%s %s: %s\n", cmd.Argv0, argv0, err)
7777
os.Exit(1)
7878
}
@@ -86,7 +86,7 @@ func syncCmd(cmd *Command, args []string) {
8686

8787
for _, rev := range revs {
8888
func() {
89-
f, err := os.OpenFile(filepath.Join(migrationsDir, rev.ID+".sql"), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, os.FileMode(0644))
89+
f, err := os.OpenFile(filepath.Join(revisionsDir, rev.ID+".sql"), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, os.FileMode(0644))
9090

9191
if err != nil {
9292
fmt.Fprintf(os.Stderr, "%s %s: failed to sync revisions: %s\n", cmd.Argv0, argv0, err)

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ initialize. To begin writing revisions simply invoke `mgrt add`,
3030

3131
$ mgrt add "My first revision"
3232

33-
this will create a new revision file in the `migrations` directory, and open
33+
this will create a new revision file in the `revisions` directory, and open
3434
it up for editting with the revision to write,
3535

3636
/*
@@ -84,15 +84,15 @@ code that was executed as part of that revision.
8484
mgrt also offers the ability to sync the revisions that have been performed on
8585
a database against what you have locally. This is achieved with `mgrt sync`, and
8686
just like before, this also takes the `-type` and `-dsn` flags. Lets delete the
87-
`migrations` directory that was created for us and do a `mgrt sync`.
87+
`revisions` directory that was created for us and do a `mgrt sync`.
8888

89-
$ rm -rf migrations
89+
$ rm -rf revisions
9090
$ mgrt ls
9191
$ mgrt sync -type sqlite3 -dsn acme.db
9292
$ mgrt ls
9393
20060102150405: Andrew Pillar <[email protected]> - My first revision
9494

95-
with `mgrt sync` you can easily view the migrations that have been run against
95+
with `mgrt sync` you can easily view the revisions that have been run against
9696
different databases.
9797

9898
## Database connection
@@ -130,7 +130,7 @@ revision can only be performed once, and cannot be undone. If you wish to undo
130130
a revision, then it is recommended to write another revision that does the
131131
inverse of the prior.
132132

133-
Revisions are stored in the `migrations` directory from where the `mgrt add`
133+
Revisions are stored in the `revisions` directory from where the `mgrt add`
134134
command was run. Each revision file is prefixed with a comment block header
135135
that contains metadata about the revision itself, such as the ID, the author and
136136
a short comment about the revision.

0 commit comments

Comments
 (0)