Skip to content

Commit a98bd02

Browse files
authored
Merge pull request #611 from PhilanthropyDataCommons/609-switch-migration-library
Allow schema specification when migrating
2 parents 28396c8 + 3395305 commit a98bd02

4 files changed

Lines changed: 25 additions & 24 deletions

File tree

package-lock.json

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"jwks-rsa": "^3.1.0",
8383
"pino": "^8.16.2",
8484
"pino-http": "^8.5.1",
85-
"postgres-migrations": "^5.3.0",
85+
"postgres-schema-migrations": "^6.1.0",
8686
"require-env-variable": "^4.0.2",
8787
"swagger-ui-express": "^5.0.0",
8888
"tinypg": "^7.0.0",

src/database/migrate.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import path from 'path';
2-
import { migrate as pgMigrate } from 'postgres-migrations';
2+
import { migrate as pgMigrate } from 'postgres-schema-migrations';
33
import { db } from './db';
44

5-
export const migrate = async (): Promise<void> => {
5+
export const migrate = async (schema = 'public'): Promise<void> => {
66
const client = await db.getClient();
77
try {
88
await pgMigrate(
99
{ client },
1010
path.resolve(__dirname, 'migrations'),
11+
{ schema },
1112
);
1213
} finally {
1314
client.release();

src/test/harnessFunctions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const prepareDatabaseForCurrentWorker = async (): Promise<void> => {
4040
const schemaName = getSchemaNameForCurrentTestWorker();
4141
await createSchema(schemaName);
4242
await setSchema(schemaName);
43-
await migrate();
43+
await migrate(schemaName);
4444
};
4545

4646
export const cleanupDatabaseForCurrentWorker = async (): Promise<void> => {

0 commit comments

Comments
 (0)