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

124
Views
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
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!