Skip to content
This repository has been archived by the owner on Jul 2, 2022. It is now read-only.

Commit

Permalink
added customDatatype for correct text mapping (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
KushnirykOleh committed Jan 22, 2021
1 parent 1a13bff commit dfc41f3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ See [getJdbcCatalogName](#getJdbcCatalogName)

The `datetime` datatype in Snowflake is an alias for the datatype `timestamp_ntz`, [Date and Time Data Types](https://docs.snowflake.net/manuals/sql-reference/data-types.html#date-and-time-data-types).
The `TimestampNTZType` class clarifies this mapping from Liquibase `datetime` to Snowflake `timestamp_ntz`.

To map `text` datatype in changesets to `text` Snowflake datatype SnowflakeTextDataType class is added (default liquibase-core classes maps it to `CLOB`)

## ChangeLog

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package liquibase.ext.snowflake.datatype;

import liquibase.change.core.LoadDataChange;
import liquibase.database.Database;
import liquibase.datatype.DataTypeInfo;
import liquibase.datatype.DatabaseDataType;
import liquibase.datatype.LiquibaseDataType;
import liquibase.ext.snowflake.database.SnowflakeDatabase;

@DataTypeInfo(name = "text", minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DATABASE)
public class SnowflakeTextDataType extends LiquibaseDataType {

@Override
public boolean supports(Database database) {
return database instanceof SnowflakeDatabase;
}

@Override
public DatabaseDataType toDatabaseDataType(Database database) {
if (database instanceof SnowflakeDatabase) {
return new DatabaseDataType("TEXT", getParameters());
}
return super.toDatabaseDataType(database);
}

@Override
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
return LoadDataChange.LOAD_DATA_TYPE.STRING;
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
liquibase.ext.snowflake.datatype.TimestampNTZType
liquibase.ext.snowflake.datatype.SnowflakeTextDataType
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE createTableDataTypeText (textCol TEXT)

0 comments on commit dfc41f3

Please sign in to comment.