Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
Sequelize/Postgres: NUMERIC scale 7 must be between 0 and precision 2

Issue Can't seem to figure out how to resolve error when migrating decimal to Heroku.

In my sequelize, it is running fine but heroku is giving me this error for postgres:

migration

  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('Spots', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      address: {
        type: Sequelize.STRING(255),
        allowNull: false
      },
      city: {
        type: Sequelize.STRING(50),
        allowNull: false
      },
      state: {
        type: Sequelize.STRING(50),
        allowNull: false
      },
      country: {
        type: Sequelize.STRING(50),
        allowNull: false
      },
      lat: {
        type: Sequelize.DECIMAL(10, 7)
      },
      lng: {
        type: Sequelize.DECIMAL(10, 7)
      },
      name: {
        type: Sequelize.STRING(50)
      },
      description: {
        type: Sequelize.STRING(255)
      },
      price: {
        type: Sequelize.DECIMAL(4, 2)
      },
      avgStarRating: {
        type: Sequelize.DECIMAL(2, 1)
      },
      ownerId: {
        type: Sequelize.INTEGER
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE,
        defaultValue: Sequelize.literal("CURRENT_TIMESTAMP")
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE,
        defaultValue: Sequelize.literal("CURRENT_TIMESTAMP")
      }
    });
  },

Error

ERROR: NUMERIC scale 7 must be between 0 and precision 2

Sample output:

{
  "Spots": [
    {
      ...,
      "lat": 37.7645358,
      "lng": -122.4730327,
      ...
    }
  ]
}

Have tried changing all the DECIMAL to NUMERIC/FLOAT (just to try if it work) and still resulted in same error. What may I be doing wrong? Thank you!

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

For a numeric type, the first number is the total number of digits to be represented, including both sides of the decimal point. The second value is the number of digits to the right of the decimal point. Thus, (2, 7) does not make sense.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!