Created
August 3, 2010 01:19
-
-
Save huacnlee/505658 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails migrate 克隆表结构 | |
class CreateArticleClones < ActiveRecord::Migration | |
def self.up | |
create_table :article_clones do |t| | |
# 从 Article 的 columns 里面找,注意! Article 的表结构必须在这个 Migrate 之前有创建! | |
Article.columns.each do |col| | |
next if col.name == "id" | |
t.send(col.type.to_sym, col.name.to_sym, :null => col.null, | |
:limit => col.limit, :default => col.default, :scale => col.scale, | |
:precision => col.precision) | |
end | |
end | |
end | |
def self.down | |
drop_table :article_clones | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment