Skip to content

Commit ef8a9c1

Browse files
committed
chore: wip
1 parent ec660ff commit ef8a9c1

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

config/database.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ import type { DatabaseConfig } from '@stacksjs/types'
1111
export default {
1212
default: env.DB_CONNECTION || 'sqlite',
1313

14-
name: env.DB_DATABASE || 'stacks',
15-
1614
connections: {
15+
sqlite: {
16+
database: env.DB_DATABASE || 'stacks.sqlite',
17+
prefix: '',
18+
},
19+
1720
dynamodb: {
1821
key: env.AWS_ACCESS_KEY_ID || '',
1922
secret: env.AWS_SECRET_ACCESS_KEY || '',
@@ -30,11 +33,6 @@ export default {
3033
password: env.DB_PASSWORD || '',
3134
prefix: '',
3235
},
33-
34-
sqlite: {
35-
database: env.DB_DATABASE || 'stacks',
36-
prefix: '',
37-
},
3836
},
3937

4038
migrations: 'migrations',

storage/framework/core/config/src/defaults.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ export default {
122122
database: {
123123
default: 'sqlite',
124124

125-
name: 'stacks',
126-
127125
connections: {
128126
sqlite: {
129127
database: projectStoragePath('framework/database/stacks.sqlite'),
@@ -383,7 +381,7 @@ export default {
383381
},
384382

385383
searchEngine: {
386-
driver: 'meilisearch',
384+
driver: 'opensearch',
387385
},
388386

389387
security: {

storage/framework/core/database/src/kysely.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ColumnType, Generated } from 'kysely'
22
import { Kysely, MysqlDialect } from 'kysely'
33
import { BunWorkerDialect } from 'kysely-bun-worker'
44
import { createPool } from 'mysql2'
5+
import { config } from '@stacksjs/config'
56

67
// TODO: we need an action that auto-generates these table interfaces
78
export interface UsersTable {
@@ -36,18 +37,18 @@ const driver = config.database.default ?? 'sqlite'
3637
export function getDialect() {
3738
if (driver === 'sqlite') {
3839
return new BunWorkerDialect({
39-
url: 'stacks.sqlite',
40+
url: config.database.connections?.sqlite.database ?? 'stacks.sqlite',
4041
})
4142
}
4243

4344
if (driver === 'mysql') {
4445
return new MysqlDialect({
4546
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,
5152
}),
5253
})
5354
}

storage/framework/core/types/src/database.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
export interface DatabaseOptions {
22
default: string
33

4-
/**
5-
* The name of the database to use.
6-
* @default stacks
7-
*/
8-
name: string
9-
104
connections: {
115
mysql?: {
126
url?: string

0 commit comments

Comments
 (0)