diff --git a/README.md b/README.md index da1a935..7fb5681 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,8 @@ # Migration -## Ignore for now as it's not production ready - -Initially started within a separate project of mine because of a desire for a migration tool -[See commit and message 06048d639eee4c994544091f0e8b4a255c021554](https://github.com/peeperklip/migration/commit/06048d639eee4c994544091f0e8b4a255c021554) From there on its restructuring, testing and developing - -Made public for my own testing/developing purposes as it's slightly less of a hassle to `go get` a public repository. Canges and features are made if i require them in my own projects ### Go get ```shell -go get https://github.com/peeperklip/migration@{COMMIT_HASH} +go get https://github.com/peeperklip/migration@0.0.1 # add the -u flag for updating ``` @@ -18,29 +12,31 @@ go get https://github.com/peeperklip/migration@{COMMIT_HASH} * as per https://github.com/golang-standards/project-layout/tree/master/cmd 3. create a file + function that you can exectute command line ``` +//Exexute in: $PROJECT_ROOT //File: $PROJECT_ROOT/cli/migration.go +//Execute as: func main() { mig := migrations.NewMigration( utils.CreateConnection(), "postgress", - "..") + ".") migrations.Init(*mig) } ``` ### Architecture: -main.go Is the entry point for the CLI
+app.go Is the entry point for the CLI
dialect.go Will eventually be used to support multiple SQL dialects
migration.go Holds all the logic for managing migrations
-dbUtils.go In there to do more supporting tasks
### Codestyle: structs go first, interfaces second, then the methods, then general functions. Besides that it's pretty much just `gofmt .` -### To be improved +### To be improved in 0.0.2 and 0.0.3: * The unsustainable swtich case in dialect.go * The typejuggeling througout migration.go * The last few methods in migration.go should be moved to its own file and struct * Inject a logger -* unify output and make it swapable +* unify output and make more of the underlying code swapable +* general improvements throughout as well as a better distinction between exported and unexported methods \ No newline at end of file diff --git a/app.go b/app.go index d8d3283..5ab0cdb 100644 --- a/app.go +++ b/app.go @@ -55,15 +55,14 @@ func Init(migrate migration) { func outputHelpText() { w := new(tabwriter.Writer) - // Format in tab-separated columns with a tab stop of 8. w.Init(os.Stdout, 0, 8, 0, '\t', 0) _, _ = fmt.Println("Usage: go cli/migrations.go [COMMAND]") _, _ = fmt.Println() _, _ = fmt.Println("Available commands:") _, _ = fmt.Fprintln(w, "\tgenerate \t This generates a new migration") _, _ = fmt.Fprintln(w, "\tmigrate \t Run the migrations") - _, _ = fmt.Fprintln(w, "\tdown \t Undo a specific migration according to down.sql") - _, _ = fmt.Fprintln(w, "\trevert \t Undo all migrations according to down.sql until, but >not< including the specified migration") + _, _ = fmt.Fprintln(w, "\tdown \t the last ran migration according to down.sql") + _, _ = fmt.Fprintln(w, "\trevert \t Revert to a specific migration") _, _ = fmt.Fprintln(w, "\tstatus \t Warn about any migration that hasn't run") _, _ = fmt.Fprintln(w) diff --git a/dbUtil.go b/dbUtil.go deleted file mode 100644 index c4cba55..0000000 --- a/dbUtil.go +++ /dev/null @@ -1,9 +0,0 @@ -package migrations - -type DBUtil struct { -} - -func (dbutil DBUtil) bootstrap() { - //check if MigrationTable Exists - //Create migration table if not exists -}