-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Enforce case-insensitive username uniqueness (#557)
* add migration for case insensitive username * fix form validation
- Loading branch information
1 parent
f32244d
commit 1331426
Showing
3 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
core/prisma/migrations/20250108021921_case_insensitive_usernames/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- RedefineTables | ||
PRAGMA foreign_keys=OFF; | ||
CREATE TABLE "new_users" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"username" TEXT NOT NULL COLLATE NOCASE, | ||
"hashed_password" TEXT NOT NULL, | ||
"is_server_owner" BOOLEAN NOT NULL DEFAULT false, | ||
"avatar_url" TEXT, | ||
"last_login" DATETIME, | ||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"deleted_at" DATETIME, | ||
"is_locked" BOOLEAN NOT NULL DEFAULT false, | ||
"max_sessions_allowed" INTEGER, | ||
"permissions" TEXT, | ||
"user_preferences_id" TEXT, | ||
CONSTRAINT "users_user_preferences_id_fkey" FOREIGN KEY ("user_preferences_id") REFERENCES "user_preferences" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
INSERT INTO "new_users" ("avatar_url", "created_at", "deleted_at", "hashed_password", "id", "is_locked", "is_server_owner", "last_login", "max_sessions_allowed", "permissions", "user_preferences_id", "username") SELECT "avatar_url", "created_at", "deleted_at", "hashed_password", "id", "is_locked", "is_server_owner", "last_login", "max_sessions_allowed", "permissions", "user_preferences_id", "username" FROM "users"; | ||
DROP TABLE "users"; | ||
ALTER TABLE "new_users" RENAME TO "users"; | ||
CREATE UNIQUE INDEX "users_username_key" ON "users"("username"); | ||
CREATE UNIQUE INDEX "users_user_preferences_id_key" ON "users"("user_preferences_id"); | ||
PRAGMA foreign_key_check; | ||
PRAGMA foreign_keys=ON; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters