如何在 appengine 上迁移 Datamapper
我已将模型从 更改为
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
刚刚添加了“property :trail_count, Integer, :default => 0”,
并且我想迁移现有的 appengine 表以拥有额外的字段“trail_count” 我读过 DataMapper.auto_upgrade!应该这样做。
但我收到错误“未定义方法‘auto_upgrade!’对于 DataMapper:Module”,
您可以帮助我如何迁移 DM 模型吗?
I've changed my model from
class Place
include DataMapper::Resource
has n, :trails
property :id, Serial
property :name, String, :length => 140
property :tag, String, :required => true
timestamps :at
end
to
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
I just added "property :trail_count, Integer, :default => 0"
and i want to migrate the existing appengine table to have the extra field "trail_count"
i've read that DataMapper.auto_upgrade! should do it.
but i get an error "undefined method `auto_upgrade!' for DataMapper:Module"
can you please help How do i migrate the DM models?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
第三次重新启动服务器后,该字段奇迹般地添加了。
这仍然是一种奇怪且不太好的迁移方式。
如何在不迁移的情况下操作数据?就像将“全名”字段拆分为名字和姓氏字段一样?你必须为此进行迁移..
After restarting the server for the third time the field was miraculously added.
It's still a weird and not so good way to do migrations.
how do you manipulate data without migrations? like splitting a field "full name" to first and last name fields? you gotta have a migration for that..
我一直在寻找同样的问题罗伊,看来迁移在使用数据映射器(或任何其他接口)的应用程序引擎上不起作用。它是数据存储的一项功能,要更新现有数据库条目,您必须查询数据库并一次更新一些条目,以避免达到速率限制。
来源
I've been looking up the same issue Roy and it appears migrations don't work on app engine using datamapper (or any other interface). It's a function of the datastore, and to update existing database entries you'll have to query the database and update a few at a time to avoid hitting rate limits.
source
尝试要求 dm-migrations gem。这就是我解决 Sinatra 1.4.7 和 do_sqlite3 0.10.17 问题的方法。
require 'dm-migrations'
此处找到答案
Try requiring the dm-migrations gem. This was how I resolved the issue with Sinatra 1.4.7 and do_sqlite3 0.10.17.
require 'dm-migrations'
answer found here