0

I'm using rails to build an application which allows users to authorize and connect to the Twitter API using their Twitter account. The log in works, but i have a problem with the posts (i'm using this gem): when i try to run rails db:migrate i get this error:

$ rails db:migrate
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR:  relation "tweets" already exists
: CREATE TABLE "tweets" ("id" serial primary key, "user_id" integer, "body" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
C:/Users/......./db/migrate/20170419185735_create_tweets.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR:  relation "tweets" already exists
: CREATE TABLE "tweets" ("id" serial primary key, "user_id" integer, "body" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
C:/Users/......./db/migrate/20170419185735_create_tweets.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
PG::DuplicateTable: ERROR:  relation "tweets" already exists
C:/Users/......./db/migrate/20170419185735_create_tweets.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
== 20170419185735 CreateTweets: migrating =====================================
-- create_table(:tweets)

I'm new to rails so any help would be appreciated!

  • It looks like you already have a table named `tweets` and your migration is failing. Did you create that manually prior to using the gem? Can you scrub your database and rebuild it from scratch using `rake db:migrate`? – tadman Apr 19 '17 at 18:47
  • 1
    I used `rails db:reset`. Thank you very much! It's working now! – Cristina Mihailescu Apr 19 '17 at 18:59

0 Answers0