-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'postgresql-dialect' into gorm-pilot-support
- Loading branch information
Showing
6 changed files
with
72 additions
and
6 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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# PGAdapter - Liquibase Connection Options | ||
|
||
PGAdapter has Pilot Support for [Liquibase](https://www.liquibase.org/) version v4.12.0 and higher. | ||
|
||
## Limitations | ||
Pilot Support means that it is possible to use `Liquibase` with Cloud Spanner PostgreSQL databases, | ||
but with limitations. This means that porting an existing application from PostgreSQL to Cloud Spanner | ||
will probably require code changes. See [Limitations](../samples/java/liquibase/README.md#limitations) | ||
in the `Liquibase` sample directory for a full list of limitations. | ||
|
||
## Usage | ||
|
||
|
||
### Start PGAdapter | ||
First start PGAdapter: | ||
|
||
```shell | ||
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json | ||
docker pull gcr.io/cloud-spanner-pg-adapter/pgadapter | ||
docker run \ | ||
-d -p 5432:5432 \ | ||
-v ${GOOGLE_APPLICATION_CREDENTIALS}:${GOOGLE_APPLICATION_CREDENTIALS}:ro \ | ||
-e GOOGLE_APPLICATION_CREDENTIALS \ | ||
gcr.io/cloud-spanner-pg-adapter/pgadapter \ | ||
-p my-project -i my-instance \ | ||
-x | ||
``` | ||
|
||
### Create databasechangelog and databasechangeloglock Manually | ||
The `databasechangeloglock` and `databasechangelog` tables **must** be created manually, as the | ||
DDL script that is automatically generated by Liquibase will try to use the data type | ||
`timestamp without time zone`, which is not supported by Cloud Spanner. The DDL script to create | ||
these tables manually can be found in [create_database_change_log.sql](../samples/java/liquibase/create_database_change_log.sql). | ||
|
||
### Connect Liquibase to PGAdapter | ||
Liquibase will by default use DDL transactions when connecting to PostgreSQL databases. This is not | ||
supported by Cloud Spanner. Instead, PGAdapter can automatically convert DDL transactions into DDL | ||
batches. This requires the following option to be set in the JDBC connection URL: | ||
|
||
```properties | ||
url: jdbc:postgresql://localhost:5432/liquibase-test?options=-c%20spanner.ddl_transaction_mode=AutocommitExplicitTransaction | ||
``` | ||
|
||
See [liquibase.properties](../samples/java/liquibase/liquibase.properties) for an example connection URL. | ||
|
||
### Run Liquibase | ||
Run Liquibase using for example the Maven plugin: | ||
|
||
```shell | ||
mvn liquibase:validate | ||
``` | ||
|
||
## Full Sample and Limitations | ||
[This directory](../samples/java/liquibase) contains a full sample of how to work with `Liquibase` with | ||
Cloud Spanner and PGAdapter. The sample readme file also lists the [current limitations](../samples/java/liquibase) | ||
when working with `Liquibase`. |
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
3 changes: 3 additions & 0 deletions
3
samples/java/hibernate/src/main/resources/hibernate.properties
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