Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dz0ny committed Aug 11, 2023
1 parent 8ae0c5e commit 09cc429
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@ Utilizing the native PostgreSQL COPY command, pg-subsetter performs data transfe
```
Usage of subsetter:
-dst string
Destination DSN
Destination database DSN
-f float
Fraction of rows to copy (default 0.05)
-force value
Query to copy required tables (users: id = 1)
-src string
Source DSN
Source database DSN
```


Example:
### Example

```pg-subsetter -src postgresql://:@/bigdb -dst postgresql://:@/littledb -f 0.05```
```
pg-subsetter
-src postgresql://:@/bigdb
-dst postgresql://:@/littledb
-f 0.05
-force "users: id = 1"
-force "groups: id = 12"
```

# Installing

Expand Down
14 changes: 14 additions & 0 deletions cli/force.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import "strings"

type arrayForce []string

func (i *arrayForce) String() string {
return "users:id=1"
}

func (i *arrayForce) Set(value string) error {
*i = append(*i, strings.TrimSpace(value))
return nil
}
3 changes: 2 additions & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
var src = flag.String("src", "", "Source database DSN")
var dst = flag.String("dst", "", "Destination database DSN")
var fraction = flag.Float64("f", 0.05, "Fraction of rows to copy")
var forceSync arrayForce

func main() {
flag.Var(&forceSync, "force", "Query to copy required tables (users: id = 1)")
flag.Parse()
log.Info().Msg("Starting")

if *src == "" || *dst == "" {
log.Fatal().Msg("Source and destination DSNs are required")
Expand Down
1 change: 0 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
golangci-lint
postgresql
process-compose
shellcheck
nixpkgs-fmt
pgweb
];
Expand Down

0 comments on commit 09cc429

Please sign in to comment.