Skip to content

Commit ed441a6

Browse files
authored
fix: check local migrations in tenantHasLocalMigrations() (#730)
1 parent 92acd27 commit ed441a6

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/internal/database/migrations/migrate.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,14 @@ export function startAsyncMigrations(signal: AbortSignal) {
8080
}
8181

8282
export async function tenantHasMigrations(tenantId: string, migration: keyof typeof DBMigration) {
83-
if (isMultitenant) {
84-
const { migrationVersion } = await getTenantConfig(tenantId)
85-
if (migrationVersion) {
86-
return DBMigration[migrationVersion] >= DBMigration[migration]
87-
}
83+
const migrationVersion = isMultitenant
84+
? (await getTenantConfig(tenantId)).migrationVersion
85+
: await lastLocalMigrationName()
8886

89-
return false
87+
if (migrationVersion) {
88+
return DBMigration[migrationVersion] >= DBMigration[migration]
9089
}
91-
92-
return true
90+
return false
9391
}
9492

9593
/**

src/internal/database/tenant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getConfig, JwksConfig, JwksConfigKey, JwksConfigKeyOCT } from '../../config'
2-
import { decrypt, verifyJWT } from '../auth'
2+
import { decrypt } from '../auth'
33
import { JWKSManager, JWKSManagerStoreKnex } from '../auth/jwks'
44
import { multitenantKnex } from './multitenant-db'
55
import { JWTPayload } from 'jose'

0 commit comments

Comments
 (0)