Domanda

I try to migrate simple sql stuff to different schemas in an Oracle 11gR2 database.
I have definded a datasource to the system user within my spring context in addition I have set the schemas parameter for the target schemas.

But that doesn't work. All tables will be created within the system schema. Only my migration table will be created in schemas[0]. All other schemas are empty.

Here comes my code snippets:

<bean id="flywaySYSTEM" class="com.googlecode.flyway.core.Flyway">
    <property name="dataSource" ref="dsSYSTEM" />
    <property name="schemas">
        <list>
            <value>MZEB</value>
            <value>MZEB2</value>
        </list>
    </property>
</bean>


@Test
/**
 * Test with an local oracle database.
 */
public void createSchemasInOracle(){
    Flyway flySYSTEM = (Flyway)beanFactory.getBean("flywaySYSTEM");
    flySYSTEM.clean();
    flySYSTEM.migrate();
}

SQL:

CREATE TABLE test_user (name VARCHAR(25) NOT NULL,PRIMARY KEY(name));

My expectation was that these sql file will be performed to the specified schemas.

Best regards,

Marcel

È stato utile?

Soluzione

The schemas property tells Flyway where to create the metadata table and which schemas to use for clean.

When you refer to an unprefixed table name in your migration, the default schema for that connection will be used. For Oracle this usually means the current user.

To solve your problem you could do one of the following

  • change the database connection user
  • prefix the table name with the schema where it belongs
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top