return old_way
end
- def save
+ def save_with_dependencies
t = Time.now
self.timestamp = t
self.save
- WayTag.delete_all(['id = ?', self.id])
-
self.tags.each do |k,v|
- tag = WayTag.new
+ tag = OldWayTag.new
tag.k = k
tag.v = v
tag.id = self.id
tag.save
end
- WaySegment.delete_all(['id = ?', self.id])
-
i = 0
self.segs.each do |n|
- seg = WaySegment.new
+ seg = OldWaySegment.new
seg.id = self.id
seg.segment_id = n
seg.sequence_id = i
--- /dev/null
+class OldWaySegment < ActiveRecord::Base
+end
--- /dev/null
+class OldWayTag < ActiveRecord::Base
+end
end
old_way = OldWay.from_way(self)
- old_way.save
+ old_way.save_with_dependencies
end
end
--- /dev/null
+class CreateOldWayTags < ActiveRecord::Migration
+ def self.up
+ create_table :old_way_tags do |t|
+ # t.column :name, :string
+ end
+ end
+
+ def self.down
+ drop_table :old_way_tags
+ end
+end
--- /dev/null
+class CreateOldWaySegments < ActiveRecord::Migration
+ def self.up
+ create_table :old_way_segments do |t|
+ # t.column :name, :string
+ end
+ end
+
+ def self.down
+ drop_table :old_way_segments
+ end
+end