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

Postgres Migration for Money columns still using 4 byte int #2212

Closed
ayushkamadji opened this issue Jun 8, 2023 · 2 comments
Closed

Postgres Migration for Money columns still using 4 byte int #2212

ayushkamadji opened this issue Jun 8, 2023 · 2 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@ayushkamadji
Copy link

Describe the bug
In reference to issue #838. The GraphQL part is fixed in v2.0. But default Postgres migration is still using 4 byte int for money columns which leads to error when adding items to cart which will set the new total > 21,474,836.47.

To Reproduce
Steps to reproduce the behavior:

  1. Add items to cart until total would be set to something > 21,474,836.47
  2. Get error message something went wrong

Expected behavior
Should be able to add more than 21,474,836.47 total into cart

Environment (please complete the following information):

  • @vendure/core version: 2.0.0
  • Nodejs version: v18.12.1
  • Database (mysql/postgres etc): Postgres 13

Additional context
Discord help: https://discord.com/channels/1100672177260478564/1116266274452942918

@ayushkamadji ayushkamadji added the type: bug 🐛 Something isn't working label Jun 8, 2023
@michaelbromley
Copy link
Member

This is by design - the DefaultMoneyStrategy aims to replicate the behaviour of Vendure v1.x. You should switch over to the BigIntMoneyStrategy.

@ayushkamadji
Copy link
Author

Ah yes I went in and tested with BigInt strategy but since there are products already, the migration fails due to price column for existing data being null. This is because the migration generator does a simple drop column and add new column.

I guess this should be a rare case since people should set their money strategy upfront before adding any products.

It's a minor issue when adding the populateProducts option during @vendure/create having populated products assuming the DefaultStrategy. Probably documentation note will suffice.

For those who encounter the same problem:

  1. When generating your vendure project do not choose to populate products
  2. Set BigIntMoneyStrategy for your entityOptions.moneyStrategy in vendure config, see doc
  3. run yarn migration:generate <some_name_for_migration>
  4. Run the app normally and it should automatically migrate the database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants