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

Cannot add foreign key constraint mysql/mysql #318

Open
huxiangquan opened this issue Feb 12, 2025 · 0 comments
Open

Cannot add foreign key constraint mysql/mysql #318

huxiangquan opened this issue Feb 12, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@huxiangquan
Copy link

2025-02-12T14:02:05.203686664+08:00 INFO default_logger - ddl begin: ALTER TABLE abplearn.sale_return_line_item ADD CONSTRAINT fk_srli_tran_id FOREIGN KEY (tran_id) REFERENCES abplearn.sale_transaction(tran_id)

2025-02-12T14:02:05.207894311+08:00 ERROR default_logger - ddl failed, error: sqlx error: error returned from database: 1215 (HY000): Cannot add foreign key constraint

2025-02-12T14:02:05.217009030+08:00 ERROR default_logger - panic: panicked at /project/dt-task/src/task_runner.rs:326:36:
called Result::unwrap() on an Err value: sqlx error: error returned from database: 1215 (HY000): Cannot add foreign key constraint

When attempting to create a foreign key on the sale_return_line_item table, an error occurred because the sale_transaction table had not yet been created. Could the tables be created in the order of their foreign key dependencies to avoid this issue?

@huxiangquan huxiangquan added the bug Something isn't working label Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant