BLOG-95 Seperate SQL migration files #98

Merged
squid merged 2 commits from BLOG-95_rename_sql_migration_file into main 2025-08-01 15:02:30 +08:00
Owner

Description

  • In beta environment, v0.3.0 migration has been run, a manual revertion is required; in real environment, there is nothing to do, but to do #97 and remove migration record for v0.1.1 manually.

Package Changes

No response

Screenshots

No response

Reference

Resolves #95

Checklist

  • A milestone is set
  • The related issuse has been linked to this branch
### Description - In beta environment, `v0.3.0` migration has been run, a manual revertion is required; in real environment, there is nothing to do, but to do #97 and remove migration record for `v0.1.1` manually. ### Package Changes _No response_ ### Screenshots _No response_ ### Reference Resolves #95 ### Checklist - [x] A milestone is set - [x] The related issuse has been linked to this branch
squid added 1 commit 2025-08-01 14:57:26 +08:00
BLOG-95 refactor: seperate sql migration files
All checks were successful
Frontend CI / build (push) Successful in 1m9s
Auto Comment On PR / add_improve_comment (pull_request) Successful in 17s
PR Title Check / pr-title-check (pull_request) Successful in 16s
ded3d6c363
Collaborator

/improve

/improve
Collaborator

PR Code Suggestions

CategorySuggestion                                                                                                                                    Impact
Possible issue
Change email index type

Hash indexes in PostgreSQL have significant limitations, such as not supporting
range queries, LIKE operators, or ORDER BY clauses. For an email column, a B-tree
index is generally more versatile and performs better for common search patterns.
Consider changing the index type to B-tree for broader query support.

backend/migrations/20250801062412_create_user_table.sql [14-15]

 CREATE INDEX IF NOT EXISTS "idx_user_email"
-ON "user" USING HASH ("email");
+ON "user" ("email");
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that a HASH index on an email column has significant limitations in PostgreSQL. Changing it to a B-tree index would provide broader query support and better performance for common email search patterns.

High
General
Increase email column length

The email column is currently defined as VARCHAR(100). Some valid email addresses
can exceed this length, potentially leading to data truncation or insertion
failures. It is recommended to use a larger VARCHAR length (e.g., VARCHAR(255)) or
TEXT type to accommodate longer email addresses and prevent data loss.

backend/migrations/20250801062412_create_user_table.sql [6]

-"email" VARCHAR(100) NOT NULL,
+"email" VARCHAR(255) NOT NULL,
Suggestion importance[1-10]: 8

__

Why: The suggestion is accurate; VARCHAR(100) can be too short for some valid email addresses, potentially leading to data truncation. Increasing the length to VARCHAR(255) or using TEXT is a good practice to prevent data loss and ensure data integrity.

Medium
## PR Code Suggestions ✨ <!-- --> <table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>Possible issue</td> <td> <details><summary>Change email index type</summary> ___ **Hash indexes in PostgreSQL have significant limitations, such as not supporting <br>range queries, <code>LIKE</code> operators, or <code>ORDER BY</code> clauses. For an <code>email</code> column, a B-tree <br>index is generally more versatile and performs better for common search patterns. <br>Consider changing the index type to B-tree for broader query support.** [backend/migrations/20250801062412_create_user_table.sql [14-15]](https://git.squidspirit.com/squid/blog/src/branch/BLOG-95_rename_sql_migration_file/backend/migrations/20250801062412_create_user_table.sql#L14-L15) ```diff CREATE INDEX IF NOT EXISTS "idx_user_email" -ON "user" USING HASH ("email"); +ON "user" ("email"); ``` <details><summary>Suggestion importance[1-10]: 9</summary> __ Why: The suggestion correctly identifies that a `HASH` index on an `email` column has significant limitations in PostgreSQL. Changing it to a B-tree index would provide broader query support and better performance for common email search patterns. </details></details></td><td align=center>High </td></tr><tr><td rowspan=1>General</td> <td> <details><summary>Increase email column length</summary> ___ **The <code>email</code> column is currently defined as <code>VARCHAR(100)</code>. Some valid email addresses <br>can exceed this length, potentially leading to data truncation or insertion <br>failures. It is recommended to use a larger <code>VARCHAR</code> length (e.g., <code>VARCHAR(255)</code>) or <br><code>TEXT</code> type to accommodate longer email addresses and prevent data loss.** [backend/migrations/20250801062412_create_user_table.sql [6]](https://git.squidspirit.com/squid/blog/src/branch/BLOG-95_rename_sql_migration_file/backend/migrations/20250801062412_create_user_table.sql#L6-L6) ```diff -"email" VARCHAR(100) NOT NULL, +"email" VARCHAR(255) NOT NULL, ``` <details><summary>Suggestion importance[1-10]: 8</summary> __ Why: The suggestion is accurate; `VARCHAR(100)` can be too short for some valid email addresses, potentially leading to data truncation. Increasing the length to `VARCHAR(255)` or using `TEXT` is a good practice to prevent data loss and ensure data integrity. </details></details></td><td align=center>Medium </td></tr></tr></tbody></table>
squid changed title from BLOG-95 refactor: seperate sql migration files to BLOG-95 Seperate SQL migration files 2025-08-01 14:57:48 +08:00
squid added 1 commit 2025-08-01 15:00:03 +08:00
BLOG-95 fix: remove hash index
All checks were successful
Frontend CI / build (push) Successful in 1m8s
PR Title Check / pr-title-check (pull_request) Successful in 16s
8938bd3c61
Author
Owner

Hash indexes in PostgreSQL have significant limitations, such as not supporting
range queries, LIKE operators, or ORDER BY clauses. For an email column, a B-tree
index is generally more versatile and performs better for common search patterns.
Consider changing the index type to B-tree for broader query support.

backend/migrations/20250801062412_create_user_table.sql [14-15]

 CREATE INDEX IF NOT EXISTS "idx_user_email"
-ON "user" USING HASH ("email");
+ON "user" ("email");

Addressed in 8938bd3c61.

> **Hash indexes in PostgreSQL have significant limitations, such as not supporting <br>range queries, <code>LIKE</code> operators, or <code>ORDER BY</code> clauses. For an <code>email</code> column, a B-tree <br>index is generally more versatile and performs better for common search patterns. <br>Consider changing the index type to B-tree for broader query support.** > > [backend/migrations/20250801062412_create_user_table.sql [14-15]](https://git.squidspirit.com/squid/blog/src/branch/BLOG-95_rename_sql_migration_file/backend/migrations/20250801062412_create_user_table.sql#L14-L15) > > ```diff > CREATE INDEX IF NOT EXISTS "idx_user_email" > -ON "user" USING HASH ("email"); > +ON "user" ("email"); > ``` Addressed in 8938bd3c612b476cf0a4aba3aecbb09ee4e008d4.
Author
Owner

The email column is currently defined as VARCHAR(100). Some valid email addresses
can exceed this length, potentially leading to data truncation or insertion
failures. It is recommended to use a larger VARCHAR length (e.g., VARCHAR(255)) or
TEXT type to accommodate longer email addresses and prevent data loss.

backend/migrations/20250801062412_create_user_table.sql [6]

-"email" VARCHAR(100) NOT NULL,
+"email" VARCHAR(255) NOT NULL,

Ignore because such a long email is not common

> **The <code>email</code> column is currently defined as <code>VARCHAR(100)</code>. Some valid email addresses <br>can exceed this length, potentially leading to data truncation or insertion <br>failures. It is recommended to use a larger <code>VARCHAR</code> length (e.g., <code>VARCHAR(255)</code>) or <br><code>TEXT</code> type to accommodate longer email addresses and prevent data loss.** > > [backend/migrations/20250801062412_create_user_table.sql [6]](https://git.squidspirit.com/squid/blog/src/branch/BLOG-95_rename_sql_migration_file/backend/migrations/20250801062412_create_user_table.sql#L6-L6) > > ```diff > -"email" VARCHAR(100) NOT NULL, > +"email" VARCHAR(255) NOT NULL, > ``` Ignore because such a long email is not common
squid merged commit c6661f3222 into main 2025-08-01 15:02:30 +08:00
squid deleted branch BLOG-95_rename_sql_migration_file 2025-08-01 15:02:30 +08:00
Sign in to join this conversation.
No description provided.