Search in sources :

Example 21 with MySQLDatabase

use of liquibase.database.core.MySQLDatabase in project liquibase by liquibase.

the class CreateTableGeneratorTest method testAutoIncrementStartWithMySQLDatabase.

@Test
public void testAutoIncrementStartWithMySQLDatabase() throws Exception {
    for (Database database : TestContext.getInstance().getAllDatabases()) {
        if (database instanceof MySQLDatabase) {
            CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
            statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("BIGINT{autoIncrement:true}", database), new AutoIncrementConstraint(COLUMN_NAME1, BigInteger.valueOf(2), null));
            Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
            assertEquals("CREATE TABLE CATALOG_NAME.TABLE_NAME (COLUMN1_NAME BIGINT AUTO_INCREMENT NULL) AUTO_INCREMENT=2", generatedSql[0].toSql());
        }
    }
}
Also used : AutoIncrementConstraint(liquibase.statement.AutoIncrementConstraint) CreateTableStatement(liquibase.statement.core.CreateTableStatement) SQLiteDatabase(liquibase.database.core.SQLiteDatabase) DerbyDatabase(liquibase.database.core.DerbyDatabase) DB2Database(liquibase.database.core.DB2Database) H2Database(liquibase.database.core.H2Database) MSSQLDatabase(liquibase.database.core.MSSQLDatabase) MySQLDatabase(liquibase.database.core.MySQLDatabase) PostgresDatabase(liquibase.database.core.PostgresDatabase) OracleDatabase(liquibase.database.core.OracleDatabase) SybaseDatabase(liquibase.database.core.SybaseDatabase) SybaseASADatabase(liquibase.database.core.SybaseASADatabase) Database(liquibase.database.Database) HsqlDatabase(liquibase.database.core.HsqlDatabase) MySQLDatabase(liquibase.database.core.MySQLDatabase) Sql(liquibase.sql.Sql) AbstractSqlGeneratorTest(liquibase.sqlgenerator.AbstractSqlGeneratorTest) Test(org.junit.Test)

Aggregations

MySQLDatabase (liquibase.database.core.MySQLDatabase)21 Test (org.junit.Test)14 OracleDatabase (liquibase.database.core.OracleDatabase)9 MSSQLDatabase (liquibase.database.core.MSSQLDatabase)7 Sql (liquibase.sql.Sql)7 H2Database (liquibase.database.core.H2Database)6 AbstractSqlGeneratorTest (liquibase.sqlgenerator.AbstractSqlGeneratorTest)6 Database (liquibase.database.Database)5 DB2Database (liquibase.database.core.DB2Database)5 PostgresDatabase (liquibase.database.core.PostgresDatabase)5 DerbyDatabase (liquibase.database.core.DerbyDatabase)4 SQLiteDatabase (liquibase.database.core.SQLiteDatabase)4 MockSqlGeneratorChain (liquibase.sqlgenerator.MockSqlGeneratorChain)4 AutoIncrementConstraint (liquibase.statement.AutoIncrementConstraint)4 CreateTableStatement (liquibase.statement.core.CreateTableStatement)4 HsqlDatabase (liquibase.database.core.HsqlDatabase)3 SybaseASADatabase (liquibase.database.core.SybaseASADatabase)3 SybaseDatabase (liquibase.database.core.SybaseDatabase)3 LiquibaseDataType (liquibase.datatype.LiquibaseDataType)3 AddColumnStatement (liquibase.statement.core.AddColumnStatement)3