本文整理汇总了Java中liquibase.statement.core.DropUniqueConstraintStatement类的典型用法代码示例。如果您正苦于以下问题:Java DropUniqueConstraintStatement类的具体用法?Java DropUniqueConstraintStatement怎么用?Java DropUniqueConstraintStatement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DropUniqueConstraintStatement类属于liquibase.statement.core包,在下文中一共展示了DropUniqueConstraintStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSql
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
public Sql[] generateSql(DropUniqueConstraintStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String sql;
if (database instanceof MySQLDatabase) {
sql = "ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " DROP KEY " + database.escapeConstraintName(statement.getConstraintName());
} else if (database instanceof MaxDBDatabase) {
sql = "DROP INDEX " + database.escapeConstraintName(statement.getConstraintName()) + " ON " + database.escapeTableName(statement.getSchemaName(), statement.getTableName());
} else if (database instanceof OracleDatabase) {
sql = "ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " DROP CONSTRAINT " + database.escapeConstraintName(statement.getConstraintName()) + " DROP INDEX";
} else if (database instanceof SybaseASADatabase) {
sql = "ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " DROP UNIQUE (" + statement.getUniqueColumns() + ")";
} else {
sql = "ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " DROP CONSTRAINT " + database.escapeConstraintName(statement.getConstraintName());
}
return new Sql[] {
new UnparsedSql(sql)
};
}
示例2: testWithoutPerconaRollback
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Test
public void testWithoutPerconaRollback() throws RollbackImpossibleException {
PTOnlineSchemaChangeStatement.available = false;
SqlStatement[] statements = generateRollbackStatements();
Assert.assertEquals(1, statements.length);
Assert.assertEquals(DropUniqueConstraintStatement.class, statements[0].getClass());
}
示例3: testRollbackSQL
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Test
public void testRollbackSQL() throws RollbackImpossibleException {
enableLogging();
SqlStatement[] statements = generateRollbackStatements();
Assert.assertEquals(3, statements.length);
Assert.assertEquals(CommentStatement.class, statements[0].getClass());
Assert.assertEquals("pt-online-schema-change --alter=\"" + alterRollbackText + "\" "
+ "--alter-foreign-keys-method=auto "
+ "--host=localhost --port=3306 --user=user --password=*** --execute D=testdb,t=person",
((CommentStatement)statements[0]).getText());
Assert.assertEquals(CommentStatement.class, statements[1].getClass());
Assert.assertEquals(DropUniqueConstraintStatement.class, statements[2].getClass());
}
示例4: testWithoutPercona
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Test
public void testWithoutPercona() {
PTOnlineSchemaChangeStatement.available = false;
SqlStatement[] statements = generateStatements();
Assert.assertEquals(1, statements.length);
Assert.assertEquals(DropUniqueConstraintStatement.class, statements[0].getClass());
}
示例5: testUpdateSQL
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Test
public void testUpdateSQL() {
enableLogging();
SqlStatement[] statements = generateStatements();
Assert.assertEquals(3, statements.length);
Assert.assertEquals(CommentStatement.class, statements[0].getClass());
Assert.assertEquals("pt-online-schema-change --alter=\"" + alterText + "\" "
+ "--alter-foreign-keys-method=auto "
+ "--host=localhost --port=3306 --user=user --password=*** --execute D=testdb,t=person",
((CommentStatement)statements[0]).getText());
Assert.assertEquals(CommentStatement.class, statements[1].getClass());
Assert.assertEquals(DropUniqueConstraintStatement.class, statements[2].getClass());
}
示例6: testSkipDropUniqueConstraintChange
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Test
public void testSkipDropUniqueConstraintChange() {
System.setProperty(Configuration.SKIP_CHANGES, "dropUniqueConstraint");
SqlStatement[] statements = generateStatements();
Assert.assertEquals(1, statements.length);
Assert.assertEquals(DropUniqueConstraintStatement.class, statements[0].getClass());
}
示例7: generateStatements
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
public SqlStatement[] generateStatements(Database database) {
//todo if (database instanceof SQLiteDatabase) {
// // return special statements for SQLite databases
// return generateStatementsForSQLiteDatabase(database);
// }
DropUniqueConstraintStatement statement = new DropUniqueConstraintStatement(getSchemaName() == null?database.getDefaultSchemaName():getSchemaName(), getTableName(), getConstraintName());
if (database instanceof SybaseASADatabase) {
statement.setUniqueColumns(uniqueColumns);
}
return new SqlStatement[]{
statement
};
}
示例8: generateSql
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(DropUniqueConstraintStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
if (!supports(statement, database)) {
return sqlGeneratorChain.generateSql(statement, database);
}
String sql = "ALTER TABLE " + database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName()) +
" DROP CONSTRAINT " + database.escapeConstraintName(statement.getConstraintName());
return new Sql[] {
new UnparsedSql(sql, getAffectedUniqueConstraint(statement))
};
}
示例9: testDropUniqueConstraintNoSchema
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Test
public void testDropUniqueConstraintNoSchema() {
Database database = new HanaDBDatabase();
DropUniqueConstraintStatement statement =
new DropUniqueConstraintStatement(null, null, "table_name", "constraint_name");
assertEquals("ALTER TABLE \"table_name\" DROP CONSTRAINT \"constraint_name\"",
this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
示例10: testDropUniqueConstraintWithSchema
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Test
public void testDropUniqueConstraintWithSchema() {
Database database = new HanaDBDatabase();
DropUniqueConstraintStatement statement =
new DropUniqueConstraintStatement(null, "schema_name", "table_name", "constraint_name");
assertEquals("ALTER TABLE \"schema_name\".\"table_name\" DROP CONSTRAINT \"constraint_name\"",
this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
示例11: supports
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Override
public boolean supports(DropUniqueConstraintStatement statement, Database database) {
return !(database instanceof SQLiteDatabase);
}
示例12: validate
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
public ValidationErrors validate(DropUniqueConstraintStatement dropUniqueConstraintStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("tableName", dropUniqueConstraintStatement.getTableName());
return validationErrors;
}
示例13: supports
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Override
public boolean supports(DropUniqueConstraintStatement statement, Database database) {
return database instanceof HanaDBDatabase;
}
示例14: DropUniqueConstraintGeneratorHanaDBTest
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
protected DropUniqueConstraintGeneratorHanaDBTest(SqlGenerator<DropUniqueConstraintStatement> generatorUnderTest) throws Exception {
super(generatorUnderTest);
}
示例15: createSampleSqlStatement
import liquibase.statement.core.DropUniqueConstraintStatement; //导入依赖的package包/类
@Override
protected DropUniqueConstraintStatement createSampleSqlStatement() {
Database database = new HanaDBDatabase();
DropUniqueConstraintStatement dropUniqueConstraintStatement = new DropUniqueConstraintStatement(null, null, "table_name", "constraint_name");
return dropUniqueConstraintStatement;
}