feat(database): increase passwordHash length and add migration snapshot
- Extended `passwordHash` field length in `users` schema from 100 to 255. - Added migration snapshot for schema updates.
This commit is contained in:
@@ -21,14 +21,19 @@ const getPgpKey = () => process.env.PGP_ENCRYPTION_KEY || "default-pgp-key";
|
||||
* withAutomaticPgpDecrypt(users.email);
|
||||
* ```
|
||||
*/
|
||||
export const pgpEncrypted = customType<{ data: string; driverData: Buffer }>({
|
||||
export const pgpEncrypted = customType<{
|
||||
data: string | null;
|
||||
driverData: Buffer | string | null | SQL;
|
||||
}>({
|
||||
dataType() {
|
||||
return "bytea";
|
||||
},
|
||||
toDriver(value: string): SQL {
|
||||
toDriver(value: string | null): SQL | null {
|
||||
if (value === null) return null;
|
||||
return sql`pgp_sym_encrypt(${value}, ${getPgpKey()})`;
|
||||
},
|
||||
fromDriver(value: Buffer | string): string {
|
||||
fromDriver(value: Buffer | string | null | any): string | null {
|
||||
if (value === null || value === undefined) return null;
|
||||
if (typeof value === "string") return value;
|
||||
return value.toString();
|
||||
},
|
||||
|
||||
@@ -29,7 +29,7 @@ export const users = pgTable(
|
||||
displayName: varchar("display_name", { length: 32 }),
|
||||
|
||||
username: varchar("username", { length: 32 }).notNull().unique(),
|
||||
passwordHash: varchar("password_hash", { length: 100 }).notNull(),
|
||||
passwordHash: varchar("password_hash", { length: 255 }).notNull(),
|
||||
avatarUrl: varchar("avatar_url", { length: 512 }),
|
||||
bio: varchar("bio", { length: 255 }),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user