Search code examples
ruby-on-railsdatabasesqlitesqlite3-ruby

Sqlite3 in ruby on rails and cmd


I have a table with name buildings and I want to drop it because i forgot a column. In cmd I go to the folder and type "sqlite3" then ".tables" and nothing shows me. why that? and what can i do?


Solution

  • You should avoid directly manipulating the database and use migrations instead. If you forgot to add a column then you should create a new migration using add_column to add the column to the table.

    Alternativly if the previous migration was the one that created the table with the missing column and you've not distributed this migration yet you can do rake db:rollback, editing the migration and run rake db:migrate again.

    Your lack of tables when running the sqlite command is most likely because you forgot to specify the sqlite file to load: sqlite3 <db_name>