Basic Rails issue during migration (Rails 2.3.11) -
i having basic rails issue during migrations. here 2 scripts
class creategooglemaps < activerecord::migration def self.up create_table :google_maps |t| t.string :name, :null => false t.string :description t.column "center", :point, :null => false, :srid => 4326, :with_z => false # 4326: wsg84 t.integer :zoom t.datetime :created_at t.datetime :updated_at t.integer :created_by_id t.integer :updated_by_id end end def self.down drop_table :google_maps end end
file #2 +++ 003_add_map_style.rb ++++++
class addmapstyle < activerecord::migration def self.up add_column :google_maps, :style, :integer googlemaps.update_all( "style = 1") end def self.down remove_column :google_maps, :style end end ***********************************************
here's i'm seeing during migration == creategooglemaps: migrating =============================================== -- create_table(:google_maps) -> 0.0638s == creategooglemaps: migrated (0.0640s) ======================================
== createmarkers: migrating ================================================== -- create_table(:markers) -> 0.0537s == createmarkers: migrated (0.0539s) =========================================
== addmapstyle: migrating ==================================================== -- add_column(:google_maps, :style, :integer) -> 0.0406s rake aborted! error has occurred, later migrations canceled:
uninitialized constant addmapstyle::googlemaps
i'm using rails 2.3.11. debugging tip appreciated !
you can safely utilize models in migrations so:
class addmapstyle < activerecord::migration class googlemaps < activerecord::base; end def self.up add_column :google_maps, :style, :integer googlemaps.update_all( "style = 1") end def self.down remove_column :google_maps, :style end end
since class defined within migration class, in separate namespace.
ruby-on-rails migration
No comments:
Post a Comment