Search in sources :

Example 1 with MigrationType

use of org.flywaydb.core.api.MigrationType in project flyway by flyway.

the class MyCustomMigrationResolver method resolveMigrations.

@Override
public List<ResolvedMigration> resolveMigrations() {
    List<ResolvedMigration> resolvedMigrations = new ArrayList<ResolvedMigration>();
    resolvedMigrations.add(new ResolvedMigration() {

        @Override
        public MigrationVersion getVersion() {
            return MigrationVersion.fromVersion("1.9");
        }

        @Override
        public String getDescription() {
            return "Virtual Migration";
        }

        @Override
        public String getScript() {
            return "VirtualScript 1.9";
        }

        @Override
        public Integer getChecksum() {
            return 19;
        }

        @Override
        public MigrationType getType() {
            return MigrationType.CUSTOM;
        }

        @Override
        public String getPhysicalLocation() {
            return "virtual://loaction";
        }

        @Override
        public MigrationExecutor getExecutor() {
            return new MigrationExecutor() {

                @Override
                public void execute(Connection connection) {
                    System.out.println("Executed !");
                }

                @Override
                public boolean executeInTransaction() {
                    return true;
                }
            };
        }
    });
    return resolvedMigrations;
}
Also used : MigrationVersion(org.flywaydb.core.api.MigrationVersion) ArrayList(java.util.ArrayList) MigrationExecutor(org.flywaydb.core.api.resolver.MigrationExecutor) Connection(java.sql.Connection) ResolvedMigration(org.flywaydb.core.api.resolver.ResolvedMigration) MigrationType(org.flywaydb.core.api.MigrationType)

Example 2 with MigrationType

use of org.flywaydb.core.api.MigrationType in project flyway by flyway.

the class MigrationInfoImplSmallTest method validateFuture.

@Test
public void validateFuture() {
    MigrationVersion version = MigrationVersion.fromVersion("1");
    String description = "test";
    MigrationType type = MigrationType.SQL;
    AppliedMigration appliedMigration = new AppliedMigration(1, version, description, type, null, 123, new Date(), "abc", 0, true);
    MigrationInfoImpl migrationInfo = new MigrationInfoImpl(null, appliedMigration, new MigrationInfoContext(), false);
    String message = migrationInfo.validate();
    assertTrue(message, message.contains("not resolved"));
}
Also used : MigrationVersion(org.flywaydb.core.api.MigrationVersion) AppliedMigration(org.flywaydb.core.internal.metadatatable.AppliedMigration) MigrationType(org.flywaydb.core.api.MigrationType) Date(java.util.Date) Test(org.junit.Test)

Example 3 with MigrationType

use of org.flywaydb.core.api.MigrationType in project flyway by flyway.

the class MigrationInfoImplSmallTest method validate.

@Test
public void validate() {
    MigrationVersion version = MigrationVersion.fromVersion("1");
    String description = "test";
    MigrationType type = MigrationType.SQL;
    ResolvedMigrationImpl resolvedMigration = new ResolvedMigrationImpl();
    resolvedMigration.setVersion(version);
    resolvedMigration.setDescription(description);
    resolvedMigration.setType(type);
    resolvedMigration.setChecksum(456);
    AppliedMigration appliedMigration = new AppliedMigration(1, version, description, type, null, 123, new Date(), "abc", 0, true);
    MigrationInfoImpl migrationInfo = new MigrationInfoImpl(resolvedMigration, appliedMigration, new MigrationInfoContext(), false);
    String message = migrationInfo.validate();
    assertTrue(message.contains("123"));
    assertTrue(message.contains("456"));
}
Also used : MigrationVersion(org.flywaydb.core.api.MigrationVersion) AppliedMigration(org.flywaydb.core.internal.metadatatable.AppliedMigration) MigrationType(org.flywaydb.core.api.MigrationType) ResolvedMigrationImpl(org.flywaydb.core.internal.resolver.ResolvedMigrationImpl) Date(java.util.Date) Test(org.junit.Test)

Aggregations

MigrationType (org.flywaydb.core.api.MigrationType)3 MigrationVersion (org.flywaydb.core.api.MigrationVersion)3 Date (java.util.Date)2 AppliedMigration (org.flywaydb.core.internal.metadatatable.AppliedMigration)2 Test (org.junit.Test)2 Connection (java.sql.Connection)1 ArrayList (java.util.ArrayList)1 MigrationExecutor (org.flywaydb.core.api.resolver.MigrationExecutor)1 ResolvedMigration (org.flywaydb.core.api.resolver.ResolvedMigration)1 ResolvedMigrationImpl (org.flywaydb.core.internal.resolver.ResolvedMigrationImpl)1