-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure DB migration runs (#1120)
* ensure DB migration runs * add beta to branch QA
- Loading branch information
1 parent
a7e93f3
commit e440f3f
Showing
6 changed files
with
42 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ on: | |
pull_request: | ||
branches: | ||
- main | ||
- beta | ||
paths-ignore: | ||
- "docs/**" | ||
- "**/README.md" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { spawnSync } from "child_process"; | ||
import pino from "pino"; | ||
const logger = pino(); | ||
|
||
export function setupDatabase() { | ||
const schemaLocation = require.resolve( | ||
"@xgovformbuilder/queue-model/schema.prisma" | ||
); | ||
|
||
const child = spawnSync( | ||
"prisma", | ||
["migrate", "deploy", "--schema", schemaLocation], | ||
{ | ||
encoding: "utf-8", | ||
stdio: "inherit", | ||
} | ||
); | ||
|
||
if (child.status === 1) { | ||
logger.error("Could not connect to database, exiting"); | ||
logger.error(child.error); | ||
process.exit(1); | ||
} | ||
|
||
if (child.stdout) { | ||
logger.info(child.stdout); | ||
logger.info("Database migration was successful, continuing"); | ||
} | ||
} |