SQLite3::SQLException: table already exists: code example

Example 1: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL

rake db:drop
rake db:create
rake db:migrate

Example 2: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL

class DropCategoriesTable < ActiveRecord::Migration
     def up
       drop_table :categories
     end

     def down
       raise ActiveRecord::IrreversibleMigration
     end
end

Tags:

Sql Example