Search in sources :

Example 16 with PostgresDatabase

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

the class CreateTableGeneratorTest method createReferencesSchemaEscaped.

@Test
public void createReferencesSchemaEscaped() throws Exception {
    Database database = new PostgresDatabase();
    database.setOutputDefaultSchema(true);
    database.setDefaultSchemaName("my-schema");
    CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
    statement.addColumnConstraint(new ForeignKeyConstraint("fk_test_parent", TABLE_NAME + "(id)").setColumn("id"));
    Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
    assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (, CONSTRAINT fk_test_parent FOREIGN KEY (id) REFERENCES \"my-schema\".TABLE_NAME(id))", generatedSql[0].toSql());
}
Also used : PostgresDatabase(liquibase.database.core.PostgresDatabase) CreateTableStatement(liquibase.statement.core.CreateTableStatement) ForeignKeyConstraint(liquibase.statement.ForeignKeyConstraint) 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) Sql(liquibase.sql.Sql) AbstractSqlGeneratorTest(liquibase.sqlgenerator.AbstractSqlGeneratorTest) Test(org.junit.Test)

Aggregations

PostgresDatabase (liquibase.database.core.PostgresDatabase)16 MSSQLDatabase (liquibase.database.core.MSSQLDatabase)8 Sql (liquibase.sql.Sql)8 Test (org.junit.Test)8 Database (liquibase.database.Database)7 MySQLDatabase (liquibase.database.core.MySQLDatabase)6 AbstractSqlGeneratorTest (liquibase.sqlgenerator.AbstractSqlGeneratorTest)6 DB2Database (liquibase.database.core.DB2Database)5 OracleDatabase (liquibase.database.core.OracleDatabase)5 DerbyDatabase (liquibase.database.core.DerbyDatabase)4 H2Database (liquibase.database.core.H2Database)4 HsqlDatabase (liquibase.database.core.HsqlDatabase)4 SQLiteDatabase (liquibase.database.core.SQLiteDatabase)4 SybaseASADatabase (liquibase.database.core.SybaseASADatabase)4 SybaseDatabase (liquibase.database.core.SybaseDatabase)4 CreateTableStatement (liquibase.statement.core.CreateTableStatement)4 ColumnConfig (liquibase.change.ColumnConfig)3 AutoIncrementConstraint (liquibase.statement.AutoIncrementConstraint)3 SqlStatement (liquibase.statement.SqlStatement)3 BigInteger (java.math.BigInteger)2