#user_sessions table not found, failing migrations on production

9 messages · Page 1 of 1 (latest)

frozen turtle
#
query: `select "users"."id", "users"."updated_at", "users"."created_at", "users"."email", "users"."reset_password_token", "users"."reset_password_expiration", "users"."salt", "users"."hash", "users"."login_attempts", "users"."lock_until", "users_roles"."data" as "roles", "users_sessions"."data" as "sessions" from "users" "users" left join lateral (select coalesce(json_agg(json_build_array("users_roles"."value") order by "users_roles"."order" asc), '[]'::json) as "data" from (select * from "users_roles" "users_roles" where "users_roles"."parent_id" = "users"."id" order by "users_roles"."order" asc) "users_roles") "users_roles" on true left join lateral (select coalesce(json_agg(json_build_array("users_sessions"."_order", "users_sessions"."id", "users_sessions"."created_at", "users_sessions"."expires_at") order by "users_sessions"."_order" asc), '[]'::json) as "data" from (select * from "users_sessions" "users_sessions" where "users_sessions"."_parent_id" = "users"."id" order by "users_sessions"."_order" asc) "users_sessions") "users_sessions" on true order by "users"."created_at" desc limit $1`,
params: [Array],
digest: '3958743889',
[cause]: error: relation "users_sessions" does not exist

this happened on my prod server—I haven’t changed anything on the user collection though …

Do you have any suggestions on how to debug this?

coral emberBOT
#

Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:

Documentation:

Community-Help:

frozen turtle
#

This is the table schema of the users table:

Table "public.users"

Column Type Collation Nullable Default Storage Compression Stats Target Description
id integer not null nextval('users_id_seq'::regclass) plain
updated_at timestamp(3) with time zone not null now() plain
created_at timestamp(3) with time zone not null now() plain
email character varying not null extended
reset_password_token character varying extended
reset_password_expiration timestamp(3) with time zone plain

Indexes

  • "users_pkey" PRIMARY KEY, btree (id)
  • "users_created_at_idx" btree (created_at)
  • "users_email_idx" UNIQUE, btree (email)
  • "users_updated_at_idx" btree (updated_at)

Referenced by

  • "els_users_fk" FOREIGN KEY (users_id) REFERENCES users(id) ON DELETE CASCADE
  • Other foreign keys referencing users(id) ON DELETE CASCADE (names appear truncated)
frozen turtle
#

also, when i try to run payload migrate:create i get this error:

throw new Error(Error creating migration: ${error})
^

Error: Error creating migration: [
{
"code": "invalid_literal",
"expected": "pg",
"path": [
"dialect"
],
"message": "Invalid literal value, expected "pg""
},
{
"code": "invalid_type",
"expected": "object",
"received": "undefined",
"path": [
"tables"
],
"message": "Required"
},
{
"code": "invalid_type",
"expected": "object",
"received": "undefined",
"path": [
"enums"
],
"message": "Required"
},
{
"code": "invalid_type",
"expected": "object",
"received": "undefined",
"path": [
"schemas"
],
"message": "Required"
},
{
"code": "invalid_type",
"expected": "object",
"received": "undefined",
"path": [
"_meta"
],
"message": "Required"
},
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"id"
],
"message": "Required"
},
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"prevId"
],
"message": "Required"
}
]
at migrate (/Users/ericwatke/Documents/GitHub/elektro-waetke-turbo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/src/bin/migrate.ts💯15)
at async start (file:///Users/ericwatke/Documents/GitHub/elektro-waetke-turbo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/bin.js:30:7)

Node.js v23.11.1
 ELIFECYCLE  Command failed with exit code 1.

frozen turtle
#

guess i should read the changelogs...

🚨 Notice 🚨

If your project uses the local auth strategy with db-postgres or db-sqlite, a migration is required. This is due to a new security feature (enabled by default) that stores a unique auth session identifier in the database.

To opt out and continue using the previous behavior, you can disable the feature by setting auth.useSessions: false in your users collection config.

For example:

// payload.config.ts
collections: [
{
slug: 'users',
auth: {
useSessions: false,
},
fields: [],
},
],

but i still cant create new migrations due to the previous error

coral emberBOT
orchid gulch
#

I'm having the same problem - same error is logged in my prod environment, payload version 3.42.0 (upgraded from 3.37.0). I was actually able to create a new migration file that ran on the server, but it looks like the deployment failed due to this error. But I can't use useSessions: false, as that isn't part of the version I'm using...

dawn bone
#

did you find solution?