Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda