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

[+] Maimai2 unique constraints #98

Open
wants to merge 2 commits into
base: v1-dev
Choose a base branch
from
Open

[+] Maimai2 unique constraints #98

wants to merge 2 commits into from

Conversation

hykilpikonna
Copy link
Collaborator

@hykilpikonna hykilpikonna commented Jan 3, 2025

Summary by Sourcery

日常维护:

  • 从各个 Maimai2 用户表中删除重复数据。
Original summary in English

Summary by Sourcery

Chores:

  • Remove duplicate data from various Maimai2 user tables.

Copy link
Contributor

sourcery-ai bot commented Jan 3, 2025

Here's the translation to Chinese:

审阅者指南 by Sourcery

此拉取请求为 maimai2 表添加唯一约束,以防止重复行。它还删除了现有的重复行,以确保数据完整性。

Maimai2 表的实体关系图(带唯一约束)

erDiagram
    maimai2_user_extend ||--|| user : "unique_user_extend"
    maimai2_user_option ||--|| user : "unique_user_option"
    maimai2_user_character }|--|| user : "unique_user_character"
    maimai2_user_character }|--|| character : "unique_user_character"
    maimai2_user_map }|--|| user : "unique_user_map"
    maimai2_user_map }|--|| map : "unique_user_map"
    maimai2_user_login_bonus }|--|| user : "unique_user_login_bonus"
    maimai2_user_login_bonus }|--|| bonus : "unique_user_login_bonus"
    maimai2_user_udemae ||--|| user : "unique_user_udemae"
    maimai2_user_general_data }|--|| user : "unique_user_general_data"
    maimai2_user_item }|--|| user : "unique_user_item"
    maimai2_user_music_detail }|--|| user : "unique_user_music_detail"
    maimai2_user_course }|--|| user : "unique_user_course"
    maimai2_user_friend_season_ranking }|--|| user : "unique_user_friend_season_ranking"
    maimai2_user_favorite }|--|| user : "unique_user_favorite"
    maimai2_user_activity }|--|| user : "unique_user_activity"

    maimai2_user_extend {
        int user_id PK, UK
    }
    maimai2_user_option {
        int user_id PK, UK
    }
    maimai2_user_character {
        int user_id PK, UK
        int character_id PK, UK
    }
    maimai2_user_map {
        int user_id PK, UK
        int map_id PK, UK
    }
    maimai2_user_login_bonus {
        int user_id PK, UK
        int bonus_id PK, UK
    }
    maimai2_user_udemae {
        int user_id PK, UK
    }
    maimai2_user_general_data {
        int user_id PK, UK
        string property_key PK, UK
    }
    maimai2_user_item {
        int user_id PK, UK
        int item_id PK, UK
        int item_kind PK, UK
    }
    maimai2_user_music_detail {
        int user_id PK, UK
        int music_id PK, UK
        int level PK, UK
    }
    maimai2_user_course {
        int user_id PK, UK
        int course_id PK, UK
    }
    maimai2_user_friend_season_ranking {
        int user_id PK, UK
        int season_id PK, UK
    }
    maimai2_user_favorite {
        int user_id PK, UK
        int item_kind PK, UK
    }
    maimai2_user_activity {
        int user_id PK, UK
        int activity_id PK, UK
        int kind PK, UK
    }
Loading

文件级更改

更改 详情 文件
删除重复行
  • 根据 user_id 删除 mai2_user_extend 表中的重复行。
  • 根据 user_id 删除 mai2_user_option 表中的重复行。
  • 根据 user_idcharacter_id 删除 mai2_user_character 表中的重复行。
  • 根据 user_idmap_id 删除 mai2_user_map 表中的重复行。
  • 根据 user_idbonus_id 删除 mai2_user_login_bonus 表中的重复行。
  • 根据 user_id 删除 mai2_user_udemae 表中的重复行。
  • 根据 user_idproperty_key 删除 mai2_user_general_data 表中的重复行。
  • 根据 user_iditem_iditem_kind 删除 mai2_user_item 表中的重复行。
  • 根据 user_idmusic_idlevel 删除 mai2_user_music_detail 表中的重复行。
  • 根据 user_idcourse_id 删除 mai2_user_course 表中的重复行。
  • 根据 user_idseason_id 删除 mai2_user_friend_season_ranking 表中的重复行。
  • 根据 user_iditem_kind 删除 mai2_user_favorite 表中的重复行。
  • 根据 user_idactivity_idkind 删除 mai2_user_activity 表中的重复行。
src/main/resources/db/migration/mariadb/V1000_25__mai2_unique.sql
添加唯一约束
  • mai2_user_extend 表的 user_id 列上添加唯一约束。
  • mai2_user_option 表的 user_id 列上添加唯一约束。
  • mai2_user_character 表的 user_idcharacter_id 列上添加唯一约束。
  • mai2_user_map 表的 user_idmap_id 列上添加唯一约束。
  • mai2_user_login_bonus 表的 user_idbonus_id 列上添加唯一约束。
  • mai2_user_udemae 表的 user_id 列上添加唯一约束。
  • mai2_user_general_data 表的 user_idproperty_key 列上添加唯一约束。
  • mai2_user_item 表的 user_iditem_iditem_kind 列上添加唯一约束。
  • mai2_user_music_detail 表的 user_idmusic_idlevel 列上添加唯一约束。
  • mai2_user_course 表的 user_idcourse_id 列上添加唯一约束。
  • mai2_user_friend_season_ranking 表的 user_idseason_id 列上添加唯一约束。
  • mai2_user_favorite 表的 user_iditem_kind 列上添加唯一约束。
  • mai2_user_activity 表的 user_idactivity_idkind 列上添加唯一约束。
src/main/resources/db/migration/mariadb/V1000_25__mai2_unique.sql

提示和命令

与 Sourcery 交互

  • **触发新的审阅:**在拉取请求中评论 @sourcery-ai review
  • **继续讨论:**直接回复 Sourcery 的审阅评论。
  • **从审阅评论生成 GitHub 问题:**通过回复审阅评论来要求 Sourcery 创建问题。
  • **生成拉取请求标题:**在拉取请求标题的任何位置写 @sourcery-ai 以随时生成标题。
  • **生成拉取请求摘要:**在拉取请求正文的任何位置写 @sourcery-ai summary 以随时生成 PR 摘要。您还可以使用此命令指定摘要的插入位置。

自定义您的体验

访问您的仪表板以:

  • 启用或禁用审阅功能,如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、删除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English

Reviewer's Guide by Sourcery

This pull request adds unique constraints to the maimai2 tables to prevent duplicate rows. It also deletes existing duplicate rows to ensure data integrity before applying the constraints.

Entity Relationship diagram for Maimai2 tables with unique constraints

erDiagram
    maimai2_user_extend ||--|| user : "unique_user_extend"
    maimai2_user_option ||--|| user : "unique_user_option"
    maimai2_user_character }|--|| user : "unique_user_character"
    maimai2_user_character }|--|| character : "unique_user_character"
    maimai2_user_map }|--|| user : "unique_user_map"
    maimai2_user_map }|--|| map : "unique_user_map"
    maimai2_user_login_bonus }|--|| user : "unique_user_login_bonus"
    maimai2_user_login_bonus }|--|| bonus : "unique_user_login_bonus"
    maimai2_user_udemae ||--|| user : "unique_user_udemae"
    maimai2_user_general_data }|--|| user : "unique_user_general_data"
    maimai2_user_item }|--|| user : "unique_user_item"
    maimai2_user_music_detail }|--|| user : "unique_user_music_detail"
    maimai2_user_course }|--|| user : "unique_user_course"
    maimai2_user_friend_season_ranking }|--|| user : "unique_user_friend_season_ranking"
    maimai2_user_favorite }|--|| user : "unique_user_favorite"
    maimai2_user_activity }|--|| user : "unique_user_activity"

    maimai2_user_extend {
        int user_id PK, UK
    }
    maimai2_user_option {
        int user_id PK, UK
    }
    maimai2_user_character {
        int user_id PK, UK
        int character_id PK, UK
    }
    maimai2_user_map {
        int user_id PK, UK
        int map_id PK, UK
    }
    maimai2_user_login_bonus {
        int user_id PK, UK
        int bonus_id PK, UK
    }
    maimai2_user_udemae {
        int user_id PK, UK
    }
    maimai2_user_general_data {
        int user_id PK, UK
        string property_key PK, UK
    }
    maimai2_user_item {
        int user_id PK, UK
        int item_id PK, UK
        int item_kind PK, UK
    }
    maimai2_user_music_detail {
        int user_id PK, UK
        int music_id PK, UK
        int level PK, UK
    }
    maimai2_user_course {
        int user_id PK, UK
        int course_id PK, UK
    }
    maimai2_user_friend_season_ranking {
        int user_id PK, UK
        int season_id PK, UK
    }
    maimai2_user_favorite {
        int user_id PK, UK
        int item_kind PK, UK
    }
    maimai2_user_activity {
        int user_id PK, UK
        int activity_id PK, UK
        int kind PK, UK
    }
Loading

File-Level Changes

Change Details Files
Delete duplicate rows
  • Deleted duplicate rows from mai2_user_extend table based on user_id.
  • Deleted duplicate rows from mai2_user_option table based on user_id.
  • Deleted duplicate rows from mai2_user_character table based on user_id and character_id.
  • Deleted duplicate rows from mai2_user_map table based on user_id and map_id.
  • Deleted duplicate rows from mai2_user_login_bonus table based on user_id and bonus_id.
  • Deleted duplicate rows from mai2_user_udemae table based on user_id.
  • Deleted duplicate rows from mai2_user_general_data table based on user_id and property_key.
  • Deleted duplicate rows from mai2_user_item table based on user_id, item_id, and item_kind.
  • Deleted duplicate rows from mai2_user_music_detail table based on user_id, music_id, and level.
  • Deleted duplicate rows from mai2_user_course table based on user_id and course_id.
  • Deleted duplicate rows from mai2_user_friend_season_ranking table based on user_id and season_id.
  • Deleted duplicate rows from mai2_user_favorite table based on user_id and item_kind.
  • Deleted duplicate rows from mai2_user_activity table based on user_id, activity_id, and kind.
src/main/resources/db/migration/mariadb/V1000_25__mai2_unique.sql
Add unique constraints
  • Added a unique constraint to the mai2_user_extend table on the user_id column.
  • Added a unique constraint to the mai2_user_option table on the user_id column.
  • Added a unique constraint to the mai2_user_character table on the user_id and character_id columns.
  • Added a unique constraint to the mai2_user_map table on the user_id and map_id columns.
  • Added a unique constraint to the mai2_user_login_bonus table on the user_id and bonus_id columns.
  • Added a unique constraint to the mai2_user_udemae table on the user_id column.
  • Added a unique constraint to the mai2_user_general_data table on the user_id and property_key columns.
  • Added a unique constraint to the mai2_user_item table on the user_id, item_id, and item_kind columns.
  • Added a unique constraint to the mai2_user_music_detail table on the user_id, music_id, and level columns.
  • Added a unique constraint to the mai2_user_course table on the user_id and course_id columns.
  • Added a unique constraint to the mai2_user_friend_season_ranking table on the user_id and season_id columns.
  • Added a unique constraint to the mai2_user_favorite table on the user_id and item_kind columns.
  • Added a unique constraint to the mai2_user_activity table on the user_id, activity_id, and kind columns.
src/main/resources/db/migration/mariadb/V1000_25__mai2_unique.sql

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hykilpikonna - 我已经审查了你的更改 - 以下是一些反馈:

整体评论

  • 在运行这些删除操作之前,请考虑备份数据库,因为这些操作将永久删除重复数据。
以下是我在审查期间查看的内容
  • 🟢 一般问题:一切看起来都很好
  • 🟢 安全性:一切看起来都很好
  • 🟢 测试:一切看起来都很好
  • 🟢 复杂性:一切看起来都很好
  • 🟢 文档:一切看起来都很好

Sourcery 对开源项目是免费的 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English

Hey @hykilpikonna - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider taking a database backup before running these delete operations, as they will permanently remove duplicate data.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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

Successfully merging this pull request may close these issues.

1 participant