Quantcast
Channel: Liquibase Forums
Viewing all articles
Browse latest Browse all 2993

H2 Remark support for columns and tables.

$
0
0
Hello,

I stumbled across a lack of support for remarks (comments) when dealing with H2 databases.  H2 supports the SQL standard COMMENT ON... syntax.  I had a look in the source code and it seemed like low hanging fruit, so I sucessfully applied the following patch:
  1. ---
  2.  .../java/liquibase/sqlgenerator/core/SetColumnRemarksGenerator.java   | 4 +++-
  3.  .../java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java    | 3 ++-
  4.  2 files changed, 5 insertions(+), 2 deletions(-)

  5. diff --git a/liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetColumnRemarksGenerator.java b/liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetColumnRemarksGenerator.java
  6. index ec76acf..3661150 100644
  7. --- a/liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetColumnRemarksGenerator.java
  8. +++ b/liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetColumnRemarksGenerator.java
  9. @@ -4,6 +4,7 @@ import liquibase.database.Database;
  10.  import liquibase.database.core.DB2Database;
  11.  import liquibase.database.core.OracleDatabase;
  12.  import liquibase.database.core.PostgresDatabase;
  13. +import liquibase.database.core.H2Database;
  14.  import liquibase.exception.ValidationErrors;
  15.  import liquibase.sql.Sql;
  16.  import liquibase.sql.UnparsedSql;
  17. @@ -20,7 +21,8 @@ public class SetColumnRemarksGenerator extends AbstractSqlGenerator<SetColumnRem
  18.  
  19.   @Override
  20.   public boolean supports(SetColumnRemarksStatement statement, Database database) {
  21. - return database instanceof OracleDatabase || database instanceof PostgresDatabase || database instanceof DB2Database;
  22. + return database instanceof OracleDatabase || database instanceof PostgresDatabase || database instanceof DB2Database
  23. +        || database instanceof H2Database;
  24.   }
  25.  
  26.   @Override
  27. diff --git a/liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java b/liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java
  28. index a4bf263..dfc6e20 100644
  29. --- a/liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java
  30. +++ b/liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java
  31. @@ -5,6 +5,7 @@ import liquibase.database.core.DB2Database;
  32.  import liquibase.database.core.MySQLDatabase;
  33.  import liquibase.database.core.OracleDatabase;
  34.  import liquibase.database.core.PostgresDatabase;
  35. +import liquibase.database.core.H2Database;
  36.  import liquibase.exception.ValidationErrors;
  37.  import liquibase.sql.Sql;
  38.  import liquibase.sql.UnparsedSql;
  39. @@ -18,7 +19,7 @@ public class SetTableRemarksGenerator extends AbstractSqlGenerator<SetTableRemar
  40.   @Override
  41.   public boolean supports(SetTableRemarksStatement statement, Database database) {
  42.   return database instanceof MySQLDatabase || database instanceof OracleDatabase || database instanceof PostgresDatabase
  43. - || database instanceof DB2Database;
  44. + || database instanceof DB2Database || database instanceof H2Database;
  45.   }
  46.  
  47.   @Override
  48. -- 
... that seemed to do the trick for me.  I don't really have the time to figure out what side effects this might have, nor did I write any tests.  If the change is not problematic, I would be thankful if it made its way into a future release so I can avoid using my fork.

Thanks, 
Sam 

Viewing all articles
Browse latest Browse all 2993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>