Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB Migration Error #26

Open
pvagare opened this issue May 15, 2015 · 3 comments
Open

DB Migration Error #26

pvagare opened this issue May 15, 2015 · 3 comments

Comments

@pvagare
Copy link

pvagare commented May 15, 2015

Hi ,

Please suggest the solution for Db migration error.

  • create_table(:survey_surveys)
    -> 0.0838s
    -- 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(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
Copy link
Contributor

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!

@alex-quiterio alex-quiterio self-assigned this Jul 22, 2015
@develaper
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants