Domanda

am currently working on a rails project. When i tried to start rails server its throwing the following error:

=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters      
/sqlite_adapter.rb:439:in `table_structure': Could not find table 'dbrick'   
(ActiveRecord::StatementInvalid)

My table name is 'dbrick'. I also Tried to rake db:drop and rake db:mirgrate. While migrating its throwing the following error:

rake aborted!
Could not find table 'dbrick'

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

This is my migrate file:

class CreateDbricks < ActiveRecord::Migration
def self.up
  create_table :dbricks do |t|
    t.text :description
    t.string :video
    t.string :video_html
    t.string :image_id
    t.string :option_id
    t.boolean :choice
    t.string :reach
    t.integer :category_id
    t.string :user_id
    t.datetime :deleted_at

    t.timestamps
  end
end

 def self.down
   drop_table :dbricks
 end
end

It will be so much help full if any one help me out of this. Thanks in advance.

È stato utile?

Soluzione

I would try :

rake db:schema:load

To load your schema ( to which I believe its finding the error against your DB ).

If that fails, I would manually find the migration that creates your dbrick, locate the name of the file and copy and paste the number in the filename to produce this :

rake db:migrate:down VERSION=123412341234 # <-- where the number is the number you pasted

Look for errors. Occasionally one thing exists already, or doesn't exist already and prevents the migration from running all the way, and consequentially that would be the source of your error. If it goes successfully then rake it back up :

rake db:migrate:up VERSION=123412341234 # <-- where the number is the number you pasted

If it doesn't go successfully, then you'll have to put on your miner's helmet, and get your hands dirty with :

rails dbconsole

Which will take you into your database and you'll have to manually delete whatever table/column is preventing the migration from occurring. Once that is fixed, exit out and rake db:migrate:up!

Altri suggerimenti

Have you migrated your database? rake db:migrate

If you have, drop your database (this deletes all data, so be careful - do it if you do not care about losing data in your db)

rake db:drop

This will clear out your database, and your schema. Then

rake db:migrate

This will re-migrate your schema.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top