Skip to content

Postgres: Collections list page in admin UI cannot fetch data in prod but can in local #3841

@Ali-Parandeh

Description

@Ali-Parandeh

Link to reproduction

No response

Describe the Bug

I have three collections - media, questions and users.

My questions collection is flat and has a blocks field that has 3 blocks only (media upload, richtext and text block for video url)

I have also turned on drafts and versioning on questions collection and use the postgres adapater.

On local everything works perfectly but as soon as I deploy to prod and visit the admin UI I see the following:
The API routes work ok however.

"error: column _questions_v__blocks_contentBlock._uuid does not exist"
Screenshot 2023-10-24 at 10 09 56 Screenshot 2023-10-24 at 10 07 12

To Reproduce

import { CollectionConfig } from "payload/types";
import { Media } from "../blocks/Media";
import { Content } from "../blocks/Content";
import { Video } from "../blocks/Video";
import { slugField } from "../fields/slug";
import { populateAuthors } from "../hooks/populateAuthors";
import { populatePublishedDate } from "../hooks/populatePublishedDate";
import { docOwner } from "../fields/docOwner";


const Questions: CollectionConfig = {
  slug: "questions",
  hooks: {
    afterRead: [populateAuthors],
    beforeChange: [populatePublishedDate],
  },
  versions: {
    drafts: true,
  },
  admin: {
    useAsTitle: "question",
    defaultColumns: ["question", "icon", "difficulty", "category"],
  },
  fields: [
    {
      name: "icon",
      label: "Icon Number",
      type: "number",
    },
    {
      name: "question",
      label: "Question",
      type: "text",
      required: true,
    },
    {
      name: "difficulty",
      label: "Difficulty",
      type: "select",
      admin: {
        position: "sidebar",
      },
      options: [
        { label: "🟢 Easy", value: "Easy" },
        { label: "🟡 Medium", value: "Medium" },
        { label: "🔴 Hard", value: "Hard" },
      ],
      required: true,
    },
    {
      name: "category",
      label: "Category",
      type: "select",
      admin: {
        position: "sidebar",
      },
      options: [
        {
          label: "Option 1",
          value: "option1",
        },
      ....
      ],
      required: true,
    },
    {
      name: "publishedOn",
      admin: {
        date: {
          pickerAppearance: "dayAndTime",
        },
        position: "sidebar",
      },
      hooks: {
        beforeChange: [
          ({ siblingData, value }) => {
            if (siblingData._status === "published" && !value) {
              return new Date();
            }
            return value;
          },
        ],
      },
      type: "date",
    },
    ...docOwner(),
    slugField("question"),
    {
      name: "criteria",
      label: "Criteria",
      type: "textarea",
      required: true,
    },
    {
      name: "supportingInfo",
      label: "Supplementary Information",
      type: "blocks",
      blocks: [Content, Media, Video],
    },
  ],
};

export default Questions;

Content Block

import { Block } from "payload/types";

export const Content: Block = {
  fields: [
    {
      name: "content",
      label: "Content",
      type: "richText",
    },
  ],
  slug: "contentBlock",
};

Media Block

import { Block } from "payload/types";

export const Media: Block = {
  fields: [
    {
      name: "media",
      relationTo: "media",
      required: true,
      type: "upload",
    },
  ],
  slug: "mediaBlock",
};

Video Block

import { Block } from "payload/types";

export const Video: Block = {
  slug: "videoBlock",
  fields: [
    {
      name: "title",
      label: "Title",
      type: "text",
      required: true,
    },
    {
      name: "url",
      label: "URL",
      type: "text",
    },
  ],
};

Steps to reproduce:

  1. Yarn dev locally to migrate prod db
  2. Deploy to prod
  3. Access the admin UI on prod and locally. The local will load the collection list page but prod will show you this
Screenshot 2023-10-24 at 10 09 56

Payload Version

^2.0.0

Adapters and Plugins

"@google-cloud/storage": "^7.3.0",     "@payloadcms/bundler-webpack": "^1.0.0",     "@payloadcms/db-postgres": "^0.x",     "@payloadcms/plugin-cloud": "^2.0.0",     "@payloadcms/plugin-cloud-storage": "^1.1.1",     "@payloadcms/richtext-slate": "^1.0.0",     "cross-env": "^7.0.3",     "dotenv": "^8.2.0",     "express": "^4.17.1",     "payload": "^2.0.0"

Metadata

Metadata

Assignees

Labels

status: needs-triagePossible bug which hasn't been reproduced yet

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions