-2

i had typed in cmd of ruby on rails command rails generate controller user name:string email:string once it is created when i type in rake db:migrate it shows error like this: C:\Sites\twinkle>rake db:migrate (in C:/Sites/twinkle) == CreateMembers: migrating ================================================== -- create_table(:members) rake aborted! An error has occurred, this and all later migrations canceled:

 SQLite3::SQLException: table "members" already exists: CREATE TABLE "members" ("
  id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "email" var
  char(255), "created_at" datetime, "updated_at" datetime)

what should i do?

3 Answers3

3

This error means you already have a table called 'members' in your database. Remove your Members table and try again. Rails can't 'overwrite' the table so you have to make a new one.

You can drop your table like this:

  1. $rails console

  2. ActiveRecord::Migration.drop_table(:members)

Now you can run rake db:migrate again. it will work now.

Kees Sonnema
  • 5,759
  • 6
  • 51
  • 106
0

Seems table members already exists.

Try removing the table from db

Siva
  • 7,780
  • 6
  • 47
  • 54
0

See this Rails DB Migration - How To Drop a Table? for drop your existing table

Community
  • 1
  • 1
visnu
  • 935
  • 6
  • 16