File tree Expand file tree Collapse file tree 4 files changed +13
-22
lines changed Expand file tree Collapse file tree 4 files changed +13
-22
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,12 @@ import type { DatabaseConfig } from '@stacksjs/types'
11
11
export default {
12
12
default : env . DB_CONNECTION || 'sqlite' ,
13
13
14
- name : env . DB_DATABASE || 'stacks' ,
15
-
16
14
connections : {
15
+ sqlite : {
16
+ database : env . DB_DATABASE || 'stacks.sqlite' ,
17
+ prefix : '' ,
18
+ } ,
19
+
17
20
dynamodb : {
18
21
key : env . AWS_ACCESS_KEY_ID || '' ,
19
22
secret : env . AWS_SECRET_ACCESS_KEY || '' ,
@@ -30,11 +33,6 @@ export default {
30
33
password : env . DB_PASSWORD || '' ,
31
34
prefix : '' ,
32
35
} ,
33
-
34
- sqlite : {
35
- database : env . DB_DATABASE || 'stacks' ,
36
- prefix : '' ,
37
- } ,
38
36
} ,
39
37
40
38
migrations : 'migrations' ,
Original file line number Diff line number Diff line change @@ -122,8 +122,6 @@ export default {
122
122
database : {
123
123
default : 'sqlite' ,
124
124
125
- name : 'stacks' ,
126
-
127
125
connections : {
128
126
sqlite : {
129
127
database : projectStoragePath ( 'framework/database/stacks.sqlite' ) ,
@@ -383,7 +381,7 @@ export default {
383
381
} ,
384
382
385
383
searchEngine : {
386
- driver : 'meilisearch ' ,
384
+ driver : 'opensearch ' ,
387
385
} ,
388
386
389
387
security : {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type { ColumnType, Generated } from 'kysely'
2
2
import { Kysely , MysqlDialect } from 'kysely'
3
3
import { BunWorkerDialect } from 'kysely-bun-worker'
4
4
import { createPool } from 'mysql2'
5
+ import { config } from '@stacksjs/config'
5
6
6
7
// TODO: we need an action that auto-generates these table interfaces
7
8
export interface UsersTable {
@@ -36,18 +37,18 @@ const driver = config.database.default ?? 'sqlite'
36
37
export function getDialect ( ) {
37
38
if ( driver === 'sqlite' ) {
38
39
return new BunWorkerDialect ( {
39
- url : 'stacks.sqlite' ,
40
+ url : config . database . connections ?. sqlite . database ?? 'stacks.sqlite' ,
40
41
} )
41
42
}
42
43
43
44
if ( driver === 'mysql' ) {
44
45
return new MysqlDialect ( {
45
46
pool : createPool ( {
46
- database : 'stacks' ,
47
- host : '127.0.0.1' ,
48
- user : 'root' ,
49
- password : '' ,
50
- port : 3306 ,
47
+ database : config . database . connections ?. mysql ?. name ?? 'stacks' ,
48
+ host : config . database . connections ?. mysql ?. host ?? '127.0.0.1' ,
49
+ user : config . database . connections ?. mysql ?. username ?? 'root' ,
50
+ password : config . database . connections ?. mysql ?. password ?? '' ,
51
+ port : config . database . connections ?. mysql ?. port ?? 3306 ,
51
52
} ) ,
52
53
} )
53
54
}
Original file line number Diff line number Diff line change 1
1
export interface DatabaseOptions {
2
2
default : string
3
3
4
- /**
5
- * The name of the database to use.
6
- * @default stacks
7
- */
8
- name : string
9
-
10
4
connections : {
11
5
mysql ?: {
12
6
url ?: string
You can’t perform that action at this time.
0 commit comments