Coverage Report - liquibase.database.Database
 
Classes in this File Line Coverage Branch Coverage Complexity
Database
N/A
N/A
1
 
 1  
 package liquibase.database;
 2  
 
 3  
 import java.io.IOException;
 4  
 import java.io.Writer;
 5  
 import java.util.Date;
 6  
 import java.util.List;
 7  
 
 8  
 import liquibase.change.Change;
 9  
 import liquibase.changelog.ChangeSet;
 10  
 import liquibase.changelog.DatabaseChangeLog;
 11  
 import liquibase.changelog.RanChangeSet;
 12  
 import liquibase.database.structure.DatabaseObject;
 13  
 import liquibase.exception.DatabaseException;
 14  
 import liquibase.exception.DatabaseHistoryException;
 15  
 import liquibase.exception.DateParseException;
 16  
 import liquibase.exception.LiquibaseException;
 17  
 import liquibase.exception.RollbackImpossibleException;
 18  
 import liquibase.exception.StatementNotSupportedOnDatabaseException;
 19  
 import liquibase.exception.UnsupportedChangeException;
 20  
 import liquibase.servicelocator.PrioritizedService;
 21  
 import liquibase.sql.visitor.SqlVisitor;
 22  
 import liquibase.statement.DatabaseFunction;
 23  
 import liquibase.statement.SqlStatement;
 24  
 
 25  
 public interface Database extends DatabaseObject, PrioritizedService {
 26  
 
 27  
     String databaseChangeLogTableName = "DatabaseChangeLog".toUpperCase();
 28  
     String databaseChangeLogLockTableName = "DatabaseChangeLogLock".toUpperCase();
 29  
 
 30  
     /**
 31  
      * Is this AbstractDatabase subclass the correct one to use for the given connection.
 32  
      */
 33  
     boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException;
 34  
 
 35  
     /**
 36  
      * If this database understands the given url, return the default driver class name. Otherwise return null.
 37  
      */
 38  
     String getDefaultDriver(String url);
 39  
 
 40  
     DatabaseConnection getConnection();
 41  
 
 42  
     void setConnection(DatabaseConnection conn);
 43  
 
 44  
     boolean requiresUsername();
 45  
 
 46  
     boolean requiresPassword();
 47  
 
 48  
     /**
 49  
      * Auto-commit mode to run in
 50  
      */
 51  
     public boolean getAutoCommitMode();
 52  
 
 53  
     /**
 54  
      * Determines if the database supports DDL within a transaction or not.
 55  
      * 
 56  
      * @return True if the database supports DDL within a transaction, otherwise false.
 57  
      */
 58  
     boolean supportsDDLInTransaction();
 59  
 
 60  
     String getDatabaseProductName();
 61  
 
 62  
     String getDatabaseProductVersion() throws DatabaseException;
 63  
 
 64  
     int getDatabaseMajorVersion() throws DatabaseException;
 65  
 
 66  
     int getDatabaseMinorVersion() throws DatabaseException;
 67  
 
 68  
     /**
 69  
      * Returns an all-lower-case short name of the product. Used for end-user selecting of database type such as the
 70  
      * DBMS precondition.
 71  
      */
 72  
     String getTypeName();
 73  
 
 74  
     String getDefaultCatalogName() throws DatabaseException;
 75  
 
 76  
     String getDefaultSchemaName();
 77  
 
 78  
     String getLiquibaseSchemaName();
 79  
 
 80  
     void setDefaultSchemaName(String schemaName) throws DatabaseException;
 81  
 
 82  
     /**
 83  
      * Returns whether this database support initially deferrable columns.
 84  
      */
 85  
     boolean supportsInitiallyDeferrableColumns();
 86  
 
 87  
     public boolean supportsSequences();
 88  
 
 89  
     public boolean supportsDropTableCascadeConstraints();
 90  
 
 91  
     public boolean supportsAutoIncrement();
 92  
 
 93  
     String getDateLiteral(String isoDate);
 94  
 
 95  
     /**
 96  
      * Returns database-specific function for generating the current date/time.
 97  
      */
 98  
     String getCurrentDateTimeFunction();
 99  
 
 100  
     void setCurrentDateTimeFunction(String function);
 101  
 
 102  
     String getLineComment();
 103  
 
 104  
     String getAutoIncrementClause();
 105  
 
 106  
     String getDatabaseChangeLogTableName();
 107  
 
 108  
     String getDatabaseChangeLogLockTableName();
 109  
 
 110  
     /**
 111  
      * Set the table name of the change log to the given table name
 112  
      * 
 113  
      * @param tableName
 114  
      */
 115  
     public void setDatabaseChangeLogTableName(String tableName);
 116  
 
 117  
     /**
 118  
      * Set the table name of the change log lock to the given table name
 119  
      * 
 120  
      * @param tableName
 121  
      */
 122  
     public void setDatabaseChangeLogLockTableName(String tableName);
 123  
 
 124  
     /**
 125  
      * Returns SQL to concat the passed values.
 126  
      */
 127  
     String getConcatSql(String... values);
 128  
 
 129  
     boolean hasDatabaseChangeLogTable() throws DatabaseException;
 130  
 
 131  
     public void setCanCacheLiquibaseTableInfo(boolean canCacheLiquibaseTableInfo);
 132  
 
 133  
     boolean hasDatabaseChangeLogLockTable() throws DatabaseException;
 134  
 
 135  
     void checkDatabaseChangeLogTable(boolean updateExistingNullChecksums, DatabaseChangeLog databaseChangeLog,
 136  
             String[] contexts) throws DatabaseException;
 137  
 
 138  
     void checkDatabaseChangeLogLockTable() throws DatabaseException;
 139  
 
 140  
     void dropDatabaseObjects(String schema) throws DatabaseException;
 141  
 
 142  
     void tag(String tagString) throws DatabaseException;
 143  
 
 144  
     boolean doesTagExist(String tag) throws DatabaseException;
 145  
 
 146  
     boolean isSystemTable(String catalogName, String schemaName, String tableName);
 147  
 
 148  
     boolean isLiquibaseTable(String tableName);
 149  
 
 150  
     boolean shouldQuoteValue(String value);
 151  
 
 152  
     boolean supportsTablespaces();
 153  
 
 154  
     String getViewDefinition(String schemaName, String name) throws DatabaseException;
 155  
 
 156  
     boolean isSystemView(String catalogName, String schemaName, String name);
 157  
 
 158  
     String getDateLiteral(java.sql.Date date);
 159  
 
 160  
     String getTimeLiteral(java.sql.Time time);
 161  
 
 162  
     String getDateTimeLiteral(java.sql.Timestamp timeStamp);
 163  
 
 164  
     String getDateLiteral(Date defaultDateValue);
 165  
 
 166  
     /**
 167  
      * Escapes the table name in a database-dependent manner so reserved words can be used as a table name (i.e.
 168  
      * "order"). Currently only escapes MS-SQL because other DBMSs store table names case-sensitively when escaping is
 169  
      * used which could confuse end-users. Pass null to schemaName to use the default schema
 170  
      */
 171  
     String escapeTableName(String schemaName, String tableName);
 172  
 
 173  
     String escapeIndexName(String schemaName, String indexName);
 174  
 
 175  
     String escapeDatabaseObject(String objectName);
 176  
 
 177  
     /**
 178  
      * Escapes a single column name in a database-dependent manner so reserved words can be used as a column name (i.e.
 179  
      * "return").
 180  
      * 
 181  
      * @param schemaName
 182  
      * @param tableName
 183  
      * @param columnName
 184  
      *            column name
 185  
      * 
 186  
      * @return escaped column name
 187  
      */
 188  
     String escapeColumnName(String schemaName, String tableName, String columnName);
 189  
 
 190  
     /**
 191  
      * Escapes a list of column names in a database-dependent manner so reserved words can be used as a column name
 192  
      * (i.e. "return").
 193  
      * 
 194  
      * @param columnNames
 195  
      *            list of column names
 196  
      * @return escaped column name list
 197  
      */
 198  
     String escapeColumnNameList(String columnNames);
 199  
 
 200  
     // Set<UniqueConstraint> findUniqueConstraints(String schema) throws DatabaseException;
 201  
 
 202  
     String convertRequestedSchemaToSchema(String requestedSchema) throws DatabaseException;
 203  
 
 204  
     String convertRequestedSchemaToCatalog(String requestedSchema) throws DatabaseException;
 205  
 
 206  
     boolean supportsSchemas();
 207  
 
 208  
     String generatePrimaryKeyName(String tableName);
 209  
 
 210  
     String escapeSequenceName(String schemaName, String sequenceName);
 211  
 
 212  
     String escapeViewName(String schemaName, String viewName);
 213  
 
 214  
     ChangeSet.RunStatus getRunStatus(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException;
 215  
 
 216  
     RanChangeSet getRanChangeSet(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException;
 217  
 
 218  
     void markChangeSetExecStatus(ChangeSet changeSet, ChangeSet.ExecType execType) throws DatabaseException;
 219  
 
 220  
     List<RanChangeSet> getRanChangeSetList() throws DatabaseException;
 221  
 
 222  
     Date getRanDate(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException;
 223  
 
 224  
     void removeRanStatus(ChangeSet changeSet) throws DatabaseException;
 225  
 
 226  
     void commit() throws DatabaseException;
 227  
 
 228  
     void rollback() throws DatabaseException;
 229  
 
 230  
     String escapeStringForDatabase(String string);
 231  
 
 232  
     void close() throws DatabaseException;
 233  
 
 234  
     boolean supportsRestrictForeignKeys();
 235  
 
 236  
     String escapeConstraintName(String constraintName);
 237  
 
 238  
     boolean isAutoCommit() throws DatabaseException;
 239  
 
 240  
     void setAutoCommit(boolean b) throws DatabaseException;
 241  
 
 242  
     boolean isLocalDatabase() throws DatabaseException;
 243  
 
 244  
     void executeStatements(Change change, DatabaseChangeLog changeLog, List<SqlVisitor> sqlVisitors)
 245  
             throws LiquibaseException, UnsupportedChangeException;
 246  
 
 247  
     /*
 248  
      * Executes the statements passed as argument to a target {@link Database}
 249  
      * 
 250  
      * @param statements an array containing the SQL statements to be issued
 251  
      * 
 252  
      * @param database the target {@link Database}
 253  
      * 
 254  
      * @throws DatabaseException if there were problems issuing the statements
 255  
      */
 256  
 
 257  
     void execute(SqlStatement[] statements, List<SqlVisitor> sqlVisitors) throws LiquibaseException;
 258  
 
 259  
     void saveStatements(Change change, List<SqlVisitor> sqlVisitors, Writer writer) throws IOException,
 260  
             UnsupportedChangeException, StatementNotSupportedOnDatabaseException, LiquibaseException;
 261  
 
 262  
     void executeRollbackStatements(Change change, List<SqlVisitor> sqlVisitors) throws LiquibaseException,
 263  
             UnsupportedChangeException, RollbackImpossibleException;
 264  
 
 265  
     void saveRollbackStatement(Change change, List<SqlVisitor> sqlVisitors, Writer writer) throws IOException,
 266  
             UnsupportedChangeException, RollbackImpossibleException, StatementNotSupportedOnDatabaseException,
 267  
             LiquibaseException;
 268  
 
 269  
     int getNextChangeSetSequenceValue() throws LiquibaseException;
 270  
 
 271  
     public Date parseDate(String dateAsString) throws DateParseException;
 272  
 
 273  
     /**
 274  
      * Returns list of database native functions
 275  
      * */
 276  
     public List<DatabaseFunction> getDatabaseFunctions();
 277  
 
 278  
     void reset();
 279  
 
 280  
     boolean supportsForeignKeyDisable();
 281  
 
 282  
     boolean disableForeignKeyChecks() throws DatabaseException;
 283  
 
 284  
     void enableForeignKeyChecks() throws DatabaseException;
 285  
 
 286  
     public boolean isReservedWord(String string);
 287  
 }