I have installed a blog engine to refinerycms which is working perfectly.
Now I have generated a migration with some table fields changes (of course not refinerycms or blog tables), but I'm getting an error:
== CreateBlogStructure: migrating ============================================
-- create_table("refinery_blog_posts", {:id=>true})
NOTICE: CREATE TABLE will create implicit sequence "refinery_blog_posts_id_seq1" for serial column "refinery_blog_posts.id"
rake aborted!
An error has occurred, this and all later migrations canceled:PG::Error: ERROR: relation "refinery_blog_posts" already exists
: CREATE TABLE "refinery_blog_posts" ("id" serial primary key, "title" character varying(255), "body" text, "draft" boolean, "published_at" timestamp, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)Tasks: TOP => db:migrate
(See full trace by running task with --trace)
To check for status, run rails db:migrate:status . Then you'll have a good view of the migrations you want to remove. Then, run rails db:rollback to revert the changes one by one. After doing so, you can check the status again to be fully confident.
rails db:reset:primary Drops and recreates the primary database from its schema for the current environment and loads the seeds. rails db:reset:secondary Drops and recreates the secondary database from its schema for the current environment and loads the seeds.
PG::Error: ERROR: relation “refinery_blog_posts” already exists
Pg is a Rails gem, the piece of code that allows communication between Rails and PostgreSQL. It relates your migrations to SQL tables, thus a relation error. So, what the error is saying is:
I'm trying to create table X, based on migration X, but table X already exists in the database.
Possible solutions:
Login to PostgreSQL and drop the table. Something like:
$ psql -U username databasename
then
database_name=# drop table table-name;
The exact commands might be a little different though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With