Skip to content
Snippets Groups Projects
Commit dad52b33 authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

feat: #be switch from sqlite to pg

parent 477ddd08
Branches
Tags
No related merge requests found
Pipeline #22985 passed
node_modules
postgres-data
......@@ -131,4 +131,4 @@ dist
#===============================================================================
*.sqlite3
postgres-data
version: '3.7'
version: "3.7"
services:
webserver:
......@@ -10,7 +10,22 @@ services:
- ./src:/app/src
- ./nodemon.json:/app/nodemon.json
ports:
- '8080:8080'
- "8080:8080"
environment:
- PORT=8080
- DATABASE_URL=postgres://db_user:db_pass@database/db_name
command: npm run serve
database:
image: postgres:14-alpine
restart: always
environment:
- POSTGRES_DB=db_name
- POSTGRES_USER=db_user
- POSTGRES_PASSWORD=db_pass
expose:
- "5432"
ports:
- "5432:5432"
# TODO: preserve db data; skipped rn as Win permissions are being annoying.
#volumes:
# - ./postgres-data:/var/lib/postgresql/data
// Update with your config settings.
/**
* @type { Object.<string, import("knex").Knex.Config> }
*/
module.exports = {
development: {
client: "sqlite3",
connection: {
filename: "./dev.sqlite3",
},
},
// staging: {
// client: "postgresql",
// connection: {
// database: "my_db",
// user: "username",
// password: "password",
// },
// pool: {
// min: 2,
// max: 10,
// },
// migrations: {
// tableName: "knex_migrations",
// },
// },
// production: {
// client: "postgresql",
// connection: {
// database: "my_db",
// user: "username",
// password: "password",
// },
// pool: {
// min: 2,
// max: 10,
// },
// migrations: {
// tableName: "knex_migrations",
// },
// },
};
import type { Knex } from "knex";
const config: Knex.Config = {
client: "pg",
connection: process.env.DATABASE_URL,
};
export default config;
This diff is collapsed.
......@@ -21,14 +21,14 @@
"fastify": "^3.27.1",
"fastify-cors": "^6.0.2",
"json-schema-to-ts": "^1.6.5",
"knex": "^1.0.3"
"knex": "^1.0.3",
"pg": "^8.7.3"
},
"devDependencies": {
"@types/jest": "^27.0.3",
"@types/node": "^16.11.11",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"@vscode/sqlite3": "^5.0.7",
"eslint": "^8.3.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^25.3.0",
......@@ -38,7 +38,6 @@
"nodemon": "^2.0.15",
"pino-pretty": "^7.5.1",
"prettier": "^2.5.1",
"sqlite3": "^5.0.2",
"ts-jest": "^27.0.7",
"ts-node": "^10.5.0",
"typescript": "^4.5.2"
......
import knex from "knex";
import config from "../knexfile";
export const connection = knex({
client: "sqlite3", // or 'better-sqlite3'
connection: {
filename: "./dev.sqlite3",
// filename: ":memory:",
},
});
export const connection = knex(config);
......@@ -13,7 +13,7 @@
// Customization
//"moduleResolution": "node",
"rootDir": "./src",
//"rootDir": "./src",
"baseUrl": "./src",
"outDir": "./dist"
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment