SHARE
TWEET

Untitled

a guest May 1st, 2011 298 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ru.pyatigil.db.migrate.liquibase;
  2.  
  3. import liquibase.database.Database;
  4. import liquibase.sql.Sql;
  5. import liquibase.sql.UnparsedSql;
  6. import liquibase.sqlgenerator.SqlGeneratorChain;
  7. import liquibase.sqlgenerator.core.CreateTableGenerator;
  8. import liquibase.statement.core.CreateTableStatement;
  9.  
  10. /**
  11.  * User: looser
  12.  * Date: 12/03/11
  13.  */
  14. @SuppressWarnings({"UnusedDeclaration"}) // used by liquibase
  15. public class InnoDbCreateTableGenerator extends CreateTableGenerator {
  16.     @Override
  17.     public Sql[] generateSql(CreateTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
  18.         Sql[] sqls = super.generateSql(statement, database, sqlGeneratorChain);
  19.         if (database.getTypeName().equals("mysql")) {
  20.             if (sqls.length != 1) {
  21.                 throw new IllegalStateException("was expecting exactly 1 sql");
  22.             }
  23.             Sql sql = sqls[0];
  24.             return new Sql[] {
  25.                     new UnparsedSql(sql.toSql() + " engine INNODB")
  26.             };
  27.         } else {
  28.             return sqls;
  29.         }
  30.     }
  31.  
  32.     @Override
  33.     public int getPriority() {
  34.         return super.getPriority() + 1;
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top