5
5
* @copyright Jeremy Chaufourier <[email protected] >
6
6
*/
7
7
8
+ import type { ApplicationService } from '@adonisjs/core/types'
9
+ import type { InferConverters } from '../../src/types/config.js'
10
+
11
+ import { copyFile , mkdir } from 'node:fs/promises'
8
12
import { IgnitorFactory } from '@adonisjs/core/factories'
9
13
import { defineConfig as defineLucidConfig } from '@adonisjs/lucid'
10
14
import { defineConfig } from '../../src/define_config.js'
11
15
import { defineConfig as defineDriveConfig , services } from '@adonisjs/drive'
12
16
13
17
import { BASE_URL } from './index.js'
14
- import type { InferConverters } from '../../src/types/config.js'
15
18
16
19
const IMPORTER = ( filePath : string ) => {
17
20
if ( filePath . startsWith ( './' ) || filePath . startsWith ( '../' ) ) {
@@ -83,7 +86,7 @@ export async function createApp(options = {}) {
83
86
sqlite : {
84
87
client : 'better-sqlite3' ,
85
88
connection : {
86
- filename : new URL ( './db.sqlite' , BASE_URL ) . pathname ,
89
+ filename : new URL ( '.. /db.sqlite' , BASE_URL ) . pathname ,
87
90
} ,
88
91
} ,
89
92
} ,
@@ -100,14 +103,21 @@ export async function createApp(options = {}) {
100
103
await app . init ( )
101
104
await app . boot ( )
102
105
106
+ await mkdir ( app . migrationsPath ( ) , { recursive : true } )
107
+
108
+ await copyFile (
109
+ new URL ( '../fixtures/migrations/create_users_table.ts' , import . meta. url ) ,
110
+ app . migrationsPath ( 'create_users_table.ts' )
111
+ )
112
+
103
113
return app
104
114
}
105
115
106
- // export async function initializeDatabase(app: ApplicationService) {
107
- // const ace = await app.container.make('ace')
108
- // await ace.exec('migration:fresh', [])
109
- // await seedDatabase()
110
- // }
116
+ export async function initializeDatabase ( app : ApplicationService ) {
117
+ const ace = await app . container . make ( 'ace' )
118
+ await ace . exec ( 'migration:fresh' , [ ] )
119
+ // await seedDatabase()
120
+ }
111
121
112
122
// async function seedDatabase() {
113
123
// const { default: User } = await import('./fixtures/models/user.js')
0 commit comments