Rake migrate problem

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

I take it this is down throught the prompt? What are the commands?

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

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)

I’ve deleted my other table and ran rake migrate again. This has
worked. Both tables have been created. Any dangers of doing this?

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.

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs