Forum: Ruby on Rails rake migrate problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7492b14ddb61f186cdb44843ac5a3ac1?d=identicon&s=25 doucie (Guest)
on 2007-02-04 14:43
I've created this migrate file.  I run rake migrate from the prompt but
it does not create a table.  Any ideas?

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.column :login, :string
      t.column :password, :string
      t.column :email, :string
    end
    add_column :new_queries, :user_id, :integer
  end

  def self.down
    drop_table :users
    remove_column :new_queries, :user_id
  end
end
1fba4539b6cafe2e60a2916fa184fc2f?d=identicon&s=25 unknown (Guest)
on 2007-02-04 15:49
(Received via mailing list)
Hi --

On Sun, 4 Feb 2007, doucie wrote:

>    end
>    add_column :new_queries, :user_id, :integer
>  end
>
>  def self.down
>    drop_table :users
>    remove_column :new_queries, :user_id
>  end
> end

If it's not giving you an error message, but also not saying it's
creating a table, that probably means it's not running the migration,
and that probably means that for some reason it thinks it's already
done that migration.  You'd have to migrate down and back up again
(and fix any inconsistencies by hand).


David

--
Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    (See what readers are saying!  http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)
7492b14ddb61f186cdb44843ac5a3ac1?d=identicon&s=25 doucie (Guest)
on 2007-02-04 18:05
I take it this is down throught the prompt?  What are the commands?
04952a6ee948f345e9c3727850d09a1b?d=identicon&s=25 dima (Guest)
on 2007-02-04 19:13
(Received via mailing list)
in your Rails app path
to drop all your migration to the start point: rake db:migrate
VERSION=0
to bring up the db: rake db:migrate

To roll the database back to a previous migration version: rake
db:migrate VERSION=X
7492b14ddb61f186cdb44843ac5a3ac1?d=identicon&s=25 doucie (Guest)
on 2007-02-04 21:05
I've done the rake db:migrate VERSION=0.
There was not a response in the promp other than giving the directory
where the app is stored.  I still had the schema and users table.
7492b14ddb61f186cdb44843ac5a3ac1?d=identicon&s=25 doucie (Guest)
on 2007-02-04 21:08
I've deleted my other table and ran rake migrate again.  This has
worked.  Both tables have been created.  Any dangers of doing this?
391f7ae8dd8c10dc323b7fbfe55b71a2?d=identicon&s=25 monki (Guest)
on 2007-02-05 22:11
(Received via mailing list)
Deleting the tables and remigrating shouldn't cause any problems (as
long as you don't care about the data).

The schema table keeps track of migrations, so by deleting it and
everything else you should be at square one.
This topic is locked and can not be replied to.