dwyl / dwyl/github-backup

Add index + unique constraint on issue_id and comment_id

未关闭
#94 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
awaiting-review enhancement T25m
主要语言
Elixir
星标
33
派生
3
PR 合并指标
30 天内没有已合并 PR

描述

The current schemas for `issue` and `comment` don't have any unique constraint and index on `issue_id` and `comment_id` yet.
This can be useful to make sure the data inserted are correct and to avoid duplicates.
A duplicate values can appear for example if the app is uninstalled and reinstalled again. As we won't automatically delete data in Postgres (see #87) this means that on the install we will save again all the issues and comments (see #65)
After adding these indexes and constraints we will need to update the Repo.insert` function on new install to `Repo.insert_or_update`:
https://github.com/dwyl/github-backup/blob/2960a82e0f2d89853d86380db4e5841677bbdbf3/lib/app_web/controllers/event_type_handlers.ex#L69

see https://hexdocs.pm/ecto/Ecto.Repo.html#c:insert_or_update/2

贡献指南

这个仓库没有索引到贡献指南

调研方向

先从 issue 和 comment schema 开始,然后检查 lib/app_web/controllers/event_type_handlers.ex 第 69 行附近的代码以及 Ecto Repo.insert_or_update/2 文档。完成标准是 issue_id 和 comment_id 具有所要求的索引和唯一约束,并且新安装路径会更新现有记录,而不是插入重复记录。

由索引模型根据 Issue 内容生成。

评估

技术栈
elixir, postgresql
领域
backend, database
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。