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);