Skip to content

Foregin Key Constraint problem while loading the data #145

Open
@prp-e

Description

@prp-e

Greetings.
I'm using rails 7.0.4 and I accidentally removed my production sqlite3 file. Since I used yaml_db in order to keep a dump for my database, I reminded of the file and tried to recover it.
For some obvious reasons, we've decided to move our code base to postgresql and when I set everything up, it works fine. So, when I run rails db:data:load command, I get this error:

rails aborted!
ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR:  insert or update on table "credit_packs" violates foreign key constraint "fk_rails_21f35c4567"
DETAIL:  Key (user_id)=(1) is not present in table "users".


Caused by:
PG::ForeignKeyViolation: ERROR:  insert or update on table "credit_packs" violates foreign key constraint "fk_rails_21f35c4567"
DETAIL:  Key (user_id)=(1) is not present in table "users".

Tasks: TOP => db:data:load
(See full trace by running task with --trace)

What should I do now?

Explanation about the credit_pack model : It's something which every user has. So I don't know why this dataloader thingy tries to first create them then users.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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