Skip to content

Commit 3f3cd4b

Browse files
committed
chore(starter-kits): expand database config templates with commented multi-driver options
1 parent eb2bd9a commit 3f3cd4b

File tree

5 files changed

+420
-42
lines changed

5 files changed

+420
-42
lines changed

api-monorepo/apps/backend/config/database.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ import app from '@adonisjs/core/services/app'
22
import { defineConfig } from '@adonisjs/lucid'
33

44
const dbConfig = defineConfig({
5+
/**
6+
* Default connection used for all queries.
7+
*/
58
connection: 'sqlite',
9+
610
connections: {
11+
/**
12+
* SQLite connection (default).
13+
*/
714
sqlite: {
815
client: 'better-sqlite3',
916
connection: {
@@ -19,6 +26,84 @@ const dbConfig = defineConfig({
1926
rulesPaths: ['./database/schema_rules.js'],
2027
},
2128
},
29+
30+
/**
31+
* PostgreSQL connection.
32+
* Install package to switch: npm install pg
33+
*/
34+
// pg: {
35+
// client: 'pg',
36+
// connection: {
37+
// host: process.env.PG_HOST,
38+
// port: Number(process.env.PG_PORT || 5432),
39+
// user: process.env.PG_USER,
40+
// password: process.env.PG_PASSWORD,
41+
// database: process.env.PG_DB_NAME,
42+
// },
43+
// migrations: {
44+
// naturalSort: true,
45+
// paths: ['database/migrations'],
46+
// },
47+
// debug: app.inDev,
48+
// },
49+
50+
/**
51+
* MySQL / MariaDB connection.
52+
* Install package to switch: npm install mysql2
53+
*/
54+
// mysql: {
55+
// client: 'mysql2',
56+
// connection: {
57+
// host: process.env.MYSQL_HOST,
58+
// port: Number(process.env.MYSQL_PORT || 3306),
59+
// user: process.env.MYSQL_USER,
60+
// password: process.env.MYSQL_PASSWORD,
61+
// database: process.env.MYSQL_DB_NAME,
62+
// },
63+
// migrations: {
64+
// naturalSort: true,
65+
// paths: ['database/migrations'],
66+
// },
67+
// debug: app.inDev,
68+
// },
69+
70+
/**
71+
* Microsoft SQL Server connection.
72+
* Install package to switch: npm install tedious
73+
*/
74+
// mssql: {
75+
// client: 'mssql',
76+
// connection: {
77+
// server: process.env.MSSQL_SERVER,
78+
// port: Number(process.env.MSSQL_PORT || 1433),
79+
// user: process.env.MSSQL_USER,
80+
// password: process.env.MSSQL_PASSWORD,
81+
// database: process.env.MSSQL_DB_NAME,
82+
// },
83+
// migrations: {
84+
// naturalSort: true,
85+
// paths: ['database/migrations'],
86+
// },
87+
// debug: app.inDev,
88+
// },
89+
90+
/**
91+
* libSQL (Turso) connection.
92+
* Install package to switch: npm install @libsql/client
93+
*/
94+
// libsql: {
95+
// client: 'libsql',
96+
// connection: {
97+
// url: process.env.LIBSQL_URL,
98+
// authToken: process.env.LIBSQL_AUTH_TOKEN,
99+
// },
100+
// useNullAsDefault: true,
101+
// migrations: {
102+
// naturalSort: true,
103+
// paths: ['database/migrations'],
104+
// },
105+
// debug: app.inDev,
106+
// },
22107
},
23108
})
24109

api/config/database.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ import app from '@adonisjs/core/services/app'
22
import { defineConfig } from '@adonisjs/lucid'
33

44
const dbConfig = defineConfig({
5+
/**
6+
* Default connection used for all queries.
7+
*/
58
connection: 'sqlite',
9+
610
connections: {
11+
/**
12+
* SQLite connection (default).
13+
*/
714
sqlite: {
815
client: 'better-sqlite3',
916
connection: {
@@ -19,6 +26,84 @@ const dbConfig = defineConfig({
1926
rulesPaths: ['./database/schema_rules.js'],
2027
},
2128
},
29+
30+
/**
31+
* PostgreSQL connection.
32+
* Install package to switch: npm install pg
33+
*/
34+
// pg: {
35+
// client: 'pg',
36+
// connection: {
37+
// host: process.env.PG_HOST,
38+
// port: Number(process.env.PG_PORT || 5432),
39+
// user: process.env.PG_USER,
40+
// password: process.env.PG_PASSWORD,
41+
// database: process.env.PG_DB_NAME,
42+
// },
43+
// migrations: {
44+
// naturalSort: true,
45+
// paths: ['database/migrations'],
46+
// },
47+
// debug: app.inDev,
48+
// },
49+
50+
/**
51+
* MySQL / MariaDB connection.
52+
* Install package to switch: npm install mysql2
53+
*/
54+
// mysql: {
55+
// client: 'mysql2',
56+
// connection: {
57+
// host: process.env.MYSQL_HOST,
58+
// port: Number(process.env.MYSQL_PORT || 3306),
59+
// user: process.env.MYSQL_USER,
60+
// password: process.env.MYSQL_PASSWORD,
61+
// database: process.env.MYSQL_DB_NAME,
62+
// },
63+
// migrations: {
64+
// naturalSort: true,
65+
// paths: ['database/migrations'],
66+
// },
67+
// debug: app.inDev,
68+
// },
69+
70+
/**
71+
* Microsoft SQL Server connection.
72+
* Install package to switch: npm install tedious
73+
*/
74+
// mssql: {
75+
// client: 'mssql',
76+
// connection: {
77+
// server: process.env.MSSQL_SERVER,
78+
// port: Number(process.env.MSSQL_PORT || 1433),
79+
// user: process.env.MSSQL_USER,
80+
// password: process.env.MSSQL_PASSWORD,
81+
// database: process.env.MSSQL_DB_NAME,
82+
// },
83+
// migrations: {
84+
// naturalSort: true,
85+
// paths: ['database/migrations'],
86+
// },
87+
// debug: app.inDev,
88+
// },
89+
90+
/**
91+
* libSQL (Turso) connection.
92+
* Install package to switch: npm install @libsql/client
93+
*/
94+
// libsql: {
95+
// client: 'libsql',
96+
// connection: {
97+
// url: process.env.LIBSQL_URL,
98+
// authToken: process.env.LIBSQL_AUTH_TOKEN,
99+
// },
100+
// useNullAsDefault: true,
101+
// migrations: {
102+
// naturalSort: true,
103+
// paths: ['database/migrations'],
104+
// },
105+
// debug: app.inDev,
106+
// },
22107
},
23108
})
24109

hypermedia/config/database.ts

Lines changed: 80 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,108 @@
11
import app from '@adonisjs/core/services/app'
22
import { defineConfig } from '@adonisjs/lucid'
33

4-
/**
5-
* Database configuration.
6-
* Defines database connections, query settings, and migration options.
7-
*/
84
const dbConfig = defineConfig({
95
/**
10-
* The default database connection to use for making queries.
6+
* Default connection used for all queries.
117
*/
128
connection: 'sqlite',
139

14-
/**
15-
* Pretty print SQL queries in development mode for easier debugging.
16-
*/
1710
prettyPrintDebugQueries: true,
1811

19-
/**
20-
* Available database connections.
21-
* Multiple connections can be configured for different databases.
22-
*/
2312
connections: {
2413
/**
25-
* SQLite connection configuration.
26-
* Uses better-sqlite3 driver for synchronous SQLite operations.
14+
* SQLite connection (default).
2715
*/
2816
sqlite: {
2917
client: 'better-sqlite3',
30-
31-
/**
32-
* SQLite database connection settings.
33-
*/
3418
connection: {
35-
/**
36-
* Path to the SQLite database file.
37-
* Stored in the tmp directory by default.
38-
*/
3919
filename: app.tmpPath('db.sqlite3'),
4020
},
41-
42-
/**
43-
* Use NULL as default value for undefined columns.
44-
* Required for SQLite compatibility.
45-
*/
4621
useNullAsDefault: true,
47-
48-
/**
49-
* Migration settings for this connection.
50-
*/
5122
migrations: {
52-
/**
53-
* Sort migration files in natural order (1, 2, 10 instead of 1, 10, 2).
54-
*/
5523
naturalSort: true,
56-
57-
/**
58-
* Directories where migration files are stored.
59-
*/
6024
paths: ['database/migrations'],
6125
},
62-
63-
/**
64-
* Enable SQL query debugging in development mode.
65-
*/
6626
debug: app.inDev,
6727
},
28+
29+
/**
30+
* PostgreSQL connection.
31+
* Install package to switch: npm install pg
32+
*/
33+
// pg: {
34+
// client: 'pg',
35+
// connection: {
36+
// host: process.env.PG_HOST,
37+
// port: Number(process.env.PG_PORT || 5432),
38+
// user: process.env.PG_USER,
39+
// password: process.env.PG_PASSWORD,
40+
// database: process.env.PG_DB_NAME,
41+
// },
42+
// migrations: {
43+
// naturalSort: true,
44+
// paths: ['database/migrations'],
45+
// },
46+
// debug: app.inDev,
47+
// },
48+
49+
/**
50+
* MySQL / MariaDB connection.
51+
* Install package to switch: npm install mysql2
52+
*/
53+
// mysql: {
54+
// client: 'mysql2',
55+
// connection: {
56+
// host: process.env.MYSQL_HOST,
57+
// port: Number(process.env.MYSQL_PORT || 3306),
58+
// user: process.env.MYSQL_USER,
59+
// password: process.env.MYSQL_PASSWORD,
60+
// database: process.env.MYSQL_DB_NAME,
61+
// },
62+
// migrations: {
63+
// naturalSort: true,
64+
// paths: ['database/migrations'],
65+
// },
66+
// debug: app.inDev,
67+
// },
68+
69+
/**
70+
* Microsoft SQL Server connection.
71+
* Install package to switch: npm install tedious
72+
*/
73+
// mssql: {
74+
// client: 'mssql',
75+
// connection: {
76+
// server: process.env.MSSQL_SERVER,
77+
// port: Number(process.env.MSSQL_PORT || 1433),
78+
// user: process.env.MSSQL_USER,
79+
// password: process.env.MSSQL_PASSWORD,
80+
// database: process.env.MSSQL_DB_NAME,
81+
// },
82+
// migrations: {
83+
// naturalSort: true,
84+
// paths: ['database/migrations'],
85+
// },
86+
// debug: app.inDev,
87+
// },
88+
89+
/**
90+
* libSQL (Turso) connection.
91+
* Install package to switch: npm install @libsql/client
92+
*/
93+
// libsql: {
94+
// client: 'libsql',
95+
// connection: {
96+
// url: process.env.LIBSQL_URL,
97+
// authToken: process.env.LIBSQL_AUTH_TOKEN,
98+
// },
99+
// useNullAsDefault: true,
100+
// migrations: {
101+
// naturalSort: true,
102+
// paths: ['database/migrations'],
103+
// },
104+
// debug: app.inDev,
105+
// },
68106
},
69107
})
70108

0 commit comments

Comments
 (0)