How can I force flyway to clean my docker oracle database? How can I force flyway to clean my docker oracle database? docker docker

How can I force flyway to clean my docker oracle database?


Flyway will throw this exception if the current schema is considered a system schema:

@Overrideprotected void doClean() throws SQLException {    if (isSystem()) {        throw new FlywayException("Clean not supported on Oracle for system schema " + database.quote(name) + "! " +                "It must not be changed in any way except by running an Oracle-supplied script!");    }

A schema is considered to be a system schema if it in a list of known default schemas or has ORACLE_MAINTAINED = 'Y'.

Creating the user with alter session set "_ORACLE_SCRIPT"=true; sets ORACLE_MAINTAINED = 'Y' for the user / schema.

There are two kinds of database in Oracle 12c: a Container Database (CDB) and a Pluggable Database (PDB). This is to support Multitenancy.

You are currently creating the user in the CDB, which would be a common user across all PDBs. In that case, you must either prefix the user name with c##:

create user c##scott identified by tiger;

or use the alter session set "_ORACLE_SCRIPT"=true;, otherwise you will get the error:

ORA-65096: invalid common user or role name in oracle

The alternative is to connect to a PDB and create a local user there (no prefix required and the user will only exists in that PDB), e.g.:

sqlplus sys/Oradoc_db1@ORCLPDB1 as sysdbacreate user scott identified by tiger;

The update the Flyway url to connect to that PDB as that user:

-url=jdbc:oracle:thin:@oracle-ee:1521/orclpdb1.localdomain -user="scott" -password=tiger