CREATE TABLE Vereninging( id INT NOT NULL AUTO_INCREMENT, naam VARCHAR(30), oprichtingsjaar INT NOT NULL CHECK (oprichtingsjaar > 2015), primary key(id) ); 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