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

Could not delete records from database directly #277

Open
johndark opened this issue Sep 1, 2016 · 1 comment
Open

Could not delete records from database directly #277

johndark opened this issue Sep 1, 2016 · 1 comment

Comments

@johndark
Copy link

johndark commented Sep 1, 2016

I need to clear pinax stripe tables directly in database, but got a dead-loop :)

Cannot truncate a table referenced in a foreign key constraint (pinax_stripe_invoice, CONSTRAINT pinax_stripe_invoic_charge_id_eb59524b_fk_pinax_stripe_charge_id FOREIGN KEY (charge_id) REFERENCES pinax_stripe_charge (id)

Cannot truncate a table referenced in a foreign key constraint (pinax_stripe_charge, CONSTRAINT pinax_stripe_char_invoice_id_bb6e58e0_fk_pinax_stripe_invoice_id FOREIGN KEY (invoice_id) REFERENCES pinax_stripe_invoice (id)

PS: Is it internal data protection algo? :)
Sure, I can drop constraints or set to NULL FKs and truncate these tables but it's not so funny.

@coler-j
Copy link

coler-j commented Feb 6, 2018

It is because the invoice table has a foreign key constraint to the charge table with the column charge_id (when the field is populated).

Just set the charge_id field to Null and update the table, then you should be able to delete data from both tables.

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

2 participants