Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AddColumnGeneratorSQLite |
|
| 1.0;1 |
1 | package liquibase.sqlgenerator.core; | |
2 | ||
3 | import liquibase.database.Database; | |
4 | import liquibase.database.core.SQLiteDatabase; | |
5 | import liquibase.sql.Sql; | |
6 | import liquibase.sql.UnparsedSql; | |
7 | import liquibase.sqlgenerator.SqlGeneratorChain; | |
8 | import liquibase.statement.core.AddColumnStatement; | |
9 | ||
10 | 11 | public class AddColumnGeneratorSQLite extends AddColumnGenerator { |
11 | @Override | |
12 | public int getPriority() { | |
13 | 1 | return PRIORITY_DATABASE; |
14 | } | |
15 | ||
16 | @Override | |
17 | public boolean supports(AddColumnStatement statement, Database database) { | |
18 | 1 | return database instanceof SQLiteDatabase; |
19 | } | |
20 | ||
21 | @Override | |
22 | public Sql[] generateSql(final AddColumnStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { | |
23 | // // SQLite does not support this ALTER TABLE operation until now. | |
24 | // // For more information see: http://www.sqlite.org/omitted.html. | |
25 | // // This is a small work around... | |
26 | // | |
27 | // List<SqlStatement> statements = new ArrayList<SqlStatement>(); | |
28 | // | |
29 | // // define alter table logic | |
30 | // SQLiteDatabase.AlterTableVisitor rename_alter_visitor = | |
31 | // new SQLiteDatabase.AlterTableVisitor() { | |
32 | // public ColumnConfig[] getColumnsToAdd() { | |
33 | // return new ColumnConfig[] { | |
34 | // new ColumnConfig() | |
35 | // .setName(statement.getColumnName()) | |
36 | // .setType(statement.getDataType()) | |
37 | // .setAutoIncrement(statement.isAutoIncrement()) | |
38 | // }; | |
39 | // } | |
40 | // public boolean copyThisColumn(ColumnConfig column) { | |
41 | // return true; | |
42 | // } | |
43 | // public boolean createThisColumn(ColumnConfig column) { | |
44 | // return true; | |
45 | // } | |
46 | // public boolean createThisIndex(Index index) { | |
47 | // return true; | |
48 | // } | |
49 | // }; | |
50 | // | |
51 | // try { | |
52 | // // alter table | |
53 | // statements.addAll(SQLiteDatabase.getAlterTableStatements(rename_alter_visitor, | |
54 | // database,statement.getSchemaName(),statement.getTableName())); | |
55 | // } catch (DatabaseException e) { | |
56 | // System.err.println(e); | |
57 | // e.printStackTrace(); | |
58 | // } | |
59 | // | |
60 | // return statements.toArray(new SqlStatement[statements.size()]); | |
61 | ||
62 | 0 | return new Sql[] { new UnparsedSql("not supported. FIXME!!") }; |
63 | } | |
64 | } |