Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add data-type migrations #1929

Merged
merged 3 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.raw(`
ALTER TABLE grants
ADD COLUMN award_ceiling_temp bigint,
ADD COLUMN award_floor_temp bigint,
ADD COLUMN open_date_temp date,
ADD COLUMN close_date_temp date,
ADD COLUMN archive_date date
`);
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.raw(`
ALTER TABLE grants
DROP COLUMN award_ceiling_temp,
DROP COLUMN award_floor_temp,
DROP COlUMN open_date_temp,
DROP COLUMN close_date_temp,
DROP COLUMN archive_date
`);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.raw(`
UPDATE grants
SET award_ceiling_temp = award_ceiling::bigint,
award_floor_temp = award_floor::bigint,
open_date_temp = open_date::date,
close_date_temp = close_date::date
`);
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.raw(`
UPDATE grants
SET award_ceiling_temp = NULL,
award_floor_temp = NULL,
open_date_temp = NULL,
close_date_temp = NULL
`);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.raw(`
ALTER TABLE grants
RENAME COLUMN award_ceiling TO award_ceiling_old,
RENAME COLUMN award_floor TO award_floor_old,
RENAME COLUMN open_date TO open_date_old,
RENAME COLUMN close_date TO close_date_old,
RENAME COLUMN award_ceiling_temp TO award_ceiling,
RENAME COLUMN award_floor_temp TO award_floor,
RENAME COLUMN open_date_temp TO open_date,
RENAME COLUMN close_date_temp TO close_date
`);
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.raw(`
ALTER TABLE grants
RENAME COLUMN award_ceiling TO award_ceiling_temp,
RENAME COLUMN award_floor TO award_floor_temp,
REANME COLUMN open_date TO open_date_temp,
RENAME COLUMN close_date TO close_date_temp,
RENAME COLUMN award_ceiling_old TO award_ceiling,
RENAME COLUMN award_floor_old TO award_floor,
RENAME COLUMN open_date_old TO open_date,
REANME COLUMN close_date_old TO close_date
`);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.raw(`
ALTER TABLE grants
DROP COLUMN award_ceiling_old,
DROP COLUMN award_floor_old,
DROP COLUMN open_date_old,
DROP COLUMN close_date_old
`);
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.raw(`
ALTER TABLE grants
ADD COLUMN award_ceiling_old text,
ADD COLUMN award_floor_old text,
ADD COLUMN open_date_old text,
ADD COLUMN close_date_old text
`);
};
1 change: 1 addition & 0 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"import-arpa-dump": "node src/scripts/import_arpa_reporter_dump.js",
"lint": "eslint '**/*.js'",
"migrate:make": "knex migrate:make",
"migrate:up": "knex migrate:up",
"parse-output-templates": "node src/scripts/parseOutputTemplates.mjs",
"pre-commit": "yarn lint",
"serve": "nodemon src",
Expand Down
Loading