closeio / closeio/sync-engine

Investigate missing foreign keys on `messagecategory` table.

Open
#302 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
30
Forks
13
Avg merge
1d 2h
Merged PRs (30d)
8

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the schema or migration that creates the messagecategory table and inspect the related message and category tables. Determine whether the missing constraints are intentional and check existing tests or migration practices for relationship integrity. Done means the decision is documented and, if appropriate, the constraints are added without breaking existing data.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.