dbmate 2.30.0 → 2.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -14
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -111,18 +111,19 @@ docker run --rm -it --network=host -v "$(pwd)/db:/db" ghcr.io/amacneil/dbmate ne
|
|
|
111
111
|
## Commands
|
|
112
112
|
|
|
113
113
|
```sh
|
|
114
|
-
dbmate --help
|
|
115
|
-
dbmate new
|
|
116
|
-
dbmate up
|
|
117
|
-
dbmate create
|
|
118
|
-
dbmate drop
|
|
119
|
-
dbmate migrate
|
|
120
|
-
dbmate rollback
|
|
121
|
-
dbmate down
|
|
122
|
-
dbmate status
|
|
123
|
-
dbmate dump
|
|
124
|
-
dbmate
|
|
125
|
-
dbmate
|
|
114
|
+
dbmate --help # print usage help
|
|
115
|
+
dbmate new # generate a new migration file
|
|
116
|
+
dbmate up # create the database (if it does not already exist) and run any pending migrations
|
|
117
|
+
dbmate create # create the database
|
|
118
|
+
dbmate drop # drop the database
|
|
119
|
+
dbmate migrate # run any pending migrations
|
|
120
|
+
dbmate rollback # roll back the most recent migration
|
|
121
|
+
dbmate down # alias for rollback
|
|
122
|
+
dbmate status # show the status of all migrations (supports --exit-code and --quiet)
|
|
123
|
+
dbmate dump # write the database schema.sql file
|
|
124
|
+
dbmate dump -- [...] # optionally pass additional arguments directly to mysqldump or pg_dump
|
|
125
|
+
dbmate load # load schema.sql file to the database
|
|
126
|
+
dbmate wait # wait for the database server to become available
|
|
126
127
|
```
|
|
127
128
|
|
|
128
129
|
### Command Line Options
|
|
@@ -130,6 +131,7 @@ dbmate wait # wait for the database server to become available
|
|
|
130
131
|
The following options are available with all commands. You must use command line arguments in the order `dbmate [global options] command [command options]`. Most options can also be configured via environment variables (and loaded from your `.env` file, which is helpful to share configuration between team members).
|
|
131
132
|
|
|
132
133
|
- `--url, -u "protocol://host:port/dbname"` - specify the database url directly. _(env: `DATABASE_URL`)_
|
|
134
|
+
- `--driver "driver_name"` - specify the driver to use (if empty, the driver is derived from database URL scheme). _(env: `DBMATE_DRIVER`)_
|
|
133
135
|
- `--env, -e "DATABASE_URL"` - specify an environment variable to read the database connection URL from.
|
|
134
136
|
- `--env-file ".env"` - specify an alternate environment variables file(s) to load.
|
|
135
137
|
- `--migrations-dir, -d "./db/migrations"` - where to keep the migration files. _(env: `DBMATE_MIGRATIONS_DIR`)_
|
|
@@ -207,6 +209,18 @@ A `socket` or `host` parameter can be specified to connect through a unix socket
|
|
|
207
209
|
DATABASE_URL="postgres://username:password@/database_name?socket=/var/run/postgresql"
|
|
208
210
|
```
|
|
209
211
|
|
|
212
|
+
For passwordless authentication such as PostgreSQL [peer auth](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html), the password can be omitted (note the `@` is still required):
|
|
213
|
+
|
|
214
|
+
```sh
|
|
215
|
+
DATABASE_URL="postgres://username@/database_name?socket=/var/run/postgresql"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
If the username is also omitted, it defaults to the `PGUSER` environment variable if set, otherwise the OS username (via `lib/pq`, matching `libpq` behavior):
|
|
219
|
+
|
|
220
|
+
```sh
|
|
221
|
+
DATABASE_URL="postgres:///database_name?socket=/var/run/postgresql"
|
|
222
|
+
```
|
|
223
|
+
|
|
210
224
|
A `search_path` parameter can be used to specify the [current schema](https://www.postgresql.org/docs/13/ddl-schemas.html#DDL-SCHEMAS-PATH) while applying migrations, as well as for dbmate's `schema_migrations` table.
|
|
211
225
|
If the schema does not exist, it will be created automatically. If multiple comma-separated schemas are passed, the first will be used for the `schema_migrations` table.
|
|
212
226
|
|
|
@@ -255,10 +269,42 @@ Otherwise the migration will fail with "Error: cannot change into wal mode from
|
|
|
255
269
|
|
|
256
270
|
#### ClickHouse
|
|
257
271
|
|
|
272
|
+
Dbmate supports connecting to ClickHouse using native TCP (default) or HTTP/HTTPS.
|
|
273
|
+
|
|
274
|
+
##### Native (TCP)
|
|
275
|
+
|
|
276
|
+
By default, the `clickhouse://` scheme uses the native protocol on port `9000`.
|
|
277
|
+
|
|
258
278
|
```sh
|
|
259
279
|
DATABASE_URL="clickhouse://username:password@127.0.0.1:9000/database_name"
|
|
260
280
|
```
|
|
261
281
|
|
|
282
|
+
##### HTTP / HTTPS
|
|
283
|
+
|
|
284
|
+
You can use `clickhouse+http://` (deafult port 8123) or `clickhouse+https://` (default port 8443).
|
|
285
|
+
|
|
286
|
+
```sh
|
|
287
|
+
# HTTP (Defaults to port 8123)
|
|
288
|
+
DATABASE_URL="clickhouse+http://username:password@127.0.0.1:8123/database_name"
|
|
289
|
+
|
|
290
|
+
# HTTPS (Defaults to port 8443)
|
|
291
|
+
DATABASE_URL="clickhouse+https://username:password@127.0.0.1:8443/database_name"
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
##### Using the --driver flag
|
|
295
|
+
|
|
296
|
+
You can use the ClickHouse driver with a standard http/https/tcp URL by providing the --driver flag
|
|
297
|
+
|
|
298
|
+
```sh
|
|
299
|
+
# Connect via HTTP using generic URL syntax
|
|
300
|
+
dbmate --driver clickhouse --url "http://username:password@127.0.0.1:8123/database_name" status
|
|
301
|
+
|
|
302
|
+
dbmate --driver clickhouse --url "https://username:password@127.0.0.1:8443/database_name" status
|
|
303
|
+
|
|
304
|
+
# Better to rely on the standard clickhouse:// scheme, but this is supported
|
|
305
|
+
dbmate --driver clickhouse --url "tcp://username:password@127.0.0.1:9000/database_name" status
|
|
306
|
+
```
|
|
307
|
+
|
|
262
308
|
To work with ClickHouse cluster, there are 4 connection query parameters that can be supplied:
|
|
263
309
|
|
|
264
310
|
- `on_cluster` - Indicataion to use cluster statements and replicated migration table. (default: `false`) If this parameter is not supplied, other cluster related query parameters are ignored.
|
|
@@ -482,14 +528,26 @@ When you run the `up`, `migrate`, or `rollback` commands, dbmate will automatica
|
|
|
482
528
|
It is recommended to check this file into source control, so that you can easily review changes to the schema in commits or pull requests. It's also possible to use this file when you want to quickly load a database schema, without running each migration sequentially (for example in your test harness). However, if you do not wish to save this file, you could add it to your `.gitignore`, or pass the `--no-dump-schema` command line option.
|
|
483
529
|
|
|
484
530
|
To dump the `schema.sql` file without performing any other actions, run `dbmate dump`. Unlike other dbmate actions, this command relies on the respective `pg_dump`, `mysqldump`, or `sqlite3` commands being available in your PATH. If these tools are not available, dbmate will silently skip the schema dump step during `up`, `migrate`, or `rollback` actions. You can diagnose the issue by running `dbmate dump` and looking at the output:
|
|
485
|
-
|
|
486
531
|
```sh
|
|
487
532
|
$ dbmate dump
|
|
488
533
|
exec: "pg_dump": executable file not found in $PATH
|
|
489
534
|
```
|
|
490
|
-
|
|
491
535
|
On Ubuntu or Debian systems, you can fix this by installing `postgresql-client`, `mysql-client`, or `sqlite3` respectively. Ensure that the package version you install is greater than or equal to the version running on your database server.
|
|
492
536
|
|
|
537
|
+
It is possible to pass additional arguments directly to mysqldump or pg_dump:
|
|
538
|
+
```sh
|
|
539
|
+
$ dbmate dump -- --flag1 --flag2
|
|
540
|
+
$ dbmate --url="..." dump -- --restrict-key=restrict_key
|
|
541
|
+
```
|
|
542
|
+
for mysqldump:
|
|
543
|
+
```sh
|
|
544
|
+
mysqldump [default_options] [your_arguments_go_here] dbname
|
|
545
|
+
```
|
|
546
|
+
for pg_dump:
|
|
547
|
+
```sh
|
|
548
|
+
pg_dump [default_options] [your_arguments_go_here] dbname
|
|
549
|
+
```
|
|
550
|
+
|
|
493
551
|
> Note: The `schema.sql` file will contain a complete schema for your database, even if some tables or columns were created outside of dbmate migrations.
|
|
494
552
|
|
|
495
553
|
## Library
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbmate",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.31.0",
|
|
4
4
|
"description": "A lightweight, framework-agnostic database migration tool",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"build": "tsc --build"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"@dbmate/linux-ia32": "2.
|
|
34
|
-
"@dbmate/linux-x64": "2.
|
|
35
|
-
"@dbmate/linux-arm": "2.
|
|
36
|
-
"@dbmate/linux-arm64": "2.
|
|
37
|
-
"@dbmate/darwin-x64": "2.
|
|
38
|
-
"@dbmate/darwin-arm64": "2.
|
|
39
|
-
"@dbmate/win32-x64": "2.
|
|
33
|
+
"@dbmate/linux-ia32": "2.31.0",
|
|
34
|
+
"@dbmate/linux-x64": "2.31.0",
|
|
35
|
+
"@dbmate/linux-arm": "2.31.0",
|
|
36
|
+
"@dbmate/linux-arm64": "2.31.0",
|
|
37
|
+
"@dbmate/darwin-x64": "2.31.0",
|
|
38
|
+
"@dbmate/darwin-arm64": "2.31.0",
|
|
39
|
+
"@dbmate/win32-x64": "2.31.0"
|
|
40
40
|
}
|
|
41
41
|
}
|