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

158
Visualizações
What is the right approach creating a Knex migration UP/DOWN which has a TRIM function

I created a Knex migration whose purpose is to update 2 tables records to TRIM white spaces. My concern and doubt are what should be the down part of the migration.

Also if the UP part is right in the way I did.

The TRIM function is not reversible as I understand so the down section, what should be inside that function?

What I did is as follows the up part works well but then we need a down part and so I don't know what could be the best approach here

exports.up = (knex) =>
  Promise.all(
    [knex.raw(`UPDATE sites SET site_id = TRIM(site_id)`)],
    [
      knex.raw(`
    UPDATE
        institutional_review_boards AS i0
        SET
          attached_sites = (
            SELECT
              ARRAY_AGG(TRIM(e))
            FROM (
              SELECT
                UNNEST(attached_sites) e
              FROM
                institutional_review_boards AS i1
              WHERE
                i1.attached_sites = i0.attached_sites) AS i)`),
    ]
  );

exports.down = (knex) => Promise.resolve(knex);
about 4 years ago · Santiago Gelvez
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