Redgate Flyway

Tutorial - Connect to a database using Oracle Cloud Infrastructure (OCI)

FLYWAY TEAMS

Prerequisites

  1. Flyway Teams
  2. Oracle Instant Client installed (for capabilities requiring Redgate comparison technology)
  3. Have a user with permissions to connect to Oracle Cloud instance 
  4. An Oracle Wallet configured with credentials for the target database
  5. The wallet files (cwallet.sso and/or ewallet.p12) available on the machine running Flyway
  6. The TNS_ADMIN environment variable pointing to the location containing your tnsnames.ora  file

Setting up the wallet

If you do not already have an Oracle Wallet configured, use the mkstore utility to create one. Normally, mkstore comes with the full Oracle Client :

# Create a new wallet
mkstore -wrl /path/to/wallet -create

# Add credentials for a database connection
mkstore -wrl /path/to/wallet -createCredential prod-db-alias prod_user prod_password

# Check existing credentials
mkstore -wrl /path/to/wallet -listCredential

NOTE: If you have an Autonomous Database, the Oracle Wallet can also be obtained by by logging into Oracle Cloud Console, navigating to your Autonomous Database instance, clicking DB Connection, and selecting "Download Wallet".

The alias (prod-db-alias ) must match an entry in your tnsnames.ora  file:

prod-db-alias =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod-oracle-host)(PORT = 1521))
    (CONNECT_DATA = (SERVICE_NAME = ORCL))
  )

  1. Ensure the sqlnet.ora  file points to the wallet location and append SQLNET.WALLET_OVERRIDE = TRUE to the end of this file which forces Oracle Client to use Wallet Authentication:

WALLET_LOCATION =
  (SOURCE =
    (METHOD = FILE)
    (METHOD_DATA =
      (DIRECTORY = /path/to/wallet)
    )
  )

SQLNET.WALLET_OVERRIDE = TRUE

Configuring Flyway

Point Flyway to the wallet directory using the oracle.walletLocation  parameter. No user  or password  is needed.

Either configure this in your TOML configuration

[environments.production]
url = "jdbc:oracle:thin:@prod-db-alias"

[flyway.oracle]
walletLocation = "/path/to/wallet"

Or specify directly on the command-line

flyway info \
  -url="jdbc:oracle:thin:@prod-db-alias" \
  -oracle.walletLocation="/path/to/wallet"

 Adjust the JDBC URL according to your needs. The @prod-db-alias  needs to the same connection string associated to the connecting user in the Oracle Wallet. 

Note: For commands which rely upon Redgate comparison technology, such as diff, generate, or prepare, connecting to OCI using wallet only works on Windows with the Oracle Instant Client installed.

From the Flyway Desktop connection dialog:

  1. Set the username - Enter just a space e.g. " ", since a username is required in the UI however you will be using the credentials via the Oracle wallet 
  2. Leave the password blank
  3. Enter the JDBC URL, use one of the TNS name alias provided by OCI e.g.  jdbc:oracle:thin:@<TNS_ALIAS>


Note: For functionality relying upon Redgate comparison technology, including all operations relating to the schema model, connecting to OCI using wallet only works on Windows with the Oracle Instant Client installed.

Troubleshooting

If connection fails, verify that:

  • The wallet files (cwallet.sso ) exist at the configured walletLocation
  • The alias in the JDBC URL matches an entry in tnsnames.ora 
  • The sqlnet.ora  file has SQLNET.WALLET_OVERRIDE = TRUE 

Reference


Didn't find what you were looking for?