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

Update to DBOS 1.12.10+ #151

Merged
merged 6 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/bank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ jobs:
working-directory: bank/bank-backend/
run: |
npm ci
npx prisma migrate dev --name init --schema prisma/schema.prisma
npm run lint
npm run build
npm test
Expand All @@ -72,4 +71,5 @@ jobs:
# The default PostgreSQL port
POSTGRES_PORT: 5432
BANK_PORT: 8081
BANK_SCHEMA: banktest
# CB 6/6/2024 - temporary limitation
BANK_SCHEMA: public
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Logs
**/.DS_Store
**/prisma/migrations/*
#**/prisma/migrations/*

logs
*.log
Expand Down
5 changes: 4 additions & 1 deletion bank/bank-backend/dbos-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ database:
app_db_name: 'bank'
password: ${PGPASSWORD}
app_db_client: "prisma"
migrate:
- npx prisma migrate deploy
runtimeConfig:
port: 8081
application:
bankname: "DBOS Bank - ${BANK_SCHEMA}"
bankport: '8081'
bankschema: ${BANK_SCHEMA}
#bankschema: ${BANK_SCHEMA}
bankschema: public
16 changes: 16 additions & 0 deletions bank/bank-backend/generate_env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { parseConfigFile } = require('@dbos-inc/dbos-sdk/dist/src/dbos-runtime/config');
const fs = require('node:fs');
const path = require('node:path');

// Load the configuration file
const [dbosConfig, ] = parseConfigFile();

// Write out the .env file
const databaseURL = `postgresql://${dbosConfig.poolConfig.user}:${dbosConfig.poolConfig.password}@${dbosConfig.poolConfig.host}:${dbosConfig.poolConfig.port}/${dbosConfig.poolConfig.database}?schema=${process.env['BANK_SCHEMA']}`;

try {
fs.writeFileSync(path.join(process.cwd(), 'prisma', '.env'), `DATABASE_URL="${databaseURL}"`);
console.log("Wrote database URL to the prisma/.env file.");
} catch (error) {
console.error("Error writing prisma/.env file:", error.message);
}
73 changes: 58 additions & 15 deletions bank/bank-backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions bank/bank-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"main": "dist/main.js",
"types": "dist/main.d.js",
"scripts": {
"build": "npx prisma generate && tsc",
"build": "node generate_env.js && npx prisma generate && tsc",
"start": "node .",
"test": "jest --detectOpenHandles",
"test": "npm run build && npx dbos migrate && jest --detectOpenHandles",
"lint-fix": "eslint --ext .ts --fix .",
"lint": "eslint --ext .ts ."
},
"author": "",
"license": "ISC",
"private": true,
"dependencies": {
"@dbos-inc/dbos-sdk": "^1.7.6",
"@dbos-inc/dbos-sdk": "^1.12.10",
"@koa/bodyparser": "^5.0.0",
"@koa/cors": "^5.0.0",
"@koa/router": "^12.0.0",
Expand All @@ -30,7 +30,7 @@
"prisma": "^5.1.1"
},
"devDependencies": {
"@dbos-inc/dbos-cloud": "^1.7.6",
"@dbos-inc/dbos-cloud": "^1.12.10",
"@dbos-inc/eslint-plugin": "^0.0.6",
"@types/jest": "^29.5.3",
"@types/koa__cors": "^4.0.1",
Expand Down
8 changes: 1 addition & 7 deletions bank/bank-backend/prisma/.env
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL=postgresql://bank:${PGPASSWORD}@localhost:5432/bank?schema=${BANK_SCHEMA}
DATABASE_URL="postgresql://bank:postgres@localhost:5432/bank?schema=public"
Loading
Loading