Skip to content

Commit

Permalink
Bump version to flyway-10.12.0
Browse files Browse the repository at this point in the history
Please see the GH release for the release notes

enable repeatable and versioned migration types in `ignoreMigrationPatterns`

Add datatype to debug log
  • Loading branch information
rg-buildmonkey committed Apr 29, 2024
1 parent b674678 commit 2bb4305
Show file tree
Hide file tree
Showing 60 changed files with 282 additions and 141 deletions.
44 changes: 36 additions & 8 deletions documentation/Flyway CLI and API/Commands/Auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,34 @@ You can find the `Flyway CLI` directory here: `~/.config/Redgate/Flyway CLI`.
| -startTeamsTrial | All | Starts a Teams trial
| -startEnterpriseTrial | All | Starts an Enterprise trial

#### Personal Access Tokens (PATs)

Users can specify a Redgate email and personal access token that can be used to non-interactively authorize Flyway without needing to run the `auth` command. If an email and PAT token
are configured, Flyway can be used normally and will be licensed to the edition of Flyway you have access to assuming you are working in an environment that is connected to the internet.
PATs can be generated at this [link](https://identityprovider.red-gate.com/personaltokens).

Redgate emails and PATs are respectively configured using the `email` and `token` configuration parameters in the TOML configuration file, on the commandline, or by using the `FLYWAY_EMAIL`
and `FLYWAY_TOKEN` environment variables. Here are some examples of how to use PATs:

Commandline:
```
flyway info -email=foo.bar@red-gate.com -token=1234ABCD
```

TOML:
```toml
[flyway]
email = "foo.bar@red-gate.com"
token = "1234ABCD"
```

Environment variables:
```shell
export FLYWAY_EMAIL=foo.bar@red-gate.com
export FLYWAY_TOKEN=1234ABCD
```

Using a personal access token will store a license permit in the Redgate app data folder, the same location as when running the `auth` command.

#### Environment Variables

Expand All @@ -47,20 +75,20 @@ There are multiple ways to authorize Flyway. The following list shows the order

1. `REDGATE_LICENSING_PERMIT_PATH` environment variable
2. `REDGATE_LICENSING_PERMIT` environment variable
3. License permit located in the `Flyway CLI` directory of the Redgate app data folder, saved to disk by running the `auth` command (both the online and offline flow save the
license permit to the same location)
3. License permit located in the `Flyway CLI` directory of the Redgate app data folder, saved to disk by running the `auth` command or by having run Flyway with an email and PAT specified
at least once (the online interactive flow, non-interactive online personal access token flow, and offline flow all save the license permit to the same location)
4. [License key](Configuration/Parameters/Flyway/License Key)

#### Refresh Tokens

When `auth` is run successfully, a refresh token is saved to disk in the `Flyway CLI` directory of the Redgate app data folder. This refresh token is used to
automatically refresh a user's license permit when it expires. Each time a license permit is refreshed, a new refresh token is saved to disk, replacing the existing
refresh token. This only applies to expired license permits in the `Flyway CLI` directory of the Redgate app data folder—Flyway will not automatically refresh expired license
permits specified by environment variables.
When `auth` is run successfully or a PAT successfully retrieves a license permit, a refresh token is saved to disk in the `Flyway CLI` directory of the Redgate app data folder.
This refresh token is used to automatically refresh a user's license permit when it expires. Each time a license permit is refreshed, a new refresh token is saved to disk,
replacing the existing refresh token. This only applies to expired license permits in the `Flyway CLI` directory of the Redgate app data folder—Flyway will not automatically
refresh expired license permits specified by environment variables.

#### Logout

`auth -logout` can be run to log out of an authorized session of Flyway. Under the hood, logging out simply deletes the license permit and refresh token stored on disk in the
Redgate app data folder. Assuming no other methods of authorization are in use (such as a permit environment variable or legacy license key environment variable), the user will be
logged out of their session and Flyway will run as Community Edition. If a valid permit environment variable or legacy license key environment variable is set, Flyway will still
Redgate app data folder. Assuming no other methods of authorization are in use (such as a permit environment variable, a legacy license key environment variable, or a PAT token), the user will be
logged out of their session and Flyway will run as Community Edition. If a valid permit environment variable, legacy license key environment variable, or PAT token is set, Flyway will still
honor these as authorizations and logout will not remove them.
13 changes: 8 additions & 5 deletions documentation/Flyway CLI and API/Concepts/Callback concept.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
subtitle: Callbacks
redirect_from: /documentation/callbacks/
---

# Callbacks

While migrations are sufficient for most needs, there are certain situations that require you to <strong>execute the same action
Expand Down Expand Up @@ -32,11 +33,11 @@ These are the events Flyway supports:
<td>Before every single migration during Migrate</td>
</tr>
<tr id="beforeEachMigrateStatement">
<td>beforeEachMigrateStatement <br>{% include redgate.html %}</td>
<td>beforeEachMigrateStatement</td>
<td>Before every single statement of a migration during Migrate</td>
</tr>
<tr id="afterEachMigrateStatement">
<td>afterEachMigrateStatement <br>{% include redgate.html %}</td>
<td>afterEachMigrateStatement</td>
<td>After every single successful statement of a migration during Migrate</td>
</tr>
<tr id="afterEachMigrateStatementError">
Expand Down Expand Up @@ -254,14 +255,16 @@ These are the events Flyway supports:

Callbacks can be implemented either in SQL or in Java.

## Location
Flyway will discover SQL callbacks in the same manner as SQL migration scripts, based on the [locations](Configuration/parameters/flyway/locations) defined.

Whereas Java callbacks will be picked up from the classpath.

## SQL Callbacks

The most convenient way to hook into Flyway's lifecycle is through SQL callbacks. These are simply sql files
in the configured locations following a certain naming convention: the event name followed by the SQL migration suffix.

Using the default settings, Flyway looks in its default locations (&lt;install_dir&gt;/sql) for the Command-line tool)
for SQL files like `beforeMigrate.sql`, `beforeEachMigrate.sql`, `afterEachMigrate.sql`, ...

Placeholder replacement works just like it does for <a href="Concepts/migrations#sql-based-migrations">SQL migrations</a>.

Optionally the callback may also include a description. In that case the callback name is composed of the event name,
Expand Down
5 changes: 5 additions & 0 deletions documentation/Flyway CLI and API/Configuration/Parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ subtitle: placeholder page
- [validateOnMigrate](configuration/parameters/flyway/Validate On Migrate)
- [workingDirectory](configuration/parameters/flyway/Working Directory)

### Redgate Authentication

- [email](configuration/parameters/flyway/email)
- [token](configuration/parameters/flyway/token)

### Schema
- [createSchemas](configuration/parameters/flyway/Create Schemas)
- [defaultSchema](configuration/parameters/flyway/Default Schema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ See also the [Change Report Concept](<Concepts/Check Changes Concept>) page

### Commandline
```powershell
./flyway check -changes -environment=prod -buildEnvironment=build
./flyway check -changes -environment=prod -check.buildEnvironment=build
```
- [`environment`](Configuration/Parameters/Flyway/Environment) - This would typically be your target/production environment
- If you can't access your target database from your build environment you should use [`check.appliedMigrations`](<Configuration/Parameters/Flyway/Check/Applied Migrations>) with the list of migrations that represent the current state if your target.
- You could alternatively use a snapshot of your target database instead and tell Flyway to use this via [`check.deployedSnapshot`](<Configuration/Parameters/Flyway/Check/Deployed Snapshot>)
- [`buildEnvironment`](<Configuration/Parameters/Flyway/Check/Build Environment>) - This is where Flyway will populate the database based on the migrations available
- [`check.buildEnvironment`](<Configuration/Parameters/Flyway/Check/Build Environment>) - This is where Flyway will populate the database based on the migrations available
- If you do not have a build database you could specify a snapshot via [`check.nextSnapshot`](<Configuration/Parameters/Flyway/Check/Next Snapshot>)

If you want to explicitly specify the filename of the generated report then the [`reportFilename`](<Configuration/Parameters/Flyway/Report Filename>) parameter exists.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ See also the [Drift Report Concept](<Concepts/Check Drift Concept>) page

### Commandline
```powershell
./flyway check -drift -environment=production -buildEnvironment=build
./flyway check -drift -environment=production -check.buildEnvironment=build
```

You need to specify the environments Flyway should use for conducting the drift report.
- [`environment`](Configuration/Parameters/Flyway/Environment) - This would typically be your target/production environment
- [`buildEnvironment`](<Configuration/Parameters/Flyway/Check/Build Environment>) - This is where Flyway will populate the database based on the migrations that exist in your target environment.
- [`check.buildEnvironment`](<Configuration/Parameters/Flyway/Check/Build Environment>) - This is where Flyway will populate the database based on the migrations that exist in your target environment.
- Alternatively, if you do not have a build database you could use a snapshot via [`check.deployedSnapshot`](<Configuration/Parameters/Flyway/Check/Deployed Snapshot>) instead.

If you want to explicitly specify the filename of the generated report then the [`reportFilename`](<Configuration/Parameters/Flyway/Report Filename>) parameter can be configured.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
pill: email
subtitle: flyway.email
redirect_from: Configuration/email/
---

# Email

## Description

A Redgate email to be used in conjunction with the [`token`](configuration/parameters/flyway/token) parameter to
configure a personal access token (PAT). Used to authenticate Flyway to use either Teams or Enterprise.

## Usage

### Commandline
```bash
./flyway -email="foo.bar@red-gate.com" -token="1234ABCD"
```

### TOML
```properties
[flyway]
email = "foo.bar@red-gate.com"
token = "1234ABCD"
```

### Environment Variable
```properties
FLYWAY_EMAIL=foo.bar@red-gate.com
FLYWAY_TOKEN=1234ABCD
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Patterns are of the form `type`:`status` with `*` matching `type` or `status`.

`type` must be one of (*case insensitive*):

* `repeatable` {% include redgate.html %}
* `versioned` {% include redgate.html %}
* `repeatable`
* `versioned`
* `*` *(will match any of the above)*

`status` must be one of (*case insensitive*):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
pill: token
subtitle: flyway.token
redirect_from: Configuration/token/
---

# Token

## Description

A personal access token (PAT) to be used in conjunction with the [`email`](configuration/parameters/flyway/email)
configuration parameter. Used to authenticate Flyway to use either Teams or Enterprise.

## Usage

### Commandline
```bash
./flyway -email="foo.bar@red-gate.com" -token="1234ABCD"
```

### TOML
```properties
[flyway]
email = "foo.bar@red-gate.com"
token = "1234ABCD"
```

### Environment Variable
```properties
FLYWAY_EMAIL=foo.bar@red-gate.com
FLYWAY_TOKEN=1234ABCD
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
subtitle: Rebuild the Schema history table
---

## How to rebuild a Schema history table

You may want to do this if your Schema history table has been accidentally dropped or if you have rebaselined your migrations and the previous deployment information is no longer applicable.

Steps
1) Run the [Baseline command](commands/baseline) to provision the table
2) Populate the table without re-executing your migrations by running a Migrate command with the [Skip Executing Migrations](Configuration/parameters/flyway/skip-executing-migrations) switch enabled.
4 changes: 2 additions & 2 deletions documentation/Flyway CLI and API/Learn More/Requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ subtitle: Requirements

Flyway is designed to be as lightweight as possible. We recommend that you need as an absolute minimum:

- 160MB disc space
- 160MB disk space
- 256MB RAM
- 512MHz processor

Though clearly the higher specification the machine, the better your experience will be. For more details, refer to the [Oracle guidelines](https://www.java.com/en/download/help/sysreq.html) for running Java-based applications. Disc space can be saved by removing unwanted JDBC drivers, and also the embedded JRE if you have an alternative one already installed.
Though clearly the higher specification the machine, the better your experience will be. For more details, refer to the [Oracle guidelines](https://www.java.com/en/download/help/sysreq.html) for running Java-based applications. Disk space can be saved by removing unwanted JDBC drivers, and also the embedded JRE if you have an alternative one already installed.

## Supported Java Platforms

Expand Down
14 changes: 7 additions & 7 deletions documentation/Flyway CLI and API/Supported Databases/Derby.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ subtitle: Derby

## Driver

| Item | Details |
|------------------------------------|-----------------------------------------------------------------|
| **URL format** | <code>jdbc:derby:<i>sub-protocol</i>:<i>databaseName</i></code> |
| **Ships with Flyway Command-line** | No |
| **Maven Central coordinates** | `org.apache.derby:derbyclient` |
| **Supported versions** | `10.11` and later |
| **Default Java class** | `org.apache.derby.jdbc.EmbeddedDriver` |
| Item | Details |
|------------------------------------|------------------------------------------------------------------|
| **URL format** | <code>jdbc:derby:<i>sub-protocol</i>:<i>database name</i></code> |
| **Ships with Flyway Command-line** | No |
| **Maven Central coordinates** | `org.apache.derby:derbyclient` |
| **Supported versions** | `10.11` and later |
| **Default Java class** | `org.apache.derby.jdbc.EmbeddedDriver` |

## CLI Usage - installing support
If you want to connect to e Derby database you will first need to download the driver that is compatible with Java 17 from the [Derby download page](https://db.apache.org/derby/derby_downloads.html)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
subtitle: 'Tutorial: Personal Access Tokens (PATs)'
---
# Tutorial: Personal Access Tokens (PATs)

This brief tutorial will teach you how to authorize Flyway to use Teams or Enterprise Edition using personal access tokens a.k.a. PATs.

## Introduction

Flyway can be authorized non-interactively by specifying the `email` and `token` parameters for PATs.

## Example: Authorizing Flyway with PATs

Let's assume we have just installed Flyway. Flyway defaults to Community Edition out of the box.

Let's say we have access to Enterprise Edition and we would like to authorize Flyway to use Enterprise features.
First, we must generate our PAT. We can do this by visiting the [Personal Access Tokens page](https://identityprovider.red-gate.com/personaltokens)
on the Redgate identity provider website and clicking on the "New Token" button. Be sure to save your token in a secure
place because once they are generated, they cannot be viewed in full again.

We can then specify our Redgate email and PAT using the `email` and `token` configuration parameters on the commandline,
in the TOML configuration file, or the `FLYWAY_EMAIL` and `FLYWAY_TOKEN` environment variables. For this example,
we'll use the TOML configuration file:

```toml
[flyway]
email = "foo.bar@red-gate.com"
token = "1234ABCD"
```

Now, we can use Flyway normally and Flyway will automatically authorize itself to use Enterprise Edition. Let's run
`flyway version` to verify that:

<pre class="console">
> flyway version

Flyway Enterprise Edition {{ site.flywayVersion }} by Redgate

See release notes here: https://rd.gt/416ObMi
</pre>

That's all there is to it! Using PATs, we have successfully authorized Flyway to use Enterprise Edition without
needing to run the `auth` command.

## Summary

In this brief tutorial we saw how to:

- Use PATs to authorize Flyway to use an edition higher than Community Edition
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@
</div>
<div class="col-md-9">

<div class="release">
<h2 id="10.12.0">Flyway 10.12.0 (2024-04-29)</h2>

<h3>Bug fixes</h3>
<ul>
<li>Flyway shouldn't call SqlFluff if there are no pending migrations found</li>
</ul>

<h3>Changes</h3>
<ul>
<li>Reworded exception messages when executing scripts fails to say "Script ... failed" instead of "Migration ... failed"</li>
<li>'beforeEachMigrateStatement' and 'afterEachMigrateStatement' callbacks are now open source features</li>
<li>Updated wording on Drift Report</li>
</ul>

<h3>New features</h3>
<ul>
<li>Personal Access Tokens are now supported as a method of authorizing Flyway</li>
<li>'versioned' and 'repeatable' can now be used for 'ignoreMigrationPatterns' in the open-source version.</li>
</ul>

</div>

<div class="release">
<h2 id="10.11.1">Flyway 10.11.1 (2024-04-18)</h2>

Expand Down
2 changes: 1 addition & 1 deletion documentation/_config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
flywayVersion: 10.11.1
flywayVersion: 10.12.0
enterpriseUrl: https://download.red-gate.com/maven/release/com/redgate/flyway
kramdown:
smart_quotes: ["apos", "apos", "quot", "quot"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ cmd
(?i)Commandline
[Cc]onfig
database_name
databaseName
default_build
[Dd]ev
[Dd]atasource
Expand Down
2 changes: 1 addition & 1 deletion flyway-commandline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-parent</artifactId>
<version>10.11.1</version>
<version>10.12.0</version>
</parent>
<artifactId>flyway-commandline</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion flyway-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-parent</artifactId>
<version>10.11.1</version>
<version>10.12.0</version>
</parent>
<artifactId>flyway-core</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public <T> T execute(Command<T> command, boolean scannerRequired, FlywayTelemetr
}

LOG.info("Database: " + redactJdbcUrl(jdbcConnectionFactory.getJdbcUrl()) + " (" + jdbcConnectionFactory.getProductName() + ")");
LOG.debug("Database Type: " + database.getDatabaseType().getName());
LOG.debug("Driver: " + jdbcConnectionFactory.getDriverInfo());

if (flywayTelemetryManager != null) {
Expand Down

0 comments on commit 2bb4305

Please sign in to comment.