Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
5afe783
wip: replace knex for new database migrations
Jan 10, 2025
7a0260d
move all the migrations; implement the migrator
Jan 14, 2025
2d9ff15
Add db migration test from other PR
Jan 14, 2025
42023e0
fix imports; lints
Jan 14, 2025
c838cf6
Add eslint rules
Jan 14, 2025
a9aea26
whitespace
Jan 14, 2025
609c34c
rename withDatabase()
Jan 14, 2025
c2ce4ba
lint?
Jan 14, 2025
714985f
make sure client closed
Jan 14, 2025
72bb6b0
add comment
Jan 14, 2025
65e7709
await
Jan 14, 2025
2fceecf
handle connection closing
Jan 14, 2025
2e42824
run migrations in tests another way
Jan 14, 2025
0821bdd
rename knexConnection in line with master changes
Jan 16, 2025
ae64408
Merge branch 'master' into prevent-new-migrations-with-knex
Jan 16, 2025
100c424
Change in line with #1371
Jan 16, 2025
bb0d883
js -> json
Jan 16, 2025
e2d64cc
reduce changes by renaming migration dirs
Jan 16, 2025
de1e5d7
Add TODOs
Jan 16, 2025
887c492
remove lint changes to legacy migrations
Jan 16, 2025
ed41ada
revert debug
Jan 16, 2025
0769356
revert knexConfig name change
Jan 16, 2025
71d4a8c
Merge branch 'master' into prevent-new-migrations-with-knex
Jan 18, 2025
c95cec6
renames to be less knexy
Jan 18, 2025
322c5ba
reduce changeset
Jan 18, 2025
6c1a62b
revert whitespace change
Jan 18, 2025
a415a70
import fixes for null content types
Jan 21, 2025
5d6218b
import query changes
Jan 21, 2025
fafc6fb
e2e test fix?
Jan 21, 2025
8c6cf29
import test changes
Jan 21, 2025
b264a83
ci/db-migrations: add new path
Jan 21, 2025
9a1db56
Make migration tests pass?
Jan 21, 2025
9987704
only move js?
Jan 21, 2025
f20dad4
lint
Jan 21, 2025
8aa2286
wip
Jan 21, 2025
62f043d
add migrator name
Jan 21, 2025
ec35f7c
correct arg count
Jan 21, 2025
f20e9a1
Merge branch 'master' into prevent-new-migrations-with-knex
alxndrsn Jan 28, 2025
1acb27c
Merge branch 'master' into prevent-new-migrations-with-knex
Feb 4, 2025
08f235c
add check
Feb 4, 2025
3f8aa12
rename new migration
Feb 4, 2025
26fe2ea
Fix test migrator
Feb 4, 2025
2d015c8
update
Feb 4, 2025
b21b486
remove logging
Feb 4, 2025
4c5ce3a
remove superseded migration
Feb 4, 2025
a15fe02
lint
Feb 4, 2025
b78683d
reintroduce faster migration
Feb 4, 2025
8b3b4db
Add review query
Feb 4, 2025
ee46a00
Merge branch 'master' into prevent-new-migrations-with-knex
Feb 11, 2025
b44e674
Resolve TODO
Feb 11, 2025
cf5a4fd
spelling
Feb 18, 2025
5dc4df6
Use same migrations table
Feb 18, 2025
9d0335f
revert name change for describeMigration()
Feb 18, 2025
5336ac9
fix knex_migrations table updates
Feb 18, 2025
86082d4
lint
Feb 18, 2025
d276085
ignore missing migrations
Feb 18, 2025
5aba8f8
document previous
Feb 18, 2025
9393aa4
change migration directories
Feb 18, 2025
0cee983
move migrations
Feb 18, 2025
244d36c
last migration
Feb 18, 2025
dfa2048
rename post-knex
Feb 18, 2025
9215950
move eslintrc
Feb 18, 2025
7d70054
remove dead file
Feb 18, 2025
7f6a8b6
fix requires
Feb 18, 2025
6bf53ad
name
Feb 18, 2025
c7fa35e
wip
Feb 18, 2025
4275829
raw -> query
Feb 18, 2025
929a976
fix?
Feb 18, 2025
d1802de
remove old TODOs
Feb 18, 2025
193f837
rename migrations tests
Feb 18, 2025
0c9610b
skip migration tests
Feb 18, 2025
de23f43
resolve REVIEW comment
Feb 18, 2025
398960f
resolve REVIEW
Feb 18, 2025
f908b9e
resolve TODO
Feb 18, 2025
38fdb4b
resolve TODO: validate migration names
Feb 18, 2025
ed6bb5e
resolve TODO with better comments
Feb 18, 2025
de06080
remove dead comment
Feb 19, 2025
1b68d91
Merge branch 'master' into prevent-new-migrations-with-knex
Mar 19, 2025
ee1e3f8
new migration: raw -> query
Mar 19, 2025
eb14edb
qyer
Mar 19, 2025
4414dc4
Merge branch 'master' into prevent-new-migrations-with-knex
Mar 25, 2025
176bc73
fix name!
Mar 25, 2025
d284918
reduce changeset
Mar 25, 2025
0b289d1
fix migration name
Mar 25, 2025
7cc1b19
Try removing disableMigrationsListValidation
Mar 25, 2025
cd0ff44
Revert "Try removing disableMigrationsListValidation"
Mar 25, 2025
e97f81f
expand comment ref disableMigrationsListValidation
Mar 25, 2025
1937710
Merge branch 'master' into prevent-new-migrations-with-knex
alxndrsn Apr 4, 2025
80b257c
Merge branch 'master' into prevent-new-migrations-with-knex
alxndrsn Apr 28, 2025
34d57fc
Merge branch 'master' into prevent-new-migrations-with-knex
alxndrsn Apr 30, 2025
f219a7b
raw -> query
Apr 30, 2025
26583da
build up full matrix
Apr 30, 2025
ea9dfcf
ci: add on: section
Apr 30, 2025
ef1f0f4
add failing outline of tests
Apr 30, 2025
45e4fbe
update and install
May 2, 2025
b6803ba
without update
May 2, 2025
14f3650
make executable
May 2, 2025
a5207d8
wip
May 2, 2025
5648c47
actually run migrations in the legacy style
May 2, 2025
6116ba0
more prep
May 2, 2025
e9ef7d2
wip
May 2, 2025
332c69b
wip
May 2, 2025
fbdc6fb
show output
May 2, 2025
54fbde8
remove js
May 2, 2025
6fbeb37
wip
May 2, 2025
4d8da90
test all in one
May 2, 2025
d50aed3
better cleran
May 2, 2025
b4b92f1
new filrst
May 2, 2025
2c7abdd
fix requires in legacy migrations
May 2, 2025
c4dfd9a
rebuild
May 2, 2025
efb9ade
build please
May 2, 2025
2ae8b03
get connection string
May 2, 2025
c21187a
nicer esxcaping
May 2, 2025
ba81777
more logging?
May 2, 2025
7b9acbb
flush output
May 2, 2025
95b2b14
fix fix
May 2, 2025
1fccd8b
helpful comments
May 2, 2025
c1df685
no escape backtick
May 2, 2025
9f2f4b0
add missing schema file
May 2, 2025
18ef0e1
expect table contnets
May 2, 2025
962c6a8
ye
May 2, 2025
f984324
revert some legacy to legacy
May 2, 2025
514d180
partial
May 2, 2025
201515a
try different syntax for JSONB_EXISTS
May 2, 2025
19c8ead
Revert "revert some legacy to legacy"
May 2, 2025
c63e4fa
Revert "partial"
May 2, 2025
b82c47e
add missing pgConnectionString
May 2, 2025
757bb93
tryail
May 2, 2025
edfc3fc
add expected schema
May 2, 2025
7f3ca0f
add trailing newline?
May 2, 2025
de3db3c
select less cols
May 2, 2025
c0dd6e6
flushings
May 2, 2025
083b604
expected table contents
May 2, 2025
6fd9531
trailing newline
May 2, 2025
1a7d8a7
remove x
May 2, 2025
30b71b5
remove random output in the middle
May 2, 2025
ff0a10d
disable knex debug
May 2, 2025
a7b4edd
Merge branch 'master' into prevent-new-migrations-with-knex
alxndrsn May 2, 2025
0271b3a
check half way
May 2, 2025
0391aff
wip
May 2, 2025
77d8d62
just print name
May 2, 2025
8048910
prefixes
May 2, 2025
9b95483
js only
May 2, 2025
6089fbf
sort
May 2, 2025
df96dbc
Merge branch 'master' into prevent-new-migrations-with-knex
Jul 14, 2025
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
50 changes: 50 additions & 0 deletions .github/workflows/db-partial-migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This is a test of legacy migrations in various states.
# This test workflow should not be required after knex has been removed.

name: Partial Database Migrations

on:
push:
pull_request:

jobs:
db-partial-migration-tests:
strategy:
matrix:
previous-migrations:
- none
- legacy-first-1
- legacy-first-10
- legacy-first-100
- legacy-all
- new-first-1-as-legacy
- new-first-10-as-legacy
- all
timeout-minutes: 2
# TODO should we use the same container as circle & central?
runs-on: ubuntu-latest
services:
# see: https://docs.github.com/en/[email protected]/actions/using-containerized-services/creating-postgresql-service-containers
postgres:
image: postgres:14.10
env:
POSTGRES_PASSWORD: odktest
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- run: sudo apt-get install tree
- uses: actions/checkout@v4
- name: Set node version
uses: actions/setup-node@v4
with:
node-version: 22.14.0
cache: 'npm'
- run: npm ci
- run: node lib/bin/create-docker-databases.js
- run: test/db-partial-migrations/test.sh ${{ matrix.previous-migrations }}
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ fake-s3-server-persistent:
.PHONY: migrations
migrations: node_version
node lib/bin/run-migrations.js
.PHONY: migrations-legacy
migrations-legacy: node_version
node lib/bin/run-migrations-legacy.js


################################################################################
Expand Down
20 changes: 20 additions & 0 deletions lib/bin/run-migrations-legacy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2022 ODK Central Developers
// See the NOTICE file at the top-level directory of this distribution and at
// https://github.com/getodk/central-backend/blob/master/NOTICE.
// This file is part of ODK Central. It is subject to the license terms in
// the LICENSE file found in the top-level directory of this distribution and at
// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central,
// including this file, may be copied, modified, propagated, or distributed
// except according to the terms contained in the LICENSE file.

const { withKnex, migrate } = require('../model/knex-migrator-legacy');

(async () => {
try {
await withKnex(require('config').get('default.database'))(migrate);
} catch (err) {
if (err.detail) console.error('Error:', err.message, `(${err.detail})`);
else console.error('Error:', err.message); // eslint-disable-line no-multi-spaces
process.exit(1);
}
})();
6 changes: 4 additions & 2 deletions lib/bin/run-migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
// including this file, may be copied, modified, propagated, or distributed
// except according to the terms contained in the LICENSE file.

const { withKnex, migrate } = require('../model/knex-migrator');
const { withKnex, migrate: knexMigrate } = require('../model/knex-migrator');
const { withPg, migrate: pgMigrate } = require('../model/pg-migrator');

(async () => {
try {
await withKnex(require('config').get('default.database'))(migrate);
await withKnex(require('config').get('default.database'))(knexMigrate);
await withPg(require('config').get('default.database'))(pgMigrate);
} catch (err) {
if (err.detail) console.error('Error:', err.message, `(${err.detail})`);
else console.error('Error:', err.message); // eslint-disable-line no-multi-spaces
Expand Down
29 changes: 29 additions & 0 deletions lib/model/knex-migrator-legacy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2017 ODK Central Developers
// See the NOTICE file at the top-level directory of this distribution and at
// https://github.com/getodk/central-backend/blob/master/NOTICE.
// This file is part of ODK Central. It is subject to the license terms in
// the LICENSE file found in the top-level directory of this distribution and at
// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central,
// including this file, may be copied, modified, propagated, or distributed
// except according to the terms contained in the LICENSE file.
//
// This is a variety of functions helpful for connecting to and performing
// top-level operations with a database, like migrations.

const knex = require('knex');
const { knexConnection } = require('../util/db');

// Connects to the postgres database specified in configuration and returns it.
const knexConnect = (config) => knex({ client: 'pg', connection: knexConnection(config) });

// Connects to a database, passes it to a function for operations, then ensures its closure.
const withKnex = (config) => (mutator) => {
const db = knexConnect(config);
return mutator(db).finally(() => db.destroy());
};

// Given a database, initiates migrations on it.
const migrate = (db) => db.migrate.latest({ directory: `${__dirname}/migrations` });

module.exports = { knexConnect, withKnex, migrate };

7 changes: 6 additions & 1 deletion lib/model/knex-migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ const withKnex = (config) => (mutator) => {
};

// Given a database, initiates migrations on it.
const migrate = (db) => db.migrate.latest({ directory: `${__dirname}/migrations` });
// disableMigrationsListValidation: because knex-migrator now shares a DB table
// with pg-migrator, knex's built-in check that all migrations found in the db
// have corresponding migration files in `directory` will fail.
// REVIEW note that we could maintain this check if we duplicate migration
// tables and store pg migrations separately.
const migrate = (db) => db.migrate.latest({ directory: `${__dirname}/migrations/legacy`, disableMigrationsListValidation: true });

module.exports = { knexConnect, withKnex, migrate };

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// Delete draft Submissions that don't have any definition - cb#911
const up = async (db) => {
await db.raw(`
await db.query(`
DELETE FROM submissions s
WHERE draft AND id IN (
SELECT s.id FROM submissions s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// except according to the terms contained in the LICENSE file.

const up = async (db) => {
await db.raw('ALTER TABLE ds_property_fields DROP COLUMN "schemaId"');
await db.query('ALTER TABLE ds_property_fields DROP COLUMN "schemaId"');
};

const down = () => {};
Expand Down
6 changes: 3 additions & 3 deletions lib/model/migrations/20230824-01-add-entity-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// except according to the terms contained in the LICENSE file.

const up = async (db) => {
await db.raw('ALTER TABLE entity_defs ADD COLUMN version INT4 NOT NULL DEFAULT 1');
await db.query('ALTER TABLE entity_defs ADD COLUMN version INT4 NOT NULL DEFAULT 1');

// Sets the correct version number for existing entities
await db.raw(`
await db.query(`
UPDATE entity_defs SET "version" = vt.rownumber
FROM (
SELECT ROW_NUMBER() OVER(PARTITION BY "entityId" ORDER BY id ) rownumber, id FROM entity_defs
Expand All @@ -20,6 +20,6 @@ const up = async (db) => {
`);
};

const down = (db) => db.raw('ALTER TABLE entity_defs DROP COLUMN version');
const down = (db) => db.query('ALTER TABLE entity_defs DROP COLUMN version');

module.exports = { up, down };
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// including this file, may be copied, modified, propagated, or distributed
// except according to the terms contained in the LICENSE file.

const up = (db) => db.raw(`
const up = (db) => db.query(`
update audits set details=(details #- '{entity,label}')
where action='entity.create'`);

Expand Down
4 changes: 2 additions & 2 deletions lib/model/migrations/20230907-01-opened-form-verb.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
// including this file, may be copied, modified, propagated, or distributed
// except according to the terms contained in the LICENSE file.

const up = (db) => db.raw(`
const up = (db) => db.query(`
UPDATE roles SET verbs = REPLACE(verbs ::TEXT, 'form', 'open_form')::JSONB
WHERE system IN ('app-user', 'formview', 'formfill', 'pub-link')`);

const down = (db) => db.raw(`
const down = (db) => db.query(`
UPDATE roles SET verbs = REPLACE(verbs ::TEXT, 'open_form', 'form')::JSONB
WHERE system IN ('app-user', 'formview', 'formfill', 'pub-link')`);

Expand Down
12 changes: 6 additions & 6 deletions lib/model/migrations/20231002-01-add-conflict-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// except according to the terms contained in the LICENSE file.

const up = async (db) => {
await db.raw(`CREATE TYPE "conflictType" AS ENUM ('soft', 'hard')`);
await db.query(`CREATE TYPE "conflictType" AS ENUM ('soft', 'hard')`);

await db.raw('ALTER TABLE entities ADD COLUMN conflict "conflictType" NULL');
await db.query('ALTER TABLE entities ADD COLUMN conflict "conflictType" NULL');

await db.raw(`ALTER TABLE entity_defs
await db.query(`ALTER TABLE entity_defs
ADD COLUMN "dataReceived" JSONB NOT NULL DEFAULT '{}'::jsonb,

-- null means, it's a first version
Expand All @@ -25,13 +25,13 @@ const up = async (db) => {
`);

// Sets the value for "dataReceived" and "baseVersion" for existing row
await db.raw(`UPDATE entity_defs SET "dataReceived" = data || jsonb_build_object('label', "label"), "baseVersion" = CASE WHEN version > 1 THEN version - 1 ELSE NULL END`);
await db.query(`UPDATE entity_defs SET "dataReceived" = data || jsonb_build_object('label', "label"), "baseVersion" = CASE WHEN version > 1 THEN version - 1 ELSE NULL END`);

};

const down = async (db) => {
await db.raw('ALTER TABLE entities DROP COLUMN conflict');
await db.raw('ALTER TABLE entity_defs DROP COLUMN "dataReceived", DROP COLUMN "baseVersion"');
await db.query('ALTER TABLE entities DROP COLUMN conflict');
await db.query('ALTER TABLE entity_defs DROP COLUMN "dataReceived", DROP COLUMN "baseVersion"');
};

module.exports = { up, down };
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
// except according to the terms contained in the LICENSE file.

const up = async (db) => {
await db.raw('UPDATE audits SET "action" = \'entity.error\' WHERE "action" = \'entity.create.error\'');
await db.query('UPDATE audits SET "action" = \'entity.error\' WHERE "action" = \'entity.create.error\'');
};

const down = async (db) => {
// will set any error back to create error, which isn't necessarily right
await db.raw('UPDATE audits SET "action" = \'entity.create.error\' WHERE "action" = \'entity.error\'');
await db.query('UPDATE audits SET "action" = \'entity.create.error\' WHERE "action" = \'entity.error\'');
};

module.exports = { up, down };
8 changes: 4 additions & 4 deletions lib/model/migrations/20231208-01-dataset-form-def-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
// except according to the terms contained in the LICENSE file.

const up = async (db) => {
await db.raw('ALTER TABLE dataset_form_defs ADD COLUMN actions jsonb');
await db.raw(`UPDATE dataset_form_defs SET actions = '["create"]'`);
await db.raw('ALTER TABLE dataset_form_defs ALTER COLUMN actions SET NOT NULL');
await db.query('ALTER TABLE dataset_form_defs ADD COLUMN actions jsonb');
await db.query(`UPDATE dataset_form_defs SET actions = '["create"]'`);
await db.query('ALTER TABLE dataset_form_defs ALTER COLUMN actions SET NOT NULL');
};

const down = (db) =>
db.raw('ALTER TABLE dataset_form_defs DROP COLUMN actions');
db.query('ALTER TABLE dataset_form_defs DROP COLUMN actions');

module.exports = { up, down };
4 changes: 2 additions & 2 deletions lib/model/migrations/20240215-01-entity-delete-verb.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// including this file, may be copied, modified, propagated, or distributed
// except according to the terms contained in the LICENSE file.

const up = (db) => db.raw(`
const up = (db) => db.query(`
UPDATE roles
SET verbs = verbs || '["entity.delete"]'::jsonb
WHERE system IN ('admin', 'manager')`);

const down = (db) => db.raw(`
const down = (db) => db.query(`
UPDATE roles
SET verbs = verbs - 'entity.delete'
WHERE system IN ('admin', 'manager')`);
Expand Down
2 changes: 1 addition & 1 deletion lib/model/migrations/20240215-02-dedupe-verbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// including this file, may be copied, modified, propagated, or distributed
// except according to the terms contained in the LICENSE file.

const up = (db) => db.raw(`
const up = (db) => db.query(`
UPDATE roles
SET verbs = (verbs - 'submission.update') || '["submission.update"]'::jsonb
WHERE system IN ('admin', 'manager')`);
Expand Down
4 changes: 2 additions & 2 deletions lib/model/migrations/20240312-01-add-dataset-create-verb.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
// including this file, may be copied, modified, propagated, or distributed
// except according to the terms contained in the LICENSE file.

const up = (db) => db.raw(`
const up = (db) => db.query(`
UPDATE roles
SET verbs = verbs || '["dataset.create"]'::jsonb
WHERE system in ('admin', 'manager')
`);

const down = (db) => db.raw(`
const down = (db) => db.query(`
UPDATE roles
SET verbs = (verbs - 'dataset.create')
WHERE system in ('admin', 'manager')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// except according to the terms contained in the LICENSE file.

const up = async (db) => {
await db.raw("CREATE INDEX audits_details_entity_def_index ON audits USING HASH (((details ->> 'entityDefId')::INTEGER))");
await db.raw("CREATE INDEX audits_details_entity_source_index ON audits USING HASH (((details ->> 'sourceId')::INTEGER))");
await db.query("CREATE INDEX audits_details_entity_def_index ON audits USING HASH (((details ->> 'entityDefId')::INTEGER))");
await db.query("CREATE INDEX audits_details_entity_source_index ON audits USING HASH (((details ->> 'sourceId')::INTEGER))");
};

const down = async (db) => {
await db.raw('DROP INDEX audits_details_entity_def_index');
await db.raw('DROP INDEX audits_details_entity_source_index');
await db.query('DROP INDEX audits_details_entity_def_index');
await db.query('DROP INDEX audits_details_entity_source_index');
};

module.exports = { up, down };
Expand Down
4 changes: 2 additions & 2 deletions lib/model/migrations/20240515-01-entity-tz-precision.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// except according to the terms contained in the LICENSE file.

const up = async (db) => {
await db.raw('ALTER TABLE entities ALTER COLUMN "deletedAt" TYPE timestamptz(3)');
await db.query('ALTER TABLE entities ALTER COLUMN "deletedAt" TYPE timestamptz(3)');
};

const down = async (db) => {
await db.raw('ALTER TABLE entities ALTER COLUMN "deletedAt" TYPE timestamp');
await db.query('ALTER TABLE entities ALTER COLUMN "deletedAt" TYPE timestamp');
};

module.exports = { up, down };
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// except according to the terms contained in the LICENSE file.

const up = async (db) => {
await db.raw(`ALTER TABLE entity_defs
await db.query(`ALTER TABLE entity_defs
ADD COLUMN "branchId" UUID,
ADD COLUMN "trunkVersion" INT4,
ADD COLUMN "branchBaseVersion" INT4`);
};

const down = (db) => db.raw(`ALTER TABLE entity_defs
const down = (db) => db.query(`ALTER TABLE entity_defs
DROP COLUMN "branchId",
DROP COLUMN "trunkVersion",
DROP COLUMN "branchBaseVersion"
Expand Down
4 changes: 2 additions & 2 deletions lib/model/migrations/20240607-02-add-submission-backlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// except according to the terms contained in the LICENSE file.

const up = async (db) => {
await db.raw(`CREATE TABLE entity_submission_backlog (
await db.query(`CREATE TABLE entity_submission_backlog (
"submissionId" INT4 NOT NULL,
"submissionDefId" INT4 NOT NULL,
"branchId" UUID NOT NULL,
Expand All @@ -26,6 +26,6 @@ const up = async (db) => {
)`);
};

const down = (db) => db.raw('DROP TABLE entity_submission_backlog');
const down = (db) => db.query('DROP TABLE entity_submission_backlog');

module.exports = { up, down };
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// except according to the terms contained in the LICENSE file.

const up = async (db) => {
await db.raw(`ALTER TABLE entity_submission_backlog
await db.query(`ALTER TABLE entity_submission_backlog
ADD COLUMN "auditId" INT4 NOT NULL,
ADD COLUMN "entityUuid" UUID NOT NULL,
ADD CONSTRAINT fk_audit_id
Expand All @@ -17,7 +17,7 @@ const up = async (db) => {
ON DELETE CASCADE`);
};

const down = (db) => db.raw(`ALTER TABLE entity_submission_backlog
const down = (db) => db.query(`ALTER TABLE entity_submission_backlog
DROP COLUMN "auditId",
DROP COLUMN "entityUuid"
`);
Expand Down
Loading
Loading