Skip to content

Commit

Permalink
Add hashedPassword and make email unique (#97)
Browse files Browse the repository at this point in the history
* Add hashedPassword and make email unique

* Generate migrations
  • Loading branch information
mauriciabad authored Oct 22, 2023
1 parent 0b801b4 commit 94a55f6
Show file tree
Hide file tree
Showing 4 changed files with 294 additions and 7 deletions.
4 changes: 4 additions & 0 deletions drizzle/0001_friendly_yellowjacket.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE `account` MODIFY COLUMN `refresh_token` text;--> statement-breakpoint
ALTER TABLE `account` MODIFY COLUMN `access_token` text;--> statement-breakpoint
ALTER TABLE `user` ADD `hashedPassword` varchar(255);--> statement-breakpoint
ALTER TABLE `user` ADD CONSTRAINT `user_email_unique` UNIQUE(`email`);
279 changes: 279 additions & 0 deletions drizzle/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
{
"version": "5",
"dialect": "mysql",
"id": "60e6bc97-3429-4396-b81c-d597457d90a7",
"prevId": "7ed78391-6147-422a-aabe-4142c0e039c0",
"tables": {
"place": {
"name": "place",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": false,
"notNull": true,
"autoincrement": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"place_id": {
"name": "place_id",
"columns": [
"id"
]
}
},
"uniqueConstraints": {}
},
"account": {
"name": "account",
"columns": {
"userId": {
"name": "userId",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"providerAccountId": {
"name": "providerAccountId",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "int",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"session_state": {
"name": "session_state",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"account_provider_providerAccountId": {
"name": "account_provider_providerAccountId",
"columns": [
"provider",
"providerAccountId"
]
}
},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"session_sessionToken": {
"name": "session_sessionToken",
"columns": [
"sessionToken"
]
}
},
"uniqueConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"hashedPassword": {
"name": "hashedPassword",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"email": {
"name": "email",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "timestamp(3)",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "(now())"
},
"image": {
"name": "image",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"user_id": {
"name": "user_id",
"columns": [
"id"
]
}
},
"uniqueConstraints": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
]
}
}
},
"verificationToken": {
"name": "verificationToken",
"columns": {
"identifier": {
"name": "identifier",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token": {
"name": "verificationToken_identifier_token",
"columns": [
"identifier",
"token"
]
}
},
"uniqueConstraints": {}
}
},
"schemas": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
}
7 changes: 7 additions & 0 deletions drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
"when": 1697892204087,
"tag": "0000_mute_harrier",
"breakpoints": true
},
{
"idx": 1,
"version": "5",
"when": 1697998014565,
"tag": "0001_friendly_yellowjacket",
"breakpoints": true
}
]
}
11 changes: 4 additions & 7 deletions src/server/db/schema/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ import {
varchar,
} from 'drizzle-orm/mysql-core'

/*
* NextAuth tables, see https://authjs.dev/reference/adapter/drizzle
*/

export const users = mysqlTable('user', {
id: varchar('id', { length: 255 }).notNull().primaryKey(),
name: varchar('name', { length: 255 }),
email: varchar('email', { length: 255 }).notNull(),
hashedPassword: varchar('hashedPassword', { length: 255 }),
email: varchar('email', { length: 255 }).unique().notNull(),
emailVerified: timestamp('emailVerified', {
mode: 'date',
fsp: 3,
Expand All @@ -33,8 +30,8 @@ export const accounts = mysqlTable(
.notNull(),
provider: varchar('provider', { length: 255 }).notNull(),
providerAccountId: varchar('providerAccountId', { length: 255 }).notNull(),
refresh_token: varchar('refresh_token', { length: 255 }),
access_token: varchar('access_token', { length: 255 }),
refresh_token: text('refresh_token'),
access_token: text('access_token'),
expires_at: int('expires_at'),
token_type: varchar('token_type', { length: 255 }),
scope: varchar('scope', { length: 255 }),
Expand Down

0 comments on commit 94a55f6

Please sign in to comment.