Skip to content

Commit c5f6c16

Browse files
committed
chore: wip
1 parent 40c8766 commit c5f6c16

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
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)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export async function generateMigration(modelPath: string) {
101101
for (const [fieldName, options] of Object.entries(fields)) {
102102
const fieldOptions = options as FieldOptions
103103
const columnType = mapFieldTypeToColumnType(fieldOptions.validator?.rule)
104-
console.log('columnType', columnType)
105104
migrationContent += ` .addColumn('${fieldName}', '${columnType}'`
106105

107106
// Check if there are configurations that require the lambda function

storage/framework/core/enums/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export enum Action {
7878
Inspire = 'inspire',
7979
KeyGenerate = 'key-generate',
8080
MakeNotification = 'make-notification',
81-
Migrate = 'migrate',
81+
Migrate = 'migrate/database',
8282
MigrateDns = 'migrate/dns',
8383
Seed = 'seed',
8484
Lint = 'lint/index',

0 commit comments

Comments
 (0)