Peppermint-Lab / peppermint

An open source ticket management & help desk solution. A zendesk/freshdesk alternative
https://peppermint.sh
Other
1.95k stars 205 forks source link

Can not run yarn seeds command #151

Closed horellana closed 10 months ago

horellana commented 1 year ago

Hi, im trying to tests this project but when i do yarn run seed ,in the apps/client/ directory, i get the following error:

Environment variables loaded from .env
Running seed command `node ./prisma/seed.js` ...
PrismaClientValidationError:
Invalid `prisma.user.upsert()` invocation:

{
  where: {
    email: 'admin@admin.com'
  },
  update: {},
  create: {
    email: 'admin@admin.com',
    name: 'admin',
    isAdmin: true,
    password: '$2b$10$BFmibvOW7FtY0soAAwujoO9y2tIyB7WEJ2HNq9O7zh9aeejMvRsKu',
    language: 'en'
    ~~~~~~~~
  }
}

Unknown arg `language` in create.language for type UserCreateInput. Did you mean `name`? Available args:
type UserCreateInput {
  createdAt?: DateTime
  updatedAt?: DateTime
  name: String
  password: String
  email: String
  isAdmin: Boolean
  todos?: TodosCreateNestedManyWithoutCreatedByInput
  tickets?: TicketCreateNestedManyWithoutAssignedToInput
  file?: UserFileCreateNestedManyWithoutUserInput
  notes?: NotesCreateNestedManyWithoutCreatedByInput
}

    at Object.validate (/home/hector/proyectos/peppermint/node_modules/@prisma/client/runtime/index.js:34755:20)
    at PrismaClient._executeRequest (/home/hector/proyectos/peppermint/node_modules/@prisma/client/runtime/index.js:39749:17)
    at consumer (/home/hector/proyectos/peppermint/node_modules/@prisma/client/runtime/index.js:39690:23)
    at /home/hector/proyectos/peppermint/node_modules/@prisma/client/runtime/index.js:39694:49
    at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
    at PrismaClient._request (/home/hector/proyectos/peppermint/node_modules/@prisma/client/runtime/index.js:39694:27)
    at request (/home/hector/proyectos/peppermint/node_modules/@prisma/client/runtime/index.js:39799:77)
    at _callback (/home/hector/proyectos/peppermint/node_modules/@prisma/client/runtime/index.js:40007:14)
    at PrismaPromise.then (/home/hector/proyectos/peppermint/node_modules/@prisma/client/runtime/index.js:40014:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  clientVersion: '3.7.0'
}

Im at the git commit 446a20b870bc68157eaafcb7275c289d76bfb29e. This is my apps/client/.env file:

NODE_ENV=development
PORT=3000
JWT_SECRET="12234"
DB_USERNAME='postgres'
DB_PASSWORD='postgres'
DB_HOST="localhost"
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/peppermint?schema=public"

yarn run migrate runs ok and says that there are no pending migrations to apply.

node version v16.19.1
npm version 8.19.3

Tried removing that language: 'en' line from the seed file, but get the following error:

PrismaClientKnownRequestError:
Invalid `prisma.user.upsert()` invocation:

  Null constraint violation on the fields: (`id`)
    at cb (/home/hector/proyectos/peppermint/node_modules/@prisma/client/runtime/index.js:38688:17)
    at async main (/home/hector/proyectos/peppermint/apps/client/prisma/seed.js:6:17) {
  code: 'P2011',
  clientVersion: '3.7.0',
  meta: { constraint: [ 'id' ] }
}

to fix that tried adding an id to the seed like this:

const admin = await prisma.user.upsert({
    where: { email: "admin@admin.com" },
    update: {},
    create: {
      id: "23299ae5-48e4-4015-a105-1d3439ea84d5",
      email: `admin@admin.com`,
      name: "admin",
      isAdmin: true,
      password: "$2b$10$BFmibvOW7FtY0soAAwujoO9y2tIyB7WEJ2HNq9O7zh9aeejMvRsKu",
    },
  });

But then i get: Unknown arg 'id' in create.id for type UserCreateInput.

potts99 commented 10 months ago

new migrations fix this