How to generate an sql comment using a migration file?

I'd like to use migrations to add/remove/modify columns from a database. Rails makes that relatively painless. One feature I don't see is the ability to comment on columns in the schema. How can I add a column comment to a migration?

We're using Oracle/PosgreSQL (and we're thinking of adding SQL Server in the future.)

The SQL for adding a comment to a column is oddly enough the same for all three it seems but I'd rather not take a chance.

COMMENT ON COLUMN table_name.column_name IS 'Random Comment';

Thanks in advance,

M

Jason Cameron wrote in post #984994:

I'd like to use migrations to add/remove/modify columns from a database. Rails makes that relatively painless. One feature I don't see is the ability to comment on columns in the schema. How can I add a column comment to a migration?

We're using Oracle/PosgreSQL (and we're thinking of adding SQL Server in the future.)

The SQL for adding a comment to a column is oddly enough the same for all three it seems but I'd rather not take a chance.

COMMENT ON COLUMN table_name.column_name IS 'Random Comment';

It's possible run whatever SQL you like using "execute" in a migration. I don't think this is a common enough problem to add to the DSL of migrations.

So for the above add this to your migration:

execute "COMMENT ON COLUMN table_name.column_name IS 'Random Comment'"