在我的概念中,mysql中的text字段应该是没有长度限制的,但是今天事实告诉我,text类型的长度是有限制的。其中mysql的text类型有64K长度限制的,MEDIUMTEXT中型是2G,LONGTEXT大型是4G .
Creating MEDIUMTEXT columns in MySQL using Rails
Adapted from http://www.depixelate.com/2008/5/24/rails-migrations-for-large-text-columns:
create_table :foo do |t| ... t.text :new_col, :limit => 64.kilobytes + 1 ... end
Leave a CommentCreating MEDIUMTEXT columns in MySQL using Rails
Adapted from http://www.depixelate.com/2008/5/24/rails-migrations-for-large-text-columns:
create_table :foo do |t| ... t.text :new_col, :limit => 64.kilobytes + 1 ... end
Leave a Comment
2006-05-27 作者:amao 同分类文章
转一篇文章存入数据库只能显示全面一部分,
ALTER TABLE fib_blog CHANGE content content LONGTEXT NOT NULL
修改数据库,然后看看 .htaccess使用指南 利用这个来让blog静态化。就像bbs.chinahtml.com一样
1.1 Migrations are Classes
A migration is a subclass of ActiveRecord::Migration that implements two class methods: up(perform the required transformations) and down (revert them).
Active Record provides methods that perform common data definition tasks in a database independent way (you’ll read about them in detail later):
- create_table
- change_table
- drop_table
- add_column
- change_column
- rename_column
- remove_column
- add_index
- remove_index
0 | |
add comment |
|
change_column(table_name, column_name, type, options): Changes the column to a different type using the same parameters as add_column.
http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
http://guides.rubyonrails.org/migrations.html
ActiveRecord::Migration.upgrade_table :subtitles do |t|
t.integer :video_id, :null => false
end
这个方法写在rake里,以后就不用migration了,要不然文件太多了,是朋友教我的,呵呵