Skip to content

Commit cbca2ac

Browse files
committed
chore: wip
1 parent 05e0072 commit cbca2ac

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

app/Models/Post.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default {
1515
count: 10,
1616
},
1717
},
18+
1819
attributes: {
1920
title: {
2021
validator: {
@@ -24,6 +25,7 @@ export default {
2425

2526
factory: () => faker.datatype.string(),
2627
},
28+
2729
body: {
2830
validator: {
2931
rule: schema.string(),

storage/framework/core/actions/src/database/mysql.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ export async function generateMysqlMigration(modelPath: string) {
125125
else await createTableMigration(modelPath)
126126
}
127127

128-
129-
130128
async function getRelations(model: ModelDefault): Promise<RelationConfig[]> {
131129
const relationsArray = ['hasOne', 'belongsTo', 'hasMany', 'belongsToMany', 'hasOneThrough']
132130

@@ -192,7 +190,7 @@ async function createTableMigration(modelPath: string) {
192190

193191
const model = await import(modelPath)
194192
const tableName = model.default.table
195-
193+
196194
await createPivotTableMigration(model)
197195

198196
const fields = model.default.attributes
@@ -278,7 +276,6 @@ async function createPivotTableMigration(model: ModelDefault) {
278276
async function createForeignKeysMigration(model: ModelDefault) {
279277
const relations = await getRelations(model)
280278

281-
282279
for (const relation of relations) {
283280
let migrationContent = `import type { Database } from '@stacksjs/database'\n`
284281
migrationContent += `export async function up(db: Database<any>) {\n`

storage/framework/core/actions/src/migrate/database.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ if (result?.isErr()) {
1313

1414
const result2 = await runDatabaseMigration()
1515

16-
1716
if (result2.isErr()) {
1817
log.error('runDatabaseMigration failed')
1918
log.error(result2.error)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { Kysely as Database } from 'kysely'
22

3-
export { sql } from 'kysely'
3+
export { sql } from 'kysely'

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,17 @@ export interface Attributes {
118118

119119
export type Model = Partial<ModelOptions>
120120

121-
122121
export interface ModelDefault {
123122
default: ModelOptions
124123
}
125124

126125
export interface RelationConfig {
127-
relationship: string;
128-
model: string;
129-
table: string;
130-
foreignKey: string;
131-
relationName: string;
132-
throughModel: string;
133-
throughForeignKey: string;
134-
pivotTable: string;
135-
}
126+
relationship: string
127+
model: string
128+
table: string
129+
foreignKey: string
130+
relationName: string
131+
throughModel: string
132+
throughForeignKey: string
133+
pivotTable: string
134+
}

0 commit comments

Comments
 (0)