Package liquibase.sql

Examples of liquibase.sql.UnparsedSql


    }

    @Override
    public Sql[] generateSql(RawSqlStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
        return new Sql[] {
           new UnparsedSql(statement.getSql(), statement.getEndDelimiter())
        };
    }
View Full Code Here


        } else {
            sql = "ALTER TABLE " + escapedTableName + " ALTER COLUMN  " + database.escapeColumnName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName(), statement.getColumnName()) + " SET DEFAULT NULL";
         }

        return new Sql[] {
                new UnparsedSql(sql, getAffectedColumn(statement))
        };
    }
View Full Code Here

        String schemaName = statement.getSchemaName();
        if (schemaName == null) {
            schemaName = database.getLiquibaseSchemaName();
        }
        return new Sql[] {
                new UnparsedSql("DELETE FROM " + database.escapeTableName(database.getLiquibaseCatalogName(), schemaName, database.getDatabaseChangeLogTableName()),
                        getAffectedTable(database, schemaName)) };
    }
View Full Code Here

    @Override
    public Sql[] generateSql(GetViewDefinitionStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
        CatalogAndSchema schema = new CatalogAndSchema(statement.getCatalogName(), statement.getSchemaName()).customize(database);

        return new Sql[] {
                    new UnparsedSql("select view_definition from SYSIBM.VIEWS where TABLE_NAME='" + statement.getViewName() + "' and TABLE_SCHEMA='" + schema.getSchemaName() + "'")
            };
    }
View Full Code Here

    final String sqlNoContraintNameTemplate = "ALTER TABLE %s ADD CONSTRAINT UNIQUE (%s)";
    final String sqlTemplate = "ALTER TABLE %s ADD CONSTRAINT UNIQUE (%s) CONSTRAINT %s";
    if (statement.getConstraintName() == null) {
      return new Sql[] {
        new UnparsedSql(String.format(sqlNoContraintNameTemplate
            , database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName())
            , database.escapeColumnNameList(statement.getColumnNames())
        ), getAffectedUniqueConstraint(statement))
      };
    } else {
      return new Sql[] {
        new UnparsedSql(String.format(sqlTemplate
            , database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName())
            , database.escapeColumnNameList(statement.getColumnNames())
            , database.escapeConstraintName(statement.getConstraintName())
        ), getAffectedUniqueConstraint(statement))
      };
View Full Code Here

        return "SELECT COUNT(*) FROM "+database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName());
    }

    @Override
    public Sql[] generateSql(TableRowCountStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
        return new Sql[] { new UnparsedSql(generateCountSql(statement, database)) };
    }
View Full Code Here

        }

        sql.append(")");

        return new Sql[] {
                new UnparsedSql(sql.toString(), getAffectedTable(statement))
        };
    }
View Full Code Here

    sb.append("PKCOLUMN_NAME as ").append(FindForeignKeyConstraintsStatement.RESULT_COLUMN_FOREIGN_COLUMN_NAME).append(", ");
    sb.append("FK_NAME as ").append(FindForeignKeyConstraintsStatement.RESULT_COLUMN_CONSTRAINT_NAME).append(" ");
    sb.append("FROM INFORMATION_SCHEMA.SYSTEM_CROSSREFERENCE ");
    sb.append("WHERE FKTABLE_NAME = '").append(statement.getBaseTableName().toUpperCase()).append("'");

    return new Sql[] { new UnparsedSql(sb.toString()) };
  }
View Full Code Here

                }
            }
        }

        return new Sql[]{
                new UnparsedSql(sql)
        };
    }
View Full Code Here

             
        String createClause = "CREATE VIEW  " + viewName + " AS SELECT * FROM (" + statement.getSelectQuery() + ") AS v";
       
        if (statement.isReplaceIfExists()) {
          return new Sql[] {
          new UnparsedSql("DROP VIEW IF EXISTS " + viewName),
                new UnparsedSql(createClause, new View().setName(viewName).setSchema(statement.getCatalogName(), statement.getViewName()))
            };
        }
        return new Sql[] {
                new UnparsedSql(createClause)
            };
    }
View Full Code Here

TOP

Related Classes of liquibase.sql.UnparsedSql

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.