runtimerevolution / survey

Survey is a Rails Engine that brings quizzes, surveys and contests into your Rails application.
MIT License
265 stars 127 forks source link

DB Migration Error #26

Open pvagare opened 9 years ago

pvagare commented 9 years ago

Hi ,

Please suggest the solution for Db migration error.

PG::UndefinedTable: ERROR: relation "surveys" does not exist : CREATE TABLE "survey_questions" ("id" serial primary key, "survey_id" integer, "text" character varying(255), "created_at" timestamp, "updated_at" timestamp, CONSTRAINT fk_survey_questions_survey_id FOREIGN KEY ("survey_id") REFERENCES "surveys" ("id")) /home/test/db/migrate/20150515142125_create_survey.rb:15:in up' ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "surveys" does not exist : CREATE TABLE "survey_questions" ("id" serial primary key, "survey_id" integer, "text" character varying(255), "created_at" timestamp, "updated_at" timestamp, CONSTRAINT fk_survey_questions_survey_id FOREIGN KEY ("survey_id") REFERENCES "surveys" ("id")) /home/test/db/migrate/20150515142125_create_survey.rb:15:inup' PG::UndefinedTable: ERROR: relation "surveys" does not exist /home/test/db/migrate/20150515142125_create_survey.rb:15:in `up' Tasks: TOP => db:migrate (See full trace by running task with --trace)

Thank you !

alex-quiterio commented 9 years ago

Hi @pvagare,

Did you change the migration file to force a foreign key reference between survey_questions and surveys?

I'm trying to mimic your issues with the migration, but I'm not seeing that constraint in the Postgres generated SQL. Could you show me the 20150515142125_create_survey.rb and your schema.rb files?

Thank you!

develaper commented 7 years ago

Hi! A few years later but I am having the same error. Just following the instruction in the read me (no changes in the migration) and I have this same result: `$ bundle exec rake db:migrate --trace Invoke db:migrate (first_time) Invoke environment (first_time) Execute environment Invoke db:load_config (first_time) Execute db:load_config Execute db:migrate == 20170522133701 CreateSurvey: migrating ===================================== -- create_table(:survey_surveys) -> 0.1217s -- create_table(:survey_questions) rake aborted! StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedTable: ERROR: relation "surveys" does not exist : CREATE TABLE "survey_questions" ("id" serial primary key, "survey_id" integer , "text" character varying , "created_at" timestamp , "updated_at" timestamp , CONSTRAINT fk_survey_questions_survey_id FOREIGN KEY ("survey_id") REFERENCES "surveys" ("id")) `

develaper commented 7 years ago

@alex-quiterio sorry for unassigning you. No idea of how i did it...