Skip to content

Commit 64dd4ca

Browse files
Add support for mongo-driver v2
1 parent 2788339 commit 64dd4ca

File tree

7 files changed

+878
-26
lines changed

7 files changed

+878
-26
lines changed

build/migrate.linux-386

51.5 MB
Binary file not shown.

database/mongodb/v2/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# MongoDB
2+
3+
* This package is for [mongo-go-driver/v2]. A backend for the older [monog-go-driver/v1]. is [also available](..).
4+
* Driver work with mongo through [db.runCommands](https://docs.mongodb.com/manual/reference/command/)
5+
* Migrations support json format. It contains array of commands for `db.runCommand`. Every command is executed in separate request to database
6+
* All keys have to be in quotes `"`
7+
* [Examples](./examples)
8+
9+
# Usage
10+
11+
`mongodb://user:password@host:port/dbname?query` (`mongodb+srv://` also works, but behaves a bit differently. See [docs](https://docs.mongodb.com/manual/reference/connection-string/#dns-seedlist-connection-format) for more information)
12+
13+
| URL Query | WithInstance Config | Description |
14+
|------------|---------------------|-------------|
15+
| `x-migrations-collection` | `MigrationsCollection` | Name of the migrations collection |
16+
| `x-transaction-mode` | `TransactionMode` | If set to `true` wrap commands in [transaction](https://docs.mongodb.com/manual/core/transactions). Available only for replica set. Driver is using [strconv.ParseBool](https://golang.org/pkg/strconv/#ParseBool) for parsing|
17+
| `x-advisory-locking` | `true` | Feature flag for advisory locking, if set to false, disable advisory locking |
18+
| `x-advisory-lock-collection` | `migrate_advisory_lock` | The name of the collection to use for advisory locking.|
19+
| `x-advisory-lock-timeout` | `15` | The max time in seconds that migrate will wait to acquire a lock before failing. |
20+
| `x-advisory-lock-timeout-interval` | `10` | The max time in seconds between attempts to acquire the advisory lock, the lock is attempted to be acquired using an exponential backoff algorithm. |
21+
| `dbname` | `DatabaseName` | The name of the database to connect to |
22+
| `user` | | The user to sign in as. Can be omitted |
23+
| `password` | | The user's password. Can be omitted |
24+
| `host` | | The host to connect to |
25+
| `port` | | The port to bind to |

0 commit comments

Comments
 (0)