Package liquibase.statement.core

Examples of liquibase.statement.core.CreateTableStatement


    @Test
    public void testAutoIncrementSybaseASADatabase() throws Exception {
      for (Database database : TestContext.getInstance().getAllDatabases()) {
        if (database instanceof SybaseASADatabase) {
          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)
          );
View Full Code Here


    @Test
    public void testAutoIncrementStartWithSybaseASADatabase() throws Exception {
      for (Database database : TestContext.getInstance().getAllDatabases()) {
        if (database instanceof SybaseASADatabase) {
          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)
          );
View Full Code Here

    @Test
    public void testAutoIncrementStartWithIncrementBySybaseASADatabase() throws Exception {
      for (Database database : TestContext.getInstance().getAllDatabases()) {
        if (database instanceof SybaseASADatabase) {
          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), BigInteger.TEN)
          );
View Full Code Here

    @Test
    public void testAutoIncrementSybaseDatabase() throws Exception {
      for (Database database : TestContext.getInstance().getAllDatabases()) {
        if (database instanceof SybaseDatabase) {
          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)
          );
View Full Code Here

    @Test
    public void testAutoIncrementStartWithSybaseDatabase() throws Exception {
      for (Database database : TestContext.getInstance().getAllDatabases()) {
        if (database instanceof SybaseDatabase) {
          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)
          );
View Full Code Here

    @Test
    public void testAutoIncrementStartWithIncrementBySybaseDatabase() throws Exception {
      for (Database database : TestContext.getInstance().getAllDatabases()) {
        if (database instanceof SybaseDatabase) {
          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), BigInteger.TEN)
          );
View Full Code Here

    @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());
    }
View Full Code Here

    protected static final String TABLESPACE_NAME = "LB_TABLESPACE";

    @Override
    protected List<? extends SqlStatement> setupStatements(Database database) {
        List<CreateTableStatement> statements = new ArrayList<CreateTableStatement>();
        CreateTableStatement table = new CreateTableStatement(null, null, TABLE_NAME);
        table
                .addColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[]{ new NotNullConstraint()})
                .addColumn(COLUMN_NAME, DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[]{ new NotNullConstraint()});
        statements.add(table);

        if (database.supportsSchemas()) {
            table = new CreateTableStatement(DatabaseTestContext.ALT_CATALOG, DatabaseTestContext.ALT_SCHEMA, TABLE_NAME);
            table
                    .addColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[]{  new NotNullConstraint() })
                    .addColumn(COLUMN_NAME, DataTypeFactory.getInstance().fromDescription("int", database), null,  new ColumnConstraint[]{ new NotNullConstraint() });
            statements.add(table);
        }
        return statements;
View Full Code Here


    @Override
    protected List<? extends SqlStatement> setupStatements(Database database) {
        ArrayList<CreateTableStatement> statements = new ArrayList<CreateTableStatement>();
        CreateTableStatement table = new CreateTableStatement(null, null, TABLE_NAME);
        if (database instanceof MySQLDatabase) {
            table.addPrimaryKeyColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, "pk_", null);
        } else {
            table.addColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[]{  new NotNullConstraint() });
        }
        table.addColumn(COLUMN_NAME, DataTypeFactory.getInstance().fromDescription("int", database));
        statements.add(table);

        if (database.supportsSchemas()) {
            table = new CreateTableStatement(DatabaseTestContext.ALT_CATALOG, DatabaseTestContext.ALT_SCHEMA, TABLE_NAME);
            table
                    .addColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[]{  new NotNullConstraint() });
            statements.add(table);
        }
        return statements;
    }
View Full Code Here

    protected static final String TABLE_NAME = "table_name";

    @Override
    protected List<? extends SqlStatement> setupStatements(Database database) {
        ArrayList<CreateTableStatement> statements = new ArrayList<CreateTableStatement>();
        CreateTableStatement table = new CreateTableStatement(null, null, TABLE_NAME);
        table.addColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[]{ new NotNullConstraint() });
        statements.add(table);

        if (database.supportsSchemas()) {
            table = new CreateTableStatement(DatabaseTestContext.ALT_CATALOG, DatabaseTestContext.ALT_SCHEMA, TABLE_NAME);
            table.addColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[]{  new NotNullConstraint()});
            statements.add(table);
        }
        return statements;
    }
View Full Code Here

TOP

Related Classes of liquibase.statement.core.CreateTableStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.