1 | |
package liquibase.sqlgenerator.core; |
2 | |
|
3 | |
import liquibase.database.Database; |
4 | |
import liquibase.database.typeconversion.TypeConverterFactory; |
5 | |
import liquibase.database.core.MaxDBDatabase; |
6 | |
import liquibase.database.structure.Column; |
7 | |
import liquibase.database.structure.Table; |
8 | |
import liquibase.sql.Sql; |
9 | |
import liquibase.sql.UnparsedSql; |
10 | |
import liquibase.sqlgenerator.SqlGenerator; |
11 | |
import liquibase.sqlgenerator.SqlGeneratorChain; |
12 | |
import liquibase.statement.core.AddDefaultValueStatement; |
13 | |
|
14 | 75 | public class AddDefaultValueGeneratorMaxDB extends AddDefaultValueGenerator { |
15 | |
@Override |
16 | |
public int getPriority() { |
17 | 5 | return SqlGenerator.PRIORITY_DATABASE; |
18 | |
} |
19 | |
|
20 | |
@Override |
21 | |
public boolean supports(AddDefaultValueStatement statement, Database database) { |
22 | 65 | return database instanceof MaxDBDatabase; |
23 | |
} |
24 | |
|
25 | |
@Override |
26 | |
public Sql[] generateSql(AddDefaultValueStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { |
27 | 0 | Object defaultValue = statement.getDefaultValue(); |
28 | 0 | return new Sql[] { new UnparsedSql("ALTER TABLE " |
29 | |
+ database.escapeTableName(statement.getSchemaName(), statement.getTableName()) |
30 | |
+ " COLUMN " |
31 | |
+ database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), |
32 | |
statement.getColumnName()) |
33 | |
+ " ADD DEFAULT " |
34 | |
+ TypeConverterFactory.getInstance().findTypeConverter(database).getDataType(defaultValue) |
35 | |
.convertObjectToString(defaultValue, database), new Column().setTable( |
36 | |
new Table(statement.getTableName()).setSchema(statement.getSchemaName())).setName( |
37 | |
statement.getColumnName())) }; |
38 | |
} |
39 | |
} |