File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 1
- // wip
1
+ import process from 'node:process'
2
+ import { generateMigrations , runDatabaseMigration } from '@stacksjs/database'
3
+ import { path } from '@stacksjs/path'
4
+ import { glob } from '@stacksjs/storage'
5
+
6
+ // if no migrations, generate them
7
+ const migrations = glob . sync ( path . userMigrationsPath ( '*.ts' ) )
8
+ if ( migrations . length === 0 )
9
+ await generateMigrations ( )
10
+
11
+ const result = await runDatabaseMigration ( )
12
+
13
+ if ( result . isErr ( ) ) {
14
+ console . error ( 'Migration failed:' , result . error )
15
+ process . exit ( 1 )
16
+ }
17
+
18
+ process . exit ( 0 )
Original file line number Diff line number Diff line change @@ -101,7 +101,6 @@ export async function generateMigration(modelPath: string) {
101
101
for ( const [ fieldName , options ] of Object . entries ( fields ) ) {
102
102
const fieldOptions = options as FieldOptions
103
103
const columnType = mapFieldTypeToColumnType ( fieldOptions . validator ?. rule )
104
- console . log ( 'columnType' , columnType )
105
104
migrationContent += ` .addColumn('${ fieldName } ', '${ columnType } '`
106
105
107
106
// Check if there are configurations that require the lambda function
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ export enum Action {
78
78
Inspire = 'inspire' ,
79
79
KeyGenerate = 'key-generate' ,
80
80
MakeNotification = 'make-notification' ,
81
- Migrate = 'migrate' ,
81
+ Migrate = 'migrate/database ' ,
82
82
MigrateDns = 'migrate/dns' ,
83
83
Seed = 'seed' ,
84
84
Lint = 'lint/index' ,
You can’t perform that action at this time.
0 commit comments