Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlyWay drops schema NOT created by FlyWay during clean operation #3331

Closed
chipilov opened this issue Nov 22, 2021 · 0 comments
Closed

FlyWay drops schema NOT created by FlyWay during clean operation #3331

chipilov opened this issue Nov 22, 2021 · 0 comments
Labels
Milestone

Comments

@chipilov
Copy link

Which version and edition of Flyway are you using?

8.0.5

If this is not the latest version, can you reproduce the issue with the latest one as well? (Many bugs are fixed in newer releases and upgrading will often resolve the issue)

N/A (using latest)

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Command-line

Which database are you using? (Type & version)

PostgreSQL 13

Which operating system are you using?

Windows and Linux

What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)
  1. Start with a PostgreSQL database with a public schema (i.e. the public schema is created BEFORE any FlyWay commands are executed, so the public schema is NOT created by FlyWay);
  2. In flyway.conf, set the schemas property to "private" and "public" (i.e. have FlyWay manage the private and public schemas). NOTE, that while FlyWay is expected to manage BOTH schemas, FlyWay will be responsible for the creation ONLY for the private schema - teh public schema already exists;
  3. After executing any number of migrations, clean the schemas by executing "flyway clean -outputType=json"
What did you expect to see?

I expected to see that ONLY the private schema is dropped while the public schema is ONLY cleaned. Instead, both schemas are dropped, as indicated by the command output:

$ flyway/flyway  clean -outputType=json
{
  "schemasCleaned": [
    "public"
  ],
  "schemasDropped": [
    "private"
  ],
  "flywayVersion": "8.0.5",
  "database": "postgres",
  "warnings": [],
  "operation": "clean"
}
What did you see instead?

Both schemas were dropped (even the schema which was NOT created by FlyWay):
I expected to see that ONLY the private schema is dropped while the public schema is ONLY cleaned. Instead, both schemas are dropped, as indicated by the command output:

$ flyway/flyway  clean -outputType=json
{
  "schemasCleaned": [],
  "schemasDropped": [
    "private",
    "public"
  ],
  "flywayVersion": "8.0.5",
  "database": "postgres",
  "warnings": [],
  "operation": "clean"
}

NOTE: It looks like the problem is that there is a single flag for dropping schemas (i.e. the flag is NOT per schema) and the flag is set as long as at least one schema is created by FlyWay (see

dropSchemas = schemaHistory.hasSchemasMarker();
)

HOWEVER, according to a comment in the sample conf file, ONLY schemas that were created by FlyWay are expected to be dropped (otherwise, they are ONLY cleaned). See:

# - If Flyway created them, the schemas themselves will be dropped when cleaning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants