-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
77 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
lint: | ||
golangci-lint run | ||
|
||
build: | ||
go build -o mover ./cmd/mover/ | ||
|
||
test: | ||
go test ./... -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
# mover | ||
|
||
`mover` is a simple utility to extract data from a remote database server and load them in another environment. | ||
`mover` is used to extract data from a remote database server and load them in another environment. | ||
|
||
It uses the underlying introspection API from the RDMS to retrieve relationships from the extracted results. | ||
It uses the underlying introspection API from the RDMS to retrieve relationships | ||
(foreign keys, reference keys, etc.) based on results from your database schema. | ||
|
||
## How do we use it internally? | ||
|
||
Instead of harcoding fixtures for each workflows, we export data from our production database by sanitizing | ||
sensible data (password, personal user information, etc.). | ||
|
||
Thanks to this tool, we don't have to maintain anymore fixtures and we can | ||
quickly reply production bugs in our local environment. | ||
Thanks to this tool, we don't have to maintain fixtures anymore and we can | ||
quickly replicate a production bug in our local environment. | ||
|
||
## Usage | ||
|
||
|
@@ -29,11 +30,13 @@ mkdir -p output | |
Extract data from backup database: | ||
|
||
```console | ||
go run cmd/mover/main.go -dsn "postgresql://user:[email protected]:5432/dbname" -path output -action extract -query "SELECT * FROM user WHERE id = 1" -table "user" | ||
export REMOTE_DSN="postgresql://user:[email protected]:5432/dbname" | ||
go run cmd/mover/main.go -dsn $REMOTE_DSN -path output -action extract -query "SELECT * FROM user WHERE id = 1" -table "user" | ||
``` | ||
|
||
Load data to your local database: | ||
|
||
```console | ||
go run cmd/mover/main.go -dsn "postgresql://user:password@localhost:5432/dbname" -path output -action load | ||
export LOCAL_DSN="postgresql://user:password@localhost:5432/dbname" | ||
go run cmd/mover/main.go -dsn $LOCAL_DSN -path output -action load | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters