Skip to content

After migrating an external pg db, all my tests failed because of "PG::ForeignKeyViolation" #1

@juliepanda

Description

@juliepanda

I updated my app's db from sqlite to an external postgres already populated with tables. Now, when I run bundle exec rake test, I get this error on every test:

ActiveRecord::InvalidForeignKey:         ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR:  update or delete on table "lessons_lesson" violates foreign key constraint "lessons_word_lesson_id_567928f32e967ac_fk_lessons_lesson_id" on table "lessons_word"
        DETAIL:  Key (id)=(1) is still referenced from table "lessons_word".
        : DELETE FROM "lessons_lesson"

I couldn't fix this simply by updating all the models to the table_name they are interacting with...

establish_connection :developmenet
self.table_name = 'lessons_lesson'

I suspect this has something to do with postgres??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions