4 Replies - 4862 Views - Last Post: 19 November 2010 - 09:29 AM Rate Topic: -----

#1 antarr.byrd  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 247
  • Joined: 30-August 09

Rake Migration Failing, invalid date

Posted 11 November 2010 - 11:24 AM

I'm tying to run my migration

But i keep getting this error

class AlterUsers < ActiveRecord::Migration
  def self.up
    rename_table("users", "admin_users")
    add_column("admin_users","username",:string, :limit =>25)
    change_column("admin_users", "email", :string,:limit=>100)
    rename_column("admin_users", "password","hashed_password")
    add_column("admin_users", "salt", :string, :limit=>40)
    add_index("admin_users", "username")
  end
  
  def self.down
    remove_index("admin_users", "username")
    remove_column("admin_users", "salt")
    rename_column("admin_users", "hashed_password","password")
    change_column("admin_users", "email", :string, :default => "", :null =>false)
    remove_coumn("admin_users","username")
    rename_table("admin_users", "users")
  end
end




Quote

C:\Users\myPC\My Documents\sites\s_cms>rails generate migration AlterUsers
invoke active_record
create db/migrate/20101111181902_alter_users.rb

C:\Users\myPC\My Documents\sites\s_cms>rake db:migrate
(in C:/Users/myPC/My Documents/sites/s_cms)
== AlterUsers: migrating =====================================================
-- rename_table("users", "admin_users")
-> 0.0280s
-- add_column("admin_users", "username", :string, {:limit=>25})
-> 0.1820s
-- change_column("admin_users", "email", :string, {:limit=>100})
-> 0.1860s
-- rename_column("admin_users", "password", "hashed_password")
-> 0.2290s
-- add_column("admin_users", "salt", :string, {:limit=>40})
-> 0.2090s
-- add_index("admin_users", "username")
rake aborted!
An error has occurred, all later migrations canceled:

invalid date
C:/Ruby192/lib/ruby/1.9.1/date.rb:1621:in `civil'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/c
onnection_adapters/mysql2_adapter.rb:446:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/c
onnection_adapters/mysql2_adapter.rb:446:in `indexes'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connect
ion_adapters/abstract/schema_statements.rb:410:in `index_name_exists?'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connect
ion_adapters/abstract/schema_statements.rb:346:in `add_index'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:383:in `block in method_missing'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:359:in `block in say_with_time'
C:/Ruby192/lib/ruby/1.9.1/benchmark.rb:294:in `measure'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:359:in `say_with_time'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:379:in `method_missing'
C:/Users/myPC/My Documents/sites/s_cms/db/migrate/20101111181902_alter_users.rb:
8:in `up'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:312:in `block in migrate'
C:/Ruby192/lib/ruby/1.9.1/benchmark.rb:294:in `measure'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:312:in `migrate'
C:in `migrate'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:537:in `block (2 levels) in migrate'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:613:in `call'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:613:in `ddl_transaction'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:536:in `block in migrate'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:523:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:523:in `migrate'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:433:in `up'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/migrati
on.rb:415:in `migrate'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/railtie
s/databases.rake:142:in `block (2 levels) in <top (required)>'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:634:in `call'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:629:in `each'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:629:in `execute'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:595:in `block in invoke_with_call_chain'
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:581:in `invoke'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2041:in `invoke_task'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:in `each'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:1992:in `run'
C:/Ruby192/bin/rake:31:in `<main>'

C:\Users\myPC\My Documents\sites\s_cms>


Is This A Good Question/Topic? 0
  • +

Replies To: Rake Migration Failing, invalid date

#2 antarr.byrd  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 247
  • Joined: 30-August 09

Re: Rake Migration Failing, invalid date

Posted 11 November 2010 - 11:56 AM

I also tried just using this migration, same problem

class AddIndex < ActiveRecord::Migration
  def self.up
    add_index("users", "username")
  end

  def self.down
    remove_index("users", "username")
  end
end



Was This Post Helpful? 0
  • +
  • -

#3 The Neoracle  Icon User is offline

  • Check, check, 1, 2.
  • member icon

Reputation: 21
  • View blog
  • Posts: 4,097
  • Joined: 30-March 01

Re: Rake Migration Failing, invalid date

Posted 11 November 2010 - 01:08 PM

Seeing as how you are using Ruby 1.9.2 and Rails 3 and MySQL2 Gem, without knowing much more about your app, I'd guess this is a bug in ActiveRecord + MySQL2 Gem + Ruby 1.9.2. You are on the very very bleeding edge of Ruby with your current stack. You might try asking on the Rails mailing list or in #rubyonrails on freenode.
Was This Post Helpful? 0
  • +
  • -

#4 antarr.byrd  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 247
  • Joined: 30-August 09

Re: Rake Migration Failing, invalid date

Posted 11 November 2010 - 02:32 PM

It turns out it was an error with MySql2. So i had to create migrates without index, then create another which does it manually.

class AddIndexes < ActiveRecord::Migration
  def self.up
     execute "alter table s_cms_development.pages ADD INDEX pages_permalink(permalink)"
     execute "alter table s_cms_development.pages ADD INDEX pages_subject_id(subject_id)"
     execute "alter table s_cms_development.users ADD INDEX users_username(username)"
  end

  def self.down
    execute "alter table  DROP INDEX pages_permalink, s_cms_development.pages"
    execute "alter table DROP INDEX pages_subject_id, s_cms_development.pages"
    execute "alter table  DROP INDEX users_username, s_cms_development.users"
  end
end



Was This Post Helpful? 0
  • +
  • -

#5 Guest_mikeritter*


Reputation:

Re: Rake Migration Failing, invalid date

Posted 19 November 2010 - 09:29 AM

This looks like the command from running migrations on Rails 3 training on Lynda.com

I ran into the same thing

Have a support request in with the course developer
Was This Post Helpful? 0

Page 1 of 1