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

Investigate missing foreign keys on messagecategory table. #302

Open
squeaky-pl opened this issue Dec 23, 2021 · 2 comments
Open

Investigate missing foreign keys on messagecategory table. #302

squeaky-pl opened this issue Dec 23, 2021 · 2 comments

Comments

@squeaky-pl
Copy link
Contributor

Currently the table looks like this:

CREATE TABLE `messagecategory` (
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `message_id` bigint(20) NOT NULL,
  `category_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `ix_messagecategory_category_id` (`category_id`),
  KEY `ix_messagecategory_created_at` (`created_at`),
  KEY `message_category_ids` (`message_id`,`category_id`)
);

Notice that there are no foreign key constraints on message_id and category_id columns. This can lead to to data corruption and exceptions on Python side. We should investigate if they were omitted on purpose. If not we should add them.

@squeaky-pl
Copy link
Contributor Author

It looks like they were dropped on purpose

text("ALTER TABLE messagecategory" " DROP FOREIGN KEY messagecategory_ibfk_1")

@squeaky-pl
Copy link
Contributor Author

The commit that deletes them is this one: ff8b0bd

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