Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mirzakhany committed Sep 13, 2022
1 parent 4c973de commit 5f17f7c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,44 @@ To install `dbctl` from it source:
go install github.com/mirzakhany/dbctl@latest
```

## How to use
to run a postgres instance you can run:

```shell
dbctl start pg
```
this command with start a postgis instance using docker engine on port `15432`, with `postgres` as default username,password and db name.
to get more detail run
```shell
dbctl start pg --help
```
```shell
Usage:
dbctl start pg [flags]

Flags:
-f, --fixtures string Path to fixture files, its can be a file or directory.files in directory will be sorted by name before applying.
-h, --help help for pg
-m, --migrations string Path to migration files, will be applied if provided
-n, --name string Database name (default "postgres")
--pass string Database password (default "postgres")
-p, --port uint32 postgres default port (default 15432)
-u, --user string Database username (default "postgres")
-v, --version string Database version, default for native 14.3.0 and 14.3.2 for docker engine
```
an example to run migrations and apply fixtures with be like this:
```shell
dbctl start pg -m ./migrations -f ./testdata
```
Out put:
```shell
2022/09/13 21:28:02 Starting postgres version 13-3.1 on port 15432 ...
2022/09/13 21:28:04 Wait for database to boot up
2022/09/13 21:28:07 Postgres is up and running
2022/09/13 21:28:07 Applying migrations ...
2022/09/13 21:28:07 Applying fixtures ...
2022/09/13 21:28:07 Database uri is: "postgres://postgres:postgres@localhost:65432/postgres?sslmode=disable"
```
2 changes: 1 addition & 1 deletion internal/cmd/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func GetPgCmd() *cobra.Command {
cmd.Flags().StringP("name", "n", "postgres", "Database name")
cmd.Flags().StringP("version", "v", "", "Database version, default for native 14.3.0 and 14.3.2 for docker engine")
cmd.Flags().StringP("migrations", "m", "", "Path to migration files, will be applied if provided")
cmd.Flags().StringP("fixtures", "f", "", "Fixture files, will be applied if provided, files will be sorted by name before apply")
cmd.Flags().StringP("fixtures", "f", "", "Path to fixture files, its can be a file or directory.files in directory will be sorted by name before applying.")

return cmd
}
Expand Down

0 comments on commit 5f17f7c

Please sign in to comment.