This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
9,112 additions
and
149 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -38,3 +38,6 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
# ignore mongoexport old db file | ||
db.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { PrismaClient } from '../db/clients/account' | ||
import { FileHandle, open } from 'node:fs/promises' | ||
import path from 'path' | ||
|
||
const client = new PrismaClient() | ||
const testLimit = 0 | ||
|
||
async function main() { | ||
let file: FileHandle | undefined | ||
try { | ||
file = await open(path.join(__dirname, '../../', 'db.json')) | ||
} catch (e) { | ||
console.log('Error opening file') | ||
console.error(e) | ||
} | ||
if (!file) return | ||
|
||
let connected = false | ||
while (!connected) { | ||
console.log('Connecting to db..') | ||
try { | ||
await client.$connect() | ||
connected = true | ||
} catch (e) { | ||
console.log('Error connecting to db. Retrying in 5 secs..') | ||
await new Promise((resolve) => setTimeout(resolve, 5000)) | ||
} | ||
} | ||
|
||
let i = 0 | ||
let accounts = [] | ||
console.log('Importing accounts from db.json file..') | ||
for await (const line of file.readLines()) { | ||
i++ | ||
const accountImport = JSON.parse(line) | ||
const interested = accountImport.appState.sessions.filter((s: any) => s.level === 'interested').map((i: any) => i.id) | ||
const attending = accountImport.appState.sessions.filter((s: any) => s.level === 'attending').map((i: any) => i.id) | ||
|
||
accounts.push({ | ||
username: accountImport.username, | ||
email: accountImport.email, | ||
addresses: accountImport.addresses ?? [], | ||
disabled: accountImport.disabled ?? false, | ||
|
||
favorite_speakers: accountImport.appState.speakers, | ||
interested_sessions: [], | ||
attending_sessions: [], | ||
publicSchedule: accountImport.appState.publicSchedule, | ||
notifications: false, | ||
appState_bogota: JSON.stringify({ interested, attending }), | ||
|
||
createdAt: new Date(accountImport.createdAt['$date']), | ||
updatedAt: accountImport.updatedAt ? new Date(accountImport.updatedAt['$date']) : new Date(), | ||
}) | ||
|
||
if (testLimit > 0 && i >= testLimit) break | ||
} | ||
|
||
console.log(`Importing ${i} accounts..`) | ||
const result = await client.account.createMany({ | ||
data: accounts, | ||
}) | ||
console.log(`Imported ${result.count} accounts.`) | ||
console.log('Done!') | ||
} | ||
|
||
main() | ||
.then(async () => { | ||
await client.$disconnect() | ||
}) | ||
.catch(async (e) => { | ||
console.error(e) | ||
await client.$disconnect() | ||
process.exit(1) | ||
}) |
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,35 @@ | ||
datasource db { | ||
provider = "postgres" | ||
url = env("DB_CONNECTION_STRING") | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
output = "./clients/account" | ||
} | ||
|
||
model VerificationToken { | ||
id String @default(cuid()) @id | ||
identifier String | ||
nonce Int | ||
issued DateTime @default(now()) | ||
expires DateTime | ||
} | ||
|
||
model Account { | ||
id String @default(cuid()) @id | ||
username String? | ||
email String? | ||
addresses String[] | ||
disabled Boolean @default(false) | ||
favorite_speakers String[] | ||
interested_sessions String[] | ||
attending_sessions String[] | ||
publicSchedule Boolean @default(false) | ||
notifications Boolean @default(false) | ||
appState_bogota String? | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime? | ||
} |
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 @@ | ||
export * from './index' |
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 @@ | ||
module.exports = { ...require('.') } |
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 @@ | ||
export * from './default' |
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,203 @@ | ||
|
||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
|
||
const { | ||
PrismaClientKnownRequestError, | ||
PrismaClientUnknownRequestError, | ||
PrismaClientRustPanicError, | ||
PrismaClientInitializationError, | ||
PrismaClientValidationError, | ||
NotFoundError, | ||
getPrismaClient, | ||
sqltag, | ||
empty, | ||
join, | ||
raw, | ||
Decimal, | ||
Debug, | ||
objectEnumValues, | ||
makeStrictEnum, | ||
Extensions, | ||
warnOnce, | ||
defineDmmfProperty, | ||
Public, | ||
getRuntime | ||
} = require('./runtime/edge.js') | ||
|
||
|
||
const Prisma = {} | ||
|
||
exports.Prisma = Prisma | ||
exports.$Enums = {} | ||
|
||
/** | ||
* Prisma Client JS version: 5.11.0 | ||
* Query Engine version: efd2449663b3d73d637ea1fd226bafbcf45b3102 | ||
*/ | ||
Prisma.prismaVersion = { | ||
client: "5.11.0", | ||
engine: "efd2449663b3d73d637ea1fd226bafbcf45b3102" | ||
} | ||
|
||
Prisma.PrismaClientKnownRequestError = PrismaClientKnownRequestError; | ||
Prisma.PrismaClientUnknownRequestError = PrismaClientUnknownRequestError | ||
Prisma.PrismaClientRustPanicError = PrismaClientRustPanicError | ||
Prisma.PrismaClientInitializationError = PrismaClientInitializationError | ||
Prisma.PrismaClientValidationError = PrismaClientValidationError | ||
Prisma.NotFoundError = NotFoundError | ||
Prisma.Decimal = Decimal | ||
|
||
/** | ||
* Re-export of sql-template-tag | ||
*/ | ||
Prisma.sql = sqltag | ||
Prisma.empty = empty | ||
Prisma.join = join | ||
Prisma.raw = raw | ||
Prisma.validator = Public.validator | ||
|
||
/** | ||
* Extensions | ||
*/ | ||
Prisma.getExtensionContext = Extensions.getExtensionContext | ||
Prisma.defineExtension = Extensions.defineExtension | ||
|
||
/** | ||
* Shorthand utilities for JSON filtering | ||
*/ | ||
Prisma.DbNull = objectEnumValues.instances.DbNull | ||
Prisma.JsonNull = objectEnumValues.instances.JsonNull | ||
Prisma.AnyNull = objectEnumValues.instances.AnyNull | ||
|
||
Prisma.NullTypes = { | ||
DbNull: objectEnumValues.classes.DbNull, | ||
JsonNull: objectEnumValues.classes.JsonNull, | ||
AnyNull: objectEnumValues.classes.AnyNull | ||
} | ||
|
||
|
||
|
||
/** | ||
* Enums | ||
*/ | ||
exports.Prisma.TransactionIsolationLevel = makeStrictEnum({ | ||
ReadUncommitted: 'ReadUncommitted', | ||
ReadCommitted: 'ReadCommitted', | ||
RepeatableRead: 'RepeatableRead', | ||
Serializable: 'Serializable' | ||
}); | ||
|
||
exports.Prisma.VerificationTokenScalarFieldEnum = { | ||
id: 'id', | ||
identifier: 'identifier', | ||
nonce: 'nonce', | ||
issued: 'issued', | ||
expires: 'expires' | ||
}; | ||
|
||
exports.Prisma.AccountScalarFieldEnum = { | ||
id: 'id', | ||
username: 'username', | ||
email: 'email', | ||
addresses: 'addresses', | ||
disabled: 'disabled', | ||
favorite_speakers: 'favorite_speakers', | ||
interested_sessions: 'interested_sessions', | ||
attending_sessions: 'attending_sessions', | ||
publicSchedule: 'publicSchedule', | ||
notifications: 'notifications', | ||
appState_bogota: 'appState_bogota', | ||
createdAt: 'createdAt', | ||
updatedAt: 'updatedAt' | ||
}; | ||
|
||
exports.Prisma.SortOrder = { | ||
asc: 'asc', | ||
desc: 'desc' | ||
}; | ||
|
||
exports.Prisma.QueryMode = { | ||
default: 'default', | ||
insensitive: 'insensitive' | ||
}; | ||
|
||
exports.Prisma.NullsOrder = { | ||
first: 'first', | ||
last: 'last' | ||
}; | ||
|
||
|
||
exports.Prisma.ModelName = { | ||
VerificationToken: 'VerificationToken', | ||
Account: 'Account' | ||
}; | ||
/** | ||
* Create the Client | ||
*/ | ||
const config = { | ||
"generator": { | ||
"name": "client", | ||
"provider": { | ||
"fromEnvVar": null, | ||
"value": "prisma-client-js" | ||
}, | ||
"output": { | ||
"value": "/home/w/Code/devcon-api/src/db/clients/account", | ||
"fromEnvVar": null | ||
}, | ||
"config": { | ||
"engineType": "library" | ||
}, | ||
"binaryTargets": [ | ||
{ | ||
"fromEnvVar": null, | ||
"value": "debian-openssl-3.0.x", | ||
"native": true | ||
} | ||
], | ||
"previewFeatures": [], | ||
"isCustomOutput": true | ||
}, | ||
"relativeEnvPaths": { | ||
"rootEnvPath": null, | ||
"schemaEnvPath": "../../../../.env" | ||
}, | ||
"relativePath": "../..", | ||
"clientVersion": "5.11.0", | ||
"engineVersion": "efd2449663b3d73d637ea1fd226bafbcf45b3102", | ||
"datasourceNames": [ | ||
"db" | ||
], | ||
"activeProvider": "postgresql", | ||
"inlineDatasources": { | ||
"db": { | ||
"url": { | ||
"fromEnvVar": "DB_CONNECTION_STRING", | ||
"value": null | ||
} | ||
} | ||
}, | ||
"inlineSchema": "datasource db {\n provider = \"postgres\"\n url = env(\"DB_CONNECTION_STRING\")\n}\n\ngenerator client {\n provider = \"prisma-client-js\"\n output = \"./clients/account\"\n}\n\nmodel VerificationToken {\n id String @default(cuid()) @id\n identifier String\n nonce Int\n issued DateTime @default(now())\n expires DateTime\n}\n\nmodel Account {\n id String @default(cuid()) @id\n username String?\n email String?\n addresses String[]\n disabled Boolean @default(false)\n \n favorite_speakers String[]\n interested_sessions String[]\n attending_sessions String[]\n publicSchedule Boolean @default(false)\n notifications Boolean @default(false)\n appState_bogota String?\n\n createdAt DateTime @default(now())\n updatedAt DateTime?\n}\n", | ||
"inlineSchemaHash": "f9a95bb20669ea54b0f8ea74f6b4e960b17382b534f52d8d04a619060eb53a42", | ||
"copyEngine": true | ||
} | ||
config.dirname = '/' | ||
|
||
config.runtimeDataModel = JSON.parse("{\"models\":{\"VerificationToken\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"default\":{\"name\":\"cuid\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"identifier\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"nonce\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"issued\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"expires\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":false}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"Account\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"default\":{\"name\":\"cuid\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"username\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"email\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"addresses\",\"kind\":\"scalar\",\"isList\":true,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"disabled\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"default\":false,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"favorite_speakers\",\"kind\":\"scalar\",\"isList\":true,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"interested_sessions\",\"kind\":\"scalar\",\"isList\":true,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"attending_sessions\",\"kind\":\"scalar\",\"isList\":true,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"publicSchedule\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"default\":false,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"notifications\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"default\":false,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"appState_bogota\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":false}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false}},\"enums\":{},\"types\":{}}") | ||
defineDmmfProperty(exports.Prisma, config.runtimeDataModel) | ||
config.engineWasm = undefined | ||
|
||
config.injectableEdgeEnv = () => ({ | ||
parsed: { | ||
DB_CONNECTION_STRING: typeof globalThis !== 'undefined' && globalThis['DB_CONNECTION_STRING'] || typeof process !== 'undefined' && process.env && process.env.DB_CONNECTION_STRING || undefined | ||
} | ||
}) | ||
|
||
if (typeof globalThis !== 'undefined' && globalThis['DEBUG'] || typeof process !== 'undefined' && process.env && process.env.DEBUG || undefined) { | ||
Debug.enable(typeof globalThis !== 'undefined' && globalThis['DEBUG'] || typeof process !== 'undefined' && process.env && process.env.DEBUG || undefined) | ||
} | ||
|
||
const PrismaClient = getPrismaClient(config) | ||
exports.PrismaClient = PrismaClient | ||
Object.assign(exports, Prisma) | ||
|
Oops, something went wrong.