Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Liquibase]: Fix check unique index #52

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion liquibase-dialect/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>tech.ydb.dialects</groupId>
<artifactId>liquibase-ydb-dialect</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>

<name>Liquibase YDB Dialect</name>
<description>Support Liquibase YDB Dialect</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public ValidationErrors validate(
ValidationErrors errors = super.validate(createIndexStatement, database, sqlGeneratorChain);
errors.checkRequiredField("name", createIndexStatement.getIndexName());

if (createIndexStatement.isUnique()) {
if (createIndexStatement.isUnique() != null && createIndexStatement.isUnique()) {
errors.addError(DOES_NOT_SUPPORT_UNIQUE_CONSTRAINT +
"[table name = " + createIndexStatement.getTableName() + ", " +
"index name = " + createIndexStatement.getIndexName() + "]");
Expand All @@ -116,10 +116,10 @@ public ValidationErrors validate(
badColumnStrPointer(createIndexStatement, column));
}

if (column.getComputed() != null && column.getComputed()) {
errors.addError("YDB doesn't support computed column in index! " +
badColumnStrPointer(createIndexStatement, column));
}
if (column.getComputed() != null && column.getComputed()) {
errors.addError("YDB doesn't support computed column in index! " +
badColumnStrPointer(createIndexStatement, column));
}
}

return errors;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package tech.ydb.liquibase.type;

import liquibase.change.core.LoadDataChange;
import liquibase.datatype.DataTypeInfo;
import liquibase.datatype.LiquibaseDataType;

/**
* @author Kirill Kurdyukov
*/
@DataTypeInfo(
name = "Date",
minParameters = 0,
maxParameters = 0,
aliases = {"java.sql.Types.DATE", "smalldatetime"},
priority = LiquibaseDataType.PRIORITY_DATABASE
)
public class DateTypeYdb extends BaseTypeYdb {

@Override
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
return LoadDataChange.LOAD_DATA_TYPE.DATE;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
tech.ydb.liquibase.type.BoolTypeYdb
tech.ydb.liquibase.type.BytesTypeYdb
tech.ydb.liquibase.type.DateTypeYdb
tech.ydb.liquibase.type.DecimalTypeYdb
tech.ydb.liquibase.type.DoubleTypeYdb
tech.ydb.liquibase.type.FloatTypeYdb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void changelogXmlMigrationAllTypesTableTest() throws SQLException, LiquibaseExce
"float_column FLOAT, double_column DOUBLE, " +
"decimal_column DECIMAL(22,9), text_column TEXT, " +
"binary_column BYTES, json_column JSON, " +
"jsondocument_column JSONDOCUMENT, date_column date, " +
"jsondocument_column JSONDOCUMENT, date_column DATE, " +
"datetime_column DATETIME, timestamp_column TIMESTAMP, " +
"interval_column INTERVAL, PRIMARY KEY (id) );"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private static void changeLogStep1() throws SQLException, LiquibaseException {
outputMigration.contains(
"-- Changeset changelogs/migration/series.xml::series::kurdyukov-kir\n" +
"-- Table series.\n" +
"CREATE TABLE series (series_id INT64, title TEXT, series_info TEXT, release_date date, PRIMARY KEY (series_id) );\n" +
"CREATE TABLE series (series_id INT64, title TEXT, series_info TEXT, release_date DATE, PRIMARY KEY (series_id) );\n" +
"\n" +
"ALTER TABLE series ADD INDEX series_index GLOBAL ON (title);\n" +
"\n" +
Expand Down