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

Foregin Key Constraint problem while loading the data #145

Open
prp-e opened this issue Sep 13, 2023 · 0 comments
Open

Foregin Key Constraint problem while loading the data #145

prp-e opened this issue Sep 13, 2023 · 0 comments

Comments

@prp-e
Copy link

prp-e commented Sep 13, 2023

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.

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

1 participant