3

我已经改变了我的模型

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,整数,:default => 0”

我想迁移现有的 appengine 表以获得额外的字段“trail_count”,我已经阅读了 DataMapper.auto_upgrade!应该这样做。

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

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

4

3 回答 3

1

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

这仍然是一种奇怪且不太好的迁移方式。如何在没有迁移的情况下操作数据?就像将字段“全名”拆分为名字和姓氏字段?你必须为此进行迁移..

于 2010-05-14T22:40:20.067 回答
0

我一直在寻找同样的问题 Roy,似乎迁移在使用数据映射器(或任何其他界面)的应用引擎上不起作用。它是数据存储的一个功能,要更新现有的数据库条目,您必须查询数据库并一次更新一些以避免达到速率限制。 资源

于 2010-07-07T01:02:28.217 回答
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!

在这里找到答案

于 2016-05-06T18:27:01.050 回答