我有更新迁移脚本下DB /迁移和Ruby on Rails的:如何使修改数据库模型
class CreateStudents < ActiveRecord::Migration
def change
create_table :students do |t|
t.string :firstname
t.string :lastname
t.string :account
t.timestamps
end
end
end
DATABSE剧本后,我做了一个
rake db:migrate
数据库脚本更新之前更新
class CreateStudents < ActiveRecord::Migration
def change
create_table :students do |t|
t.string :firstname
t.string :lastname
t.string :account
t.string :address
t.string :city
t.string :state
t.string :postcode
t.string :homephone
t.timestamps
end
end
end
我丢弃了旧的development.sqlite3和旧的schema在schame.rb中。
说我添加了几列,但在模型中这些列丢失。
但我的模式仍然是
class Student < ActiveRecord::Base
attr_accessible :firstname,:lastname,:account,
end
有一个简单的方法使我能在新的迁移脚本修改模型?
你的意思是什么样的变化? – eeeeeean
@eeeeeean说我添加了几列,但在模型中这些列丢失 – icn
给出的例子。你的问题含糊不清。 – Huy