#Update Users Collection

7 messages · Page 1 of 1 (latest)

vital idol
#

I have been reading and going through the docs on PCMS and have Implemented the basic Website Template, then I was reviewing the Admin Control Demo and Video (https://youtu.be/DoPLyXG26Dg?si=jUTo8RZ-C_z7frIh)

The question I have is one of the basics of how is PCMS updating the database or types. For example the Demo modifies the users to add roles and attributes. But if I have already installed the Website Template then in theory the database is out of sync with the changes in the Users Collection object and the Payload-types.ts.

Can someone give me a high level direction on how to update the collections on an existing data set? Does PCMS handle this dynamically? How do the conflicts between new types and the database resolve?

Please feel free to clarify my question if it unclear.

Access control is one of Payload's killer features. It delivers a ton of power and flexibility, especially compared to other CMS' rigid RBAC patterns.

Payload's admin UI automatically responds to the access control that you define. For example, if a user can't edit a document, the "Publish" button will be automatically removed. If a user can't...

▶ Play video
green marsh
#

Hi, @vital idol
Could you please clarify what you meant by “already installing the website template”?
I'd appreciate it if you could explain your question in more detail so I can assist you better.

ionic thunder
#

Likely they chose the website template when creating a new project using npx create-payload-app

vital idol
#

First thank you for responding and reading the post. Yes as I am exploring the Payload CMS. I am finding the documentation is so highly abstracted that is exceptionally difficult to follow.

I used npx create-payload-app@latest... Which I understand creates the Payload Templated Website. Which basically does not have roles based permissions implemented. In exploring this I figured a first step was to modify the User collections as Mirkut did in his access-control-demo. I realized the default use in the Website Template had the field name:'name' which was the username. Well I wanted to change this to 'firstName' and 'lastName' as in the access-control-demo. I thought this would be a good step to see how the different pieces are moving together.

Then I realize that after starting the website up and creating an admin, this created a table (using postgres) that already would have a field called 'name' (I checked and the database does). Well now I am changing the Users collection to have fields called 'firstName' and 'lastName' but I am not understanding the flow of how these changes trickle through things. Ultimately this has to result in a database change with these two fields being changed. So I am figuring some how the schema needs updated. I think I saw one line in the docs about auto updating. But this has to be a very common problem.

I just need pointed in the right direction. I have read a lot of the docs but either I am not understanding it or the significance of some of the phrasing is not landing well. My next step is to set a breakpoint on the server instance and step through the code as it processes the request but I thought I would ask here while I figure that out.

vagrant cliff
#

For Postgres: In development mode, Drizzle should automatically push changes (based on the fields you define in your code) to the database. (You might see warnings indicating that proceeding to push changes might result in data loss and ask you to confirm). It should also update your payload types definitions. If you aren't running your app while making the changes, you should run the command to update your types npm run generate:typesand you would might see messages about database changes the next time you start the app.

vital idol