M .gitignore => .gitignore +2 -1
@@ 4,4 4,5 @@ testdb/
.yarn/
*.cjs
*.mjs
-.fleet/>
\ No newline at end of file
+.fleet/
+.env
A knexfile.ts => knexfile.ts +26 -0
@@ 0,0 1,26 @@
+import type { Knex } from "knex";
+import {SCHEMA_NAME} from "./src/environment";
+
+// Update with your config settings.
+
+const config: { [key: string]: Knex.Config } = {
+ development: {
+ client: 'postgresql',
+ connection: {
+ database: process.env.DB_NAME,
+ user: process.env.DB_USER,
+ password: process.env.DB_PASSWORD,
+ host: process.env.DB_HOST
+ },
+ pool: {
+ min: 2,
+ max: 10
+ },
+ migrations: {
+ tableName: 'knex_migrations',
+ }
+ },
+
+};
+
+module.exports = config;
M package.json => package.json +5 -1
@@ 14,6 14,8 @@
"@typescript-eslint/eslint-plugin": "latest",
"@typescript-eslint/parser": "^5.59.0",
"dockerode": "^3.3.5",
+ "dotenv": "^16.0.3",
+ "dotenv-cli": "^7.2.1",
"eslint": "^8.38.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-functional": "latest",
@@ 29,6 31,8 @@
"scripts": {
"dev": "nodemon src/index.ts",
"build": "tsc -p tsconfig.json",
- "lint": "eslint . --ext .ts"
+ "lint": "eslint . --ext .ts",
+ "migrate": "dotenv knex migrate:latest",
+ "migrateup": "dotenv knex migrate:up"
}
}
M yarn.lock => yarn.lock +20 -0
@@ 709,6 709,26 @@ doctrine@^3.0.0:
dependencies:
esutils "^2.0.2"
+dotenv-cli@^7.2.1:
+ version "7.2.1"
+ resolved "https://registry.yarnpkg.com/dotenv-cli/-/dotenv-cli-7.2.1.tgz#e595afd9ebfb721df9da809a435b9aa966c92062"
+ integrity sha512-ODHbGTskqRtXAzZapDPvgNuDVQApu4oKX8lZW7Y0+9hKA6le1ZJlyRS687oU9FXjOVEDU/VFV6zI125HzhM1UQ==
+ dependencies:
+ cross-spawn "^7.0.3"
+ dotenv "^16.0.0"
+ dotenv-expand "^10.0.0"
+ minimist "^1.2.6"
+
+dotenv-expand@^10.0.0:
+ version "10.0.0"
+ resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-10.0.0.tgz#12605d00fb0af6d0a592e6558585784032e4ef37"
+ integrity sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==
+
+dotenv@^16.0.0, dotenv@^16.0.3:
+ version "16.0.3"
+ resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.3.tgz#115aec42bac5053db3c456db30cc243a5a836a07"
+ integrity sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==
+
end-of-stream@^1.1.0, end-of-stream@^1.4.1:
version "1.4.4"
resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0"