Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda