Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example server fails when accessing /admin with Error: Cannot read properties of undefined (reading 'createdAt') #7126

Open
Aeolun opened this issue Jul 12, 2024 · 2 comments
Assignees
Labels

Comments

@Aeolun
Copy link

Aeolun commented Jul 12, 2024

Link to reproduction

No response

Payload Version

3.0.0-beta.60

Node Version

v20.12.2

Next.js Version

15.0.0-rc.0

Describe the Bug

 ⨯ TypeError: Cannot read properties of undefined (reading 'createdAt')
    at Array.reduce (<anonymous>)
digest: "4292446021"
   8 |         } else {
   9 |             columns = [
> 10 |                 table[name]
     | ^
  11 |             ];
  12 |         }
  13 |         if (unique) return uniqueIndex(`${tableName}_${columnName}_idx`).on(columns[0], ...columns.slice(1));
 ⨯ ../../node_modules/.pnpm/@payloadcms [email protected]_@opentelemetry [email protected]_@types [email protected][email protected]._r3rnez2gugtepnwsxzywqkt5vy/node_modules/@payloadcms/db-postgres/dist/schema/createIndex.js (10:1) @ eval

I tried looking around a bit on whether I could find a fix to this, but I have hard time understanding where to even start. It's expecting some createdAt column that's not defined in the object, but the table creation logic is kind of... complex to say the least so no idea where it's supposed to come from.

Reproduction Steps

Using pnpm, run pnpx create-payload-app@beta cms

Enter information, most relevantly blank, postgresql and postgres://[username]@localhost:5432/cms (no password, not sure if relevant)

Then start the application with pnpm run dev, and access http://localhost:3000/admin.

Adapters and Plugins

@payloadcms/db-postgres 3.0.0-beta.60

@Aeolun Aeolun added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Jul 12, 2024
@yobottehg
Copy link

yobottehg commented Jul 12, 2024

I also had this issue yesterday locally when updating to beta 60 but not because of payload but because of updated drizzle-orm and drizzle-kit dependencies.

These versions worked for me:

    "drizzle-kit": "0.20.18",
    "drizzle-orm": "0.30.10",

I need these explicit dependencies because of some customs scripts i wrote to check that the migrations added in the PR will apply cleanly against the target branch.

Also note that beta59 needs a newer Next.js version: https://github.com/payloadcms/payload-3.0-demo/blob/main/package.json#L32

@GrowthWizard
Copy link

I am running into the same issue, after trying to install the payload 3.0 beta.

npx create-payload-app@beta

  1. Choosing the website theme, using postgres password on an empty database.
  2. During installation, running into the same issue, as reported here: Npm projects receiving Cannot find module 'drizzle-orm/pg-core' #6752
  3. Drizzle was not installed or mentioned in my package.json, using npm.
  4. Trying to install Drizzle manually: npm i drizzle-orm
  5. Ending up: with "drizzle-orm": "0.32.10",
  6. Running into a new issue:
    `✓ Starting...
    ✓ Ready in 2.4s
    ○ Compiling /admin/[[...segments]] ...
    ✓ Compiled /admin/[[...segments]] in 3.1s (4086 modules)
    ⨯ node_modules/@payloadcms/db-postgres/dist/schema/createIndex.js (10:1) @ eval
    ⨯ TypeError: Cannot read properties of undefined (reading 'createdAt')
    at Array.reduce ()
    digest: "787331360"
    8 | } else {
    9 | columns = [

10 | table[name]
| ^
11 | ];
12 | }
13 | if (unique) return uniqueIndex(${tableName}_${columnName}_idx).on(columns[0], ...columns.slice(1));
GET /admin 500 in 5183ms
`

  1. Using @yobottehg mention, of changing "drizzle-orm": "0.30.10" via npm install --legacy-peer-deps`
  2. PostGres Connection does work now.

@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Jul 19, 2024
@jmikrut jmikrut assigned r1tsuu and unassigned DanRibbens Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants