-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matt Krick <[email protected]>
- Loading branch information
Showing
8 changed files
with
88 additions
and
169 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
31 changes: 0 additions & 31 deletions
31
packages/server/postgres/migrations/1709351538000_addEmailVerification.ts
This file was deleted.
Oops, something went wrong.
76 changes: 0 additions & 76 deletions
76
packages/server/postgres/migrations/1709351575000_moveEmailVerification.ts
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
packages/server/postgres/migrations/1721868364099_addEmailVerification.ts
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,52 @@ | ||
import {Kysely, PostgresDialect, sql} from 'kysely' | ||
import {Client} from 'pg' | ||
import {r} from 'rethinkdb-ts' | ||
import connectRethinkDB from '../../database/connectRethinkDB' | ||
import getPg from '../getPg' | ||
import getPgConfig from '../getPgConfig' | ||
|
||
export async function up() { | ||
await connectRethinkDB() | ||
const pg = new Kysely<any>({ | ||
dialect: new PostgresDialect({ | ||
pool: getPg() | ||
}) | ||
}) | ||
await sql` | ||
CREATE TABLE "EmailVerification" ( | ||
"id" INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | ||
"email" "citext" NOT NULL, | ||
"expiration" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
"token" VARCHAR(100) NOT NULL, | ||
"hashedPassword" VARCHAR(100), | ||
"invitationToken" VARCHAR(100), | ||
"pseudoId" VARCHAR(100) | ||
); | ||
CREATE INDEX IF NOT EXISTS "idx_EmailVerification_email" ON "EmailVerification"("email"); | ||
CREATE INDEX IF NOT EXISTS "idx_EmailVerification_token" ON "EmailVerification"("token"); | ||
`.execute(pg) | ||
|
||
const rData = await r.table('EmailVerification').coerceTo('array').run() | ||
const insertData = rData.map((row) => { | ||
const {email, expiration, hashedPassword, token, invitationToken, pseudoId} = row | ||
return { | ||
email, | ||
expiration, | ||
hashedPassword, | ||
token, | ||
invitationToken, | ||
pseudoId | ||
} | ||
}) | ||
await pg.insertInto('EmailVerification').values(insertData).execute() | ||
} | ||
|
||
export async function down() { | ||
const client = new Client(getPgConfig()) | ||
await client.connect() | ||
await client.query(` | ||
DROP TABLE IF EXISTS "EmailVerification"; | ||
`) | ||
await client.end() | ||
} |