mirror of
https://github.com/saltbo/zpan.git
synced 2026-08-28 15:51:29 +08:00
fix: resolve coverage gap and migration filename collision
- Add getTableConfig FK reference tests to cover deferred .references() callbacks in schema.ts (fixes Codecov patch coverage < 94.98%) - Rename 0011_image-hosting → 0012_image-hosting to avoid filename collision with pre-existing 0011_notifications migration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -83,7 +83,7 @@
|
|||||||
"idx": 11,
|
"idx": 11,
|
||||||
"version": "6",
|
"version": "6",
|
||||||
"when": 1776749333797,
|
"when": 1776749333797,
|
||||||
"tag": "0011_image-hosting",
|
"tag": "0012_image-hosting",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { getTableConfig } from 'drizzle-orm/sqlite-core'
|
||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { apikey } from './auth-schema.js'
|
import { apikey } from './auth-schema.js'
|
||||||
import { imageHostingConfigs, imageHostings } from './schema.js'
|
import { imageHostingConfigs, imageHostings } from './schema.js'
|
||||||
@@ -40,6 +41,14 @@ describe('imageHostingConfigs table', () => {
|
|||||||
expect(imageHostingConfigs.createdAt.notNull).toBe(true)
|
expect(imageHostingConfigs.createdAt.notNull).toBe(true)
|
||||||
expect(imageHostingConfigs.updatedAt.notNull).toBe(true)
|
expect(imageHostingConfigs.updatedAt.notNull).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('org_id has a cascade-delete FK to organization', () => {
|
||||||
|
const { foreignKeys } = getTableConfig(imageHostingConfigs)
|
||||||
|
expect(foreignKeys).toHaveLength(1)
|
||||||
|
const ref = foreignKeys[0].reference()
|
||||||
|
expect(ref.foreignColumns).toHaveLength(1)
|
||||||
|
expect(ref.foreignColumns[0].name).toBe('id')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('imageHostings table', () => {
|
describe('imageHostings table', () => {
|
||||||
@@ -97,6 +106,17 @@ describe('imageHostings table', () => {
|
|||||||
it('has not-null created_at timestamp', () => {
|
it('has not-null created_at timestamp', () => {
|
||||||
expect(imageHostings.createdAt.notNull).toBe(true)
|
expect(imageHostings.createdAt.notNull).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('org_id and storage_id have cascade/no-action FKs', () => {
|
||||||
|
const { foreignKeys } = getTableConfig(imageHostings)
|
||||||
|
expect(foreignKeys).toHaveLength(2)
|
||||||
|
// Both FKs resolve to a single-column reference on 'id'
|
||||||
|
for (const fk of foreignKeys) {
|
||||||
|
const ref = fk.reference()
|
||||||
|
expect(ref.foreignColumns).toHaveLength(1)
|
||||||
|
expect(ref.foreignColumns[0].name).toBe('id')
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('apikey table', () => {
|
describe('apikey table', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user