aboutsummaryrefslogtreecommitdiffstats
path: root/config/database.ts
diff options
context:
space:
mode:
Diffstat (limited to 'config/database.ts')
-rw-r--r--config/database.ts121
1 files changed, 121 insertions, 0 deletions
diff --git a/config/database.ts b/config/database.ts
new file mode 100644
index 0000000..65a9455
--- /dev/null
+++ b/config/database.ts
@@ -0,0 +1,121 @@
1/* eslint-disable @typescript-eslint/indent */
2/**
3 * Config source: https://git.io/JesV9
4 *
5 * Feel free to let us know via PR, if you find something broken in this config
6 * file.
7 */
8
9import path from 'node:path';
10import Env from '@ioc:Adonis/Core/Env';
11import { DatabaseConfig } from '@ioc:Adonis/Lucid/Database';
12
13const databaseConfig: DatabaseConfig = {
14 /*
15 |--------------------------------------------------------------------------
16 | Connection
17 |--------------------------------------------------------------------------
18 |
19 | The primary connection for making database queries across the application
20 | You can use any key from the `connections` object defined in this same
21 | file.
22 |
23 */
24 connection: Env.get('DB_CONNECTION', 'sqlite'),
25
26 connections: {
27 /*
28 |--------------------------------------------------------------------------
29 | SQLite
30 |--------------------------------------------------------------------------
31 |
32 | Configuration for the SQLite database. Make sure to install the driver
33 | from npm when using this connection
34 |
35 | npm i sqlite3
36 |
37 */
38 sqlite: {
39 client: 'sqlite',
40 connection: {
41 filename: path.join(
42 Env.get('DATA_DIR', 'data'),
43 `${Env.get('DB_DATABASE', 'ferdium')}.sqlite`,
44 ),
45 },
46 pool: {
47 afterCreate: (conn, cb) => {
48 conn.run('PRAGMA foreign_keys=true', cb);
49 },
50 },
51 migrations: {
52 naturalSort: true,
53 },
54 useNullAsDefault: true,
55 healthCheck: false,
56 debug: Env.get('DB_DEBUG', false),
57 },
58
59 /*
60 |--------------------------------------------------------------------------
61 | MySQL config
62 |--------------------------------------------------------------------------
63 |
64 | Configuration for MySQL database. Make sure to install the driver
65 | from npm when using this connection
66 |
67 | npm i mysql
68 |
69 */
70 mysql: {
71 client: 'mysql',
72 connection: {
73 host: Env.get('DB_HOST', 'localhost'),
74 port: Env.get('DB_PORT', ''),
75 user: Env.get('DB_USER', 'root'),
76 password: Env.get('DB_PASSWORD', ''),
77 database: Env.get('DB_DATABASE', 'ferdium'),
78 },
79 migrations: {
80 naturalSort: true,
81 },
82 healthCheck: false,
83 debug: Env.get('DB_DEBUG', false),
84 },
85
86 /*
87 |--------------------------------------------------------------------------
88 | PostgreSQL config
89 |--------------------------------------------------------------------------
90 |
91 | Configuration for PostgreSQL database. Make sure to install the driver
92 | from npm when using this connection
93 |
94 | npm i pg
95 |
96 */
97 pg: {
98 client: 'pg',
99 connection: {
100 host: Env.get('DB_HOST', 'localhost'),
101 port: Env.get('DB_PORT', ''),
102 user: Env.get('DB_USER', 'root'),
103 password: Env.get('DB_PASSWORD', ''),
104 database: Env.get('DB_DATABASE', 'ferdium'),
105 ssl: Env.get('DB_CA_CERT')
106 ? {
107 rejectUnauthorized: false,
108 ca: Env.get('DB_CA_CERT'),
109 }
110 : JSON.parse(Env.get('DB_SSL', 'true')),
111 },
112 migrations: {
113 naturalSort: true,
114 },
115 healthCheck: false,
116 debug: Env.get('DB_DEBUG', false),
117 },
118 },
119};
120
121export default databaseConfig;