2010-05-14 33 views
3

我已经改变了我的模型从我怎么迁移DataMapper的AppEngine上

class Place 
    include DataMapper::Resource 
    has n, :trails 

    property :id,   Serial 
    property :name,   String,   :length => 140 
    property :tag,   String,   :required => true 
    timestamps :at 
end 

class Place 
    include DataMapper::Resource 
    has n, :trails 

    property :id,   Serial 
    property :name,   String,   :length => 140 
    property :tag,   String,   :required => true 
    property :trail_count, Integer,  :default => 0 
    timestamps :at 
end 

我只是说 “属性:trail_count,整型:默认=> 0”

并且我想迁移现有的appengine表,让我有更多的字段“trail_count” 我读过DataMapper.auto_upgrade!应该这样做。

但我得到一个错误“未定义的方法`auto_upgrade!'对于DataMapper:模块“

你能请帮助我如何迁移DM模型?

回答

1

第三次重新启动服务器后,奇怪地添加了该字段。

这仍然是一个奇怪的,不是很好的方式来进行迁移。 如何在没有迁移的情况下操作数据?比如将字段“全名”分割为姓和名字段?你必须有一个迁移..

0

我一直在寻找同样的问题罗伊,似乎迁移不适用于应用程序引擎使用数据映射(或任何其他接口)。这是数据存储的功能,为了更新现有的数据库条目,您必须一次查询数据库并更新一些数据库,以避免达到速率限制。 source

0

尝试要求dm-migrations gem。这是我用Sinatra 1.4.7和do_sqlite3 0.10.17解决问题的方法。

require 'dm-migrations'

require 'rubygems' 
require 'sinatra' 
require 'dm-core' 
require 'dm-timestamps' 
require 'dm-sqlite-adapter' 
require 'dm-migrations' 

DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/adserver.db") 

class Ad 

    include DataMapper::Resource 

    property :id,      Serial 
    property :title,     String 
    property :content,    Text 
    property :width,     Integer 
    property :height,     Integer 
    property :filename,    String 
    property :url,     String 
    property :is_active,    Boolean 
    property :created_at,    DateTime 
    property :updated_at,    DateTime 
    property :size,     Integer 
    property :content_type,   String 

end 

# Create or upgrade all table at once, like magic 
DataMapper.auto_upgrade! 

answer found here

相关问题