ageery
2010-10-02 18:20:20 UTC
PostgreSQL supports "Oracle-style" table and column comments (since at least
7.1 -- http://www.postgresql.org/docs/7.1/static/sql-comment.html). The
patch below makes this functionality available for PostgreSQL.
Thanks
Andrew
### Eclipse Workspace Patch 1.0
#P liquibase-trunk
Index:
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java
===================================================================
---
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java
(revision 1770)
+++
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java
(working copy)
@@ -3,6 +3,7 @@
import liquibase.database.Database;
import liquibase.database.core.MySQLDatabase;
import liquibase.database.core.OracleDatabase;
+import liquibase.database.core.PostgresDatabase;
import liquibase.exception.ValidationErrors;
import liquibase.sql.Sql;
import liquibase.sql.UnparsedSql;
@@ -14,7 +15,7 @@
@Override
public boolean supports(SetTableRemarksStatement statement, Database
database) {
- return database instanceof MySQLDatabase || database instanceof
OracleDatabase;
+ return database instanceof MySQLDatabase || database instanceof
OracleDatabase || database instanceof PostgresDatabase;
}
public ValidationErrors validate(SetTableRemarksStatement
setTableRemarksStatement, Database database, SqlGeneratorChain
sqlGeneratorChain) {
@@ -27,7 +28,7 @@
public Sql[] generateSql(SetTableRemarksStatement statement, Database
database, SqlGeneratorChain sqlGeneratorChain) {
String sql;
String remarks =
database.escapeStringForDatabase(statement.getRemarks());
- if (database instanceof OracleDatabase) {
+ if (!(database instanceof MySQLDatabase)) {
sql = "COMMENT ON TABLE
"+database.escapeTableName(statement.getSchemaName(),
statement.getTableName())+" IS '"+remarks+"'";
} else {
sql = "ALTER TABLE
"+database.escapeTableName(statement.getSchemaName(),
statement.getTableName())+" COMMENT = '"+remarks+"'";
Index:
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetColumnRemarksGeneratorOracle.java
===================================================================
---
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetColumnRemarksGeneratorOracle.java
(revision 1770)
+++
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetColumnRemarksGeneratorOracle.java
(working copy)
@@ -2,6 +2,7 @@
import liquibase.database.Database;
import liquibase.database.core.OracleDatabase;
+import liquibase.database.core.PostgresDatabase;
import liquibase.exception.ValidationErrors;
import liquibase.sql.Sql;
import liquibase.sql.UnparsedSql;
@@ -17,7 +18,7 @@
@Override
public boolean supports(SetColumnRemarksStatement statement, Database
database) {
- return database instanceof OracleDatabase;
+ return database instanceof OracleDatabase || database instanceof
PostgresDatabase;
}
public ValidationErrors validate(SetColumnRemarksStatement
setColumnRemarksStatement, Database database, SqlGeneratorChain
sqlGeneratorChain) {
7.1 -- http://www.postgresql.org/docs/7.1/static/sql-comment.html). The
patch below makes this functionality available for PostgreSQL.
Thanks
Andrew
### Eclipse Workspace Patch 1.0
#P liquibase-trunk
Index:
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java
===================================================================
---
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java
(revision 1770)
+++
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetTableRemarksGenerator.java
(working copy)
@@ -3,6 +3,7 @@
import liquibase.database.Database;
import liquibase.database.core.MySQLDatabase;
import liquibase.database.core.OracleDatabase;
+import liquibase.database.core.PostgresDatabase;
import liquibase.exception.ValidationErrors;
import liquibase.sql.Sql;
import liquibase.sql.UnparsedSql;
@@ -14,7 +15,7 @@
@Override
public boolean supports(SetTableRemarksStatement statement, Database
database) {
- return database instanceof MySQLDatabase || database instanceof
OracleDatabase;
+ return database instanceof MySQLDatabase || database instanceof
OracleDatabase || database instanceof PostgresDatabase;
}
public ValidationErrors validate(SetTableRemarksStatement
setTableRemarksStatement, Database database, SqlGeneratorChain
sqlGeneratorChain) {
@@ -27,7 +28,7 @@
public Sql[] generateSql(SetTableRemarksStatement statement, Database
database, SqlGeneratorChain sqlGeneratorChain) {
String sql;
String remarks =
database.escapeStringForDatabase(statement.getRemarks());
- if (database instanceof OracleDatabase) {
+ if (!(database instanceof MySQLDatabase)) {
sql = "COMMENT ON TABLE
"+database.escapeTableName(statement.getSchemaName(),
statement.getTableName())+" IS '"+remarks+"'";
} else {
sql = "ALTER TABLE
"+database.escapeTableName(statement.getSchemaName(),
statement.getTableName())+" COMMENT = '"+remarks+"'";
Index:
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetColumnRemarksGeneratorOracle.java
===================================================================
---
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetColumnRemarksGeneratorOracle.java
(revision 1770)
+++
liquibase-core/src/main/java/liquibase/sqlgenerator/core/SetColumnRemarksGeneratorOracle.java
(working copy)
@@ -2,6 +2,7 @@
import liquibase.database.Database;
import liquibase.database.core.OracleDatabase;
+import liquibase.database.core.PostgresDatabase;
import liquibase.exception.ValidationErrors;
import liquibase.sql.Sql;
import liquibase.sql.UnparsedSql;
@@ -17,7 +18,7 @@
@Override
public boolean supports(SetColumnRemarksStatement statement, Database
database) {
- return database instanceof OracleDatabase;
+ return database instanceof OracleDatabase || database instanceof
PostgresDatabase;
}
public ValidationErrors validate(SetColumnRemarksStatement
setColumnRemarksStatement, Database database, SqlGeneratorChain
sqlGeneratorChain) {
--
View this message in context: http://old.nabble.com/Table---column-comments-in-PG-tp29867445p29867445.html
Sent from the LiquiBase - User mailing list archive at Nabble.com.
View this message in context: http://old.nabble.com/Table---column-comments-in-PG-tp29867445p29867445.html
Sent from the LiquiBase - User mailing list archive at Nabble.com.