ArtimusMaximus / NUA

GNU General Public License v3.0
3 stars 1 forks source link

Prisma error on brand new install #43

Closed JoeWalters closed 5 months ago

JoeWalters commented 5 months ago

Invalid `prisma.credentials.findMany()` invocation in
/home/jwalters/nodeunifireact/server/app.js:45:55

  42 const fetchLoginInfo = async () => {
  43     const getAdminLoginInfo = async () => {
  44         try {
→ 45           const adminLogin = await prisma.credentials.findMany(
The table `main.Credentials` does not exist in the current database.
    at si.handleRequestError (/home/jwalters/nodeunifireact/server/node_modules/@prisma/client/runtime/library.js:125:6817)
    at si.handleAndLogRequestError (/home/jwalters/nodeunifireact/server/node_modules/@prisma/client/runtime/library.js:125:6151)
    at si.request (/home/jwalters/nodeunifireact/server/node_modules/@prisma/client/runtime/library.js:125:5859)
    at async l (/home/jwalters/nodeunifireact/server/node_modules/@prisma/client/runtime/library.js:130:10025)
    at async getAdminLoginInfo (/home/jwalters/nodeunifireact/server/app.js:45:30) {
  code: 'P2021',
  clientVersion: '5.7.0',
  meta: { modelName: 'Credentials', table: 'main.Credentials' }
}

Node.js v18.18.1
[nodemon] app crashed - waiting for file changes before starting...```
ArtimusMaximus commented 5 months ago

I will get this fixed most likely tomorrow 1/19. I cloned repo to test on my system. With prisma we need to 'generate' the db and then migrate the schema to the db. Two separate commands to apply in the cli (in server folder): npx prisma generate npx prisma migrate dev (migrate deploy is recommended for CI/CD, 'dev' should satisfy the needs of running locally) in addition, naturally our main page AdminConsole calls a useEffect() that fetches the unifi login information. I will add error handling to the server to not crash when there are no credentials, and an automatic redirect to the /sitesettings page for the user to input the creds.