# Could ActiveRecord add some comments when create table

**URL:** <https://www.ruby-forum.com/t/could-activerecord-add-some-comments-when-create-table/131656>\
**Category:** Rails\
**Created:** [March 12, 2008, 8:00am UTC](https://www.ruby-forum.com/t/could-activerecord-add-some-comments-when-create-table/131656 "2008-03-12T08:00:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phoenix520](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/6f9a4e/32.png) [@phoenix520](https://www.ruby-forum.com/u/phoenix520)\
**Post date:** [March 12, 2008, 8:00am UTC](https://www.ruby-forum.com/t/could-activerecord-add-some-comments-when-create-table/131656/1 "2008-03-12T08:00:33Z")

</div>

Could ActiveRecord add some comments for a column when create a  
table?For example use some sentence like this:

create\_table :blogs do |t|  
t.string, :blog\_title, :limit=\>100,:null=\>false, :comment=\>‘my blog  
title’  
end

After do this,I can use the comment instead of the human name of  
column,it’s more suitable.

---

<div class="post-metadata">

**Author:** ![phoenix520](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/6f9a4e/32.png) [@phoenix520](https://www.ruby-forum.com/u/phoenix520)\
**Post date:** [March 12, 2008, 9:34am UTC](https://www.ruby-forum.com/t/could-activerecord-add-some-comments-when-create-table/131656/2 "2008-03-12T09:34:14Z")

</div>

Wu Junchen wrote:

> Could ActiveRecord add some comments for a column when create a  
> table?

Column comments are not part of the table as such and not available in  
all databases. The normal solution for this sort of requirement is to  
encode it yourself. In your migration, use something like:

class CreateUsers \< ActiveRecord::Migration  
def self.up  
create\_table :users do |t|  
t.string :name  
t.datetime :dob  
t.timestamps  
end  
if config[RAILS\_ENV][‘adapter’].match(/oracle|oci/)  
execute “comment on column users.name is ‘The username of the  
user’”  
end  
end  
:
