How to transfer datamapper to appengine

I 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 a property: trail_count, Integer ,: default => 0 "

and I want to migrate the existing appengine table to have an extra field "trail_count" I read that DataMapper.auto_upgrade! gotta do it.

but I get the error message "undefined method` auto_upgrade! 'for DataMapper: module"

Please help, how can I migrate DM models?

+3
source share
3 answers

After restarting the server for the third time, this miracle was added.

. ? , " " ? .

+1

, Roy, , , datamapper ( ). , .

0

dm-migrations. 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!

0

Source: https://habr.com/ru/post/1745524/


All Articles