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

113
Vistas
How to look at SQL query while Knex.js migrations?

Let's say I have such piece of code:

exports.up = function(knex, Promise) {
  return knex.schema
    .createTable('test', table => {
      table.uuid('id').primary();
    })
};

This is just simple migration and it works correctly, but what I want is to look at SQL query using .toSQ() method. This method works while requests to DB using Knex.js, but how to do that while migrations?

When I was trying to add just .toSQL() at the end of the code, I had such error:

migration 20211101093701_test.js did not return a promise

Also I was trying to made function async like:

exports.up = async function(knex, Promise) {
  return knex.schema
    .createTable('test', table => {
      table.uuid('id').primary();
    }).toSQL();
};

But it works just like common migration. How can I add this .toSQL() method?

about 4 years ago · Juan Pablo Isaza
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