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

Creating migrations not working in latest v2 #8782

Closed
max-degterev opened this issue Oct 18, 2024 · 12 comments · Fixed by #8786
Closed

Creating migrations not working in latest v2 #8782

max-degterev opened this issue Oct 18, 2024 · 12 comments · Fixed by #8786
Labels

Comments

@max-degterev
Copy link

max-degterev commented Oct 18, 2024

Link to reproduction

No response

Describe the Bug

Last version of v2 is incompatible with previous migrations:

 ~/Projects/bldry-db │ master !1  npm run payload migrate:create noTextIndex                                                                                                

> [email protected] payload
> cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload migrate:create noTextIndex

[15:30:12] INFO (payload): Starting Payload...

/Volumes/Data/Projects/bldry-db/node_modules/payload/src/bin/migrate.ts:88
        throw new Error(`Error creating migration: ${err.message}`)
              ^
Error: Error creating migration: [
  {
    "received": "5",
    "code": "invalid_literal",
    "expected": "7",
    "path": [
      "version"
    ],
    "message": "Invalid literal value, expected \"7\""
  },
  {
    "received": "pg",
    "code": "invalid_literal",
    "expected": "postgresql",
    "path": [
      "dialect"
    ],
    "message": "Invalid literal value, expected \"postgresql\""
  },
  {
    "code": "invalid_type",
    "expected": "object",
    "received": "string",
    "path": [
      "tables",
      "admins",
      "indexes",
      "admins_created_at_idx",
      "columns",
      0
    ],
    "message": "Expected object, received string"
  },
  {
    "code": "invalid_type",
    "expected": "object",
    "received": "string",
    "path": [
      "tables",
      "admins",
      "indexes",
      "admins_email_idx",
      "columns",
      0
    ],
    "message": "Expected object, received string"
  },
  {
    "code": "invalid_type",
    "expected": "object",
    "received": "string",
    "path": [
      "tables",
      "users_parameters",
      "indexes",
      "users_parameters_order_idx",
      "columns",
      0
    ],
    "message": "Expected object, received string"
  },
  {
    "code": "invalid_type",
    "expected": "object",
    "received": "string",
    "path": [
      "tables",
      "users_parameters",
      "indexes",
      "users_parameters_parent_id_idx",
      "columns",
      0
    ],
    "message": "Expected object, received string"
  },
// ... lots of similar errors
  {
    "code": "invalid_type",
    "expected": "array",
    "received": "object",
    "path": [
      "enums",
      "enum_email_format",
      "values"
    ],
    "message": "Expected array, received object"
  }
]
    at migrate (/Volumes/Data/Projects/bldry-db/node_modules/payload/src/bin/migrate.ts:88:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

To Reproduce

I am running agains a system with existing migrations. Initially the change in enum behavior has forced me to re-create my dev DB to start the project. Now I am unable to create migrations (same enum issue again). Any idea how to patch the old schema so the new system is able to diff it correctly?

Payload Version

current v2

Adapters and Plugins

No response

@max-degterev max-degterev added status: needs-triage Possible bug which hasn't been reproduced yet v2 labels Oct 18, 2024
@max-degterev
Copy link
Author

Regression was pushed yesterday with "@payloadcms/db-postgres": "0.8.8"

locking to 0.8.7 allows to create migrations

@r1tsuu
Copy link
Member

r1tsuu commented Oct 18, 2024

It may be possible for you to clean up all your migrations and create a new one from the latest version

@r1tsuu
Copy link
Member

r1tsuu commented Oct 18, 2024

Another note, if you have drizzle-orm / kit installed in your project you need to bump them, may be not related to this

@max-degterev
Copy link
Author

max-degterev commented Oct 18, 2024

It may be possible for you to clean up all your migrations and create a new one from the latest version

Yes but I would need to seed some sort of pre-migration migration to not have it run. Since it will create a new initial migration. Not great.

@r1tsuu
Copy link
Member

r1tsuu commented Oct 18, 2024

It may be possible for you to clean up all your migrations and create a new one from the latest version

Yes but I would need to seed some sort of pre-migration migration to not have it run. Since it will create a new initial migration. Not great.

You could "simulate" that it's ran by adding it to the payload_migratoons table manually, not ideal but may work
@DanRibbens did we encounter issues like this on beta?

@max-degterev
Copy link
Author

Yeah that was my initial reaction too but I thought to ask here for a better fix perhaps

@DanRibbens
Copy link
Contributor

I just spoke with @r1tsuu
We missed the piece of code that migrates drizzle snapshot schemas. That will handle the versioning error you are seeing here.

We're going to include a test for this and release the updated patch later today.

Thanks for reporting this @max-degterev!

@max-degterev
Copy link
Author

Awesome, lmk when it's live I will test for you 👍

@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Oct 18, 2024
Copy link

🚀 This is included in version v2.30.3

@max-degterev
Copy link
Author

Works, thanks!

@r1tsuu
Copy link
Member

r1tsuu commented Oct 19, 2024

Nice, thank you! My bad that I missed this important thing.

Copy link

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants