aboutsummaryrefslogtreecommitdiffstats
path: root/config/database.ts
diff options
context:
space:
mode:
Diffstat (limited to 'config/database.ts')
-rw-r--r--config/database.ts54
1 files changed, 27 insertions, 27 deletions
diff --git a/config/database.ts b/config/database.ts
index 65a9455..d2db1c2 100644
--- a/config/database.ts
+++ b/config/database.ts
@@ -1,4 +1,3 @@
1/* eslint-disable @typescript-eslint/indent */
2/** 1/**
3 * Config source: https://git.io/JesV9 2 * Config source: https://git.io/JesV9
4 * 3 *
@@ -6,11 +5,12 @@
6 * file. 5 * file.
7 */ 6 */
8 7
9import path from 'node:path'; 8import path from 'node:path'
10import Env from '@ioc:Adonis/Core/Env'; 9import env from '#start/env'
11import { DatabaseConfig } from '@ioc:Adonis/Lucid/Database'; 10import { DatabaseConfig } from '@adonisjs/lucid/database'
11import { defineConfig } from '@adonisjs/lucid'
12 12
13const databaseConfig: DatabaseConfig = { 13const databaseConfig = defineConfig({
14 /* 14 /*
15 |-------------------------------------------------------------------------- 15 |--------------------------------------------------------------------------
16 | Connection 16 | Connection
@@ -21,7 +21,7 @@ const databaseConfig: DatabaseConfig = {
21 | file. 21 | file.
22 | 22 |
23 */ 23 */
24 connection: Env.get('DB_CONNECTION', 'sqlite'), 24 connection: env.get('DB_CONNECTION', 'sqlite'),
25 25
26 connections: { 26 connections: {
27 /* 27 /*
@@ -39,13 +39,13 @@ const databaseConfig: DatabaseConfig = {
39 client: 'sqlite', 39 client: 'sqlite',
40 connection: { 40 connection: {
41 filename: path.join( 41 filename: path.join(
42 Env.get('DATA_DIR', 'data'), 42 env.get('DATA_DIR', 'data'),
43 `${Env.get('DB_DATABASE', 'ferdium')}.sqlite`, 43 `${env.get('DB_DATABASE', 'ferdium')}.sqlite`
44 ), 44 ),
45 }, 45 },
46 pool: { 46 pool: {
47 afterCreate: (conn, cb) => { 47 afterCreate: (conn, cb) => {
48 conn.run('PRAGMA foreign_keys=true', cb); 48 conn.run('PRAGMA foreign_keys=true', cb)
49 }, 49 },
50 }, 50 },
51 migrations: { 51 migrations: {
@@ -53,7 +53,7 @@ const databaseConfig: DatabaseConfig = {
53 }, 53 },
54 useNullAsDefault: true, 54 useNullAsDefault: true,
55 healthCheck: false, 55 healthCheck: false,
56 debug: Env.get('DB_DEBUG', false), 56 debug: env.get('DB_DEBUG', false),
57 }, 57 },
58 58
59 /* 59 /*
@@ -70,17 +70,17 @@ const databaseConfig: DatabaseConfig = {
70 mysql: { 70 mysql: {
71 client: 'mysql', 71 client: 'mysql',
72 connection: { 72 connection: {
73 host: Env.get('DB_HOST', 'localhost'), 73 host: env.get('DB_HOST', 'localhost'),
74 port: Env.get('DB_PORT', ''), 74 port: env.get('DB_PORT', ''),
75 user: Env.get('DB_USER', 'root'), 75 user: env.get('DB_USER', 'root'),
76 password: Env.get('DB_PASSWORD', ''), 76 password: env.get('DB_PASSWORD', ''),
77 database: Env.get('DB_DATABASE', 'ferdium'), 77 database: env.get('DB_DATABASE', 'ferdium'),
78 }, 78 },
79 migrations: { 79 migrations: {
80 naturalSort: true, 80 naturalSort: true,
81 }, 81 },
82 healthCheck: false, 82 healthCheck: false,
83 debug: Env.get('DB_DEBUG', false), 83 debug: env.get('DB_DEBUG', false),
84 }, 84 },
85 85
86 /* 86 /*
@@ -97,25 +97,25 @@ const databaseConfig: DatabaseConfig = {
97 pg: { 97 pg: {
98 client: 'pg', 98 client: 'pg',
99 connection: { 99 connection: {
100 host: Env.get('DB_HOST', 'localhost'), 100 host: env.get('DB_HOST', 'localhost'),
101 port: Env.get('DB_PORT', ''), 101 port: env.get('DB_PORT', ''),
102 user: Env.get('DB_USER', 'root'), 102 user: env.get('DB_USER', 'root'),
103 password: Env.get('DB_PASSWORD', ''), 103 password: env.get('DB_PASSWORD', ''),
104 database: Env.get('DB_DATABASE', 'ferdium'), 104 database: env.get('DB_DATABASE', 'ferdium'),
105 ssl: Env.get('DB_CA_CERT') 105 ssl: env.get('DB_CA_CERT')
106 ? { 106 ? {
107 rejectUnauthorized: false, 107 rejectUnauthorized: false,
108 ca: Env.get('DB_CA_CERT'), 108 ca: env.get('DB_CA_CERT'),
109 } 109 }
110 : JSON.parse(Env.get('DB_SSL', 'true')), 110 : JSON.parse(env.get('DB_SSL', 'true')),
111 }, 111 },
112 migrations: { 112 migrations: {
113 naturalSort: true, 113 naturalSort: true,
114 }, 114 },
115 healthCheck: false, 115 healthCheck: false,
116 debug: Env.get('DB_DEBUG', false), 116 debug: env.get('DB_DEBUG', false),
117 }, 117 },
118 }, 118 },
119}; 119})
120 120
121export default databaseConfig; 121export default databaseConfig