Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

migration in ci - going from push:true to push:false

default discord avatar
cedric.dev_last year
8

Hi



I am trying to integrate migrations in my CI.



As I have previously connected to my db with "push: true", I get following message, when trying to migrate a new change:



? It looks like you've run Payload in dev mode, meaning you've dynamically pushed changes to your database.
If you'd like to run migrations, data loss will occur. Would you like to proceed? › (y/N)


I already run it locally once (connecting to that same db) and accepted. push is also set to false now. I then added a new field, and this message keeps coming up. How is Payload tracking this? Is there a way to tell it to use migrations from now on? The only solution I found yet, is deleting and recreating my database and ensure to never use push:true. But that doesn't seem sustainable.



Does anyone have a better solution?

  • default discord avatar
    xndyzyxlast year

    it's being tracked here

  • default discord avatar
    themachine0488last year

    Hello

    @1270279842872561717

    I think you need to remove the dev entry in the table



    DELETE FROM payload_migrations WHERE name='dev'
  • default discord avatar
    nils06488last year

    You do not migrate your dev database, it is managed by push true.



    Once you are happy with your changes create a migration for another database.


    Use a localdb to test with simple changes. Check the files in migrations, you will understand a lot more.

  • default discord avatar
    zed0547last year
  • default discord avatar
    nils06488last year

    ⭐️ your repo. Thanks a lot.

  • default discord avatar
    cedric.dev_last year
    @149226354624167936

    @1286711107020390481

    thanks, that's exactly what I was looking for! 🙂



    @795565624860344320

    @654031862146007055

    thanks for your comments. I'm aware you shouldn't do it, but I'm at the start of a project and experimenting and shit happens 🙂 . I didn't want to drop my database just because of this.

  • default discord avatar
    nils06488last year
    @1270279842872561717


    Another approach is to not have individual data on dev. Loosing it is part of the flow.



    I have apps that have proper seeding of minimal data; loosing data is part of the flow.


    A

    pnpm run dev:seed

    gives any developer the same clean start. It is an extra step and extra time with your updated schema. But, it enables the "same" experience for all devs and since loosing data, is the plan, you can use

    pnpm run payload migrate:create

    on the same dev database and create migrations.



    !!! Creating seeding data is a annoying step. But you get joy, when it's done. Keep it minimal, it should only be for critical data. In best cases, you have tests for the seeding data / use case that need it.


    Keep it clean from load test data, client data, test data separately. This seeding is only for you.



    ... only go here, once you have the standard flow (our discussion) under control.

  • default discord avatar
    cedric.dev_last year

    Yes thanks. I'll try to improve my setup to get this flow.



    But yeah, creating seeding data is indeed an annoying step. I already have some in place, but I need to relate words from my rich text field to glossary items, which makes the seeding even worse 😅

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.