dbmate 2.17.0 → 2.19.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 CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Dbmate is a database migration tool that will keep your database schema in sync across multiple developers and your production servers.
8
8
 
9
- It is a standalone command line tool that can be used with Go, Node.js, Python, Ruby, PHP, or any other language or framework you are using to write database-backed applications. This is especially helpful if you are writing multiple services in different languages, and want to maintain some sanity with consistent development tools.
9
+ It is a standalone command line tool that can be used with Go, Node.js, Python, Ruby, PHP, Rust, C++, or any other language or framework you are using to write database-backed applications. This is especially helpful if you are writing multiple services in different languages, and want to maintain some sanity with consistent development tools.
10
10
 
11
11
  For a comparison between dbmate and other popular database schema migration tools, please see [Alternatives](#alternatives).
12
12
 
@@ -23,6 +23,7 @@ For a comparison between dbmate and other popular database schema migration tool
23
23
  - [SQLite](#sqlite)
24
24
  - [ClickHouse](#clickhouse)
25
25
  - [BigQuery](#bigquery)
26
+ - [Spanner](#spanner)
26
27
  - [Creating Migrations](#creating-migrations)
27
28
  - [Running Migrations](#running-migrations)
28
29
  - [Rolling Back Migrations](#rolling-back-migrations)
@@ -41,15 +42,16 @@ For a comparison between dbmate and other popular database schema migration tool
41
42
 
42
43
  ## Features
43
44
 
44
- - Supports MySQL, PostgreSQL, SQLite, and ClickHouse.
45
- - Uses plain SQL for writing schema migrations.
46
- - Migrations are timestamp-versioned, to avoid version number conflicts with multiple developers.
47
- - Migrations are run atomically inside a transaction.
48
- - Supports creating and dropping databases (handy in development/test).
49
- - Supports saving a `schema.sql` file to easily diff schema changes in git.
50
- - Database connection URL is defined using an environment variable (`DATABASE_URL` by default), or specified on the command line.
51
- - Built-in support for reading environment variables from your `.env` file.
52
- - Easy to distribute, single self-contained binary.
45
+ - Supports MySQL, PostgreSQL, SQLite, and ClickHouse
46
+ - Uses plain SQL for writing schema migrations
47
+ - Migrations are timestamp-versioned, to avoid version number conflicts with multiple developers
48
+ - Migrations are run atomically inside a transaction
49
+ - Supports creating and dropping databases (handy in development/test)
50
+ - Supports saving a `schema.sql` file to easily diff schema changes in git
51
+ - Database connection URL is defined using an environment variable (`DATABASE_URL` by default), or specified on the command line
52
+ - Built-in support for reading environment variables from your `.env` file
53
+ - Easy to distribute, single self-contained binary
54
+ - Doesn't try to upsell you on a SaaS service
53
55
 
54
56
  ## Installation
55
57
 
@@ -84,7 +86,7 @@ $ sudo chmod +x /usr/local/bin/dbmate
84
86
  Install using [Scoop](https://scoop.sh)
85
87
 
86
88
  ```pwsh
87
- scoop install dbmate
89
+ $ scoop install dbmate
88
90
  ```
89
91
 
90
92
  **Docker**
@@ -103,20 +105,6 @@ If you wish to create or apply migrations, you will need to use Docker's [bind m
103
105
  $ docker run --rm -it --network=host -v "$(pwd)/db:/db" ghcr.io/amacneil/dbmate new create_users_table
104
106
  ```
105
107
 
106
- **Heroku**
107
-
108
- To use dbmate on Heroku, either use the NPM method, or store the linux binary in your git repository:
109
-
110
- ```sh
111
- $ mkdir -p bin
112
- $ curl -fsSL -o bin/dbmate https://github.com/amacneil/dbmate/releases/latest/download/dbmate-linux-amd64
113
- $ chmod +x bin/dbmate
114
- $ git add bin/dbmate
115
- $ git commit -m "Add dbmate binary"
116
- $ git push heroku master
117
- $ heroku run bin/dbmate --help
118
- ```
119
-
120
108
  ## Commands
121
109
 
122
110
  ```sh
@@ -290,18 +278,20 @@ DATABASE_URL="clickhouse://username:password@127.0.0.1:9000/database_name?on_clu
290
278
  [See other supported connection options](https://github.com/ClickHouse/clickhouse-go#dsn).
291
279
 
292
280
  #### BigQuery
281
+
293
282
  Follow the following format for `DATABASE_URL` when connecting to actual BigQuery in GCP:
294
283
 
295
284
  ```
296
285
  bigquery://projectid/location/dataset
297
286
  ```
287
+
298
288
  `projectid` (mandatory) - Project ID
299
289
 
300
290
  `dataset` (mandatory) - Dataset name within the Project
301
291
 
302
292
  `location` (optional) - Where Dataset is created
303
293
 
304
- *NOTE: Follow [this doc](https://cloud.google.com/docs/authentication/provide-credentials-adc) on how to set `GOOGLE_APPLICATION_CREDENTIALS` environment variable for proper Authentication*
294
+ _NOTE: Follow [this doc](https://cloud.google.com/docs/authentication/provide-credentials-adc) on how to set `GOOGLE_APPLICATION_CREDENTIALS` environment variable for proper Authentication_
305
295
 
306
296
  Follow the following format if trying to connect to a custom endpoint e.g. [BigQuery Emulator](https://github.com/goccy/bigquery-emulator)
307
297
 
@@ -311,6 +301,32 @@ bigquery://host:port/projectid/location/dataset?disable_auth=true
311
301
 
312
302
  `disable_auth` (optional) - Pass `true` to skip Authentication, use only for testing and connecting to emulator.
313
303
 
304
+ #### Spanner
305
+
306
+ Spanner support is currently limited to databases using the [PostgreSQL Dialect](https://cloud.google.com/spanner/docs/postgresql-interface), which must be chosen during database creation. For future Spanner with GoogleSQL support, see [this discussion](https://github.com/amacneil/dbmate/discussions/369).
307
+
308
+ Spanner with the Postgres interface requires that the [PGAdapter](https://cloud.google.com/spanner/docs/pgadapter) is running. Use the following format for `DATABASE_URL`, with the host and port set to where the PGAdapter is running:
309
+
310
+ ```shell
311
+ DATABASE_URL="spanner-postgres://127.0.0.1:5432/database_name?sslmode=disable"
312
+ ```
313
+
314
+ Note that specifying a username and password is not necessary, as authentication is handled by the PGAdapter (they will be ignored by the PGAdapter if specified).
315
+
316
+ Other options of the [postgres driver](#postgresql) are supported.
317
+
318
+ Spanner also doesn't allow DDL to be executed inside explicit transactions. You must therefore specify `transaction:false` on migrations that include DDL:
319
+
320
+ ```sql
321
+ -- migrate:up transaction:false
322
+ CREATE TABLE ...
323
+
324
+ -- migrate:down transaction:false
325
+ DROP TABLE ...
326
+ ```
327
+
328
+ Schema dumps are not currently supported, as `pg_dump` uses functions that are not provided by Spanner.
329
+
314
330
  ### Creating Migrations
315
331
 
316
332
  To create a new migration, run `dbmate new create_users_table`. You can name the migration anything you like. This will create a file `db/migrations/20151127184807_create_users_table.sql` in the current directory:
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveBinary = void 0;
3
+ exports.resolveBinary = resolveBinary;
4
4
  const node_process_1 = require("node:process");
5
5
  /**
6
6
  * Resolve path to dbmate for the current platform
@@ -23,5 +23,4 @@ function resolveBinary() {
23
23
  }
24
24
  }
25
25
  }
26
- exports.resolveBinary = resolveBinary;
27
26
  //# sourceMappingURL=resolveBinary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveBinary.js","sourceRoot":"","sources":["../src/resolveBinary.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAE9C;;KAEK;AACL,SAAgB,aAAa;IAC3B,MAAM,GAAG,GAAG,uBAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,MAAM,IAAI,GAAG,WAAW,uBAAQ,IAAI,mBAAI,cAAc,GAAG,EAAE,CAAC;IAE5D,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IACE,GAAG,IAAI,SAAS;YAChB,OAAO,GAAG,KAAK,QAAQ;YACvB,MAAM,IAAI,GAAG;YACb,GAAG,CAAC,IAAI,KAAK,kBAAkB,EAC/B,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,GAAG,CAAC,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;AACH,CAAC;AAlBD,sCAkBC"}
1
+ {"version":3,"file":"resolveBinary.js","sourceRoot":"","sources":["../src/resolveBinary.ts"],"names":[],"mappings":";;AAKA,sCAkBC;AAvBD,+CAA8C;AAE9C;;KAEK;AACL,SAAgB,aAAa;IAC3B,MAAM,GAAG,GAAG,uBAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,MAAM,IAAI,GAAG,WAAW,uBAAQ,IAAI,mBAAI,cAAc,GAAG,EAAE,CAAC;IAE5D,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IACE,GAAG,IAAI,SAAS;YAChB,OAAO,GAAG,KAAK,QAAQ;YACvB,MAAM,IAAI,GAAG;YACb,GAAG,CAAC,IAAI,KAAK,kBAAkB,EAC/B,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,GAAG,CAAC,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbmate",
3
- "version": "2.17.0",
3
+ "version": "2.19.0",
4
4
  "description": "A lightweight, framework-agnostic database migration tool",
5
5
  "repository": "https://github.com/amacneil/dbmate",
6
6
  "homepage": "https://github.com/amacneil/dbmate#readme",
@@ -24,12 +24,12 @@
24
24
  "build": "tsc --build"
25
25
  },
26
26
  "optionalDependencies": {
27
- "@dbmate/linux-ia32": "2.17.0",
28
- "@dbmate/linux-x64": "2.17.0",
29
- "@dbmate/linux-arm": "2.17.0",
30
- "@dbmate/linux-arm64": "2.17.0",
31
- "@dbmate/darwin-x64": "2.17.0",
32
- "@dbmate/darwin-arm64": "2.17.0",
33
- "@dbmate/win32-x64": "2.17.0"
27
+ "@dbmate/linux-ia32": "2.19.0",
28
+ "@dbmate/linux-x64": "2.19.0",
29
+ "@dbmate/linux-arm": "2.19.0",
30
+ "@dbmate/linux-arm64": "2.19.0",
31
+ "@dbmate/darwin-x64": "2.19.0",
32
+ "@dbmate/darwin-arm64": "2.19.0",
33
+ "@dbmate/win32-x64": "2.19.0"
34
34
  }
35
35
  }