chore(root): adds src and test files#29
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #29 +/- ##
==========================================
- Coverage 87.72% 87.38% -0.35%
==========================================
Files 12 12
Lines 1491 1538 +47
==========================================
+ Hits 1308 1344 +36
- Misses 183 194 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
| Filename | Overview |
|---|---|
| src/migrations/index.ts | Major refactor: adds SQL parser with proper string/comment/dollar-quote awareness, MigrationHooks, MigrationsOptions, Prisma Migrate record compatibility helpers, and switches to $transaction. |
| src/migrations/locking.ts | Replaces per-DB advisory lock detection with a unified table-based lock; adds stale-lock TTL via clearStaleLock; non-conflict errors from tryAcquire are now re-thrown instead of silently returning false. |
| src/types.ts | Splits PrismaClient into PrismaMigrationClient (raw query methods + $executeRawUnsafe) and PrismaClient extends PrismaMigrationClient (adds $transaction, $disconnect). |
| src/cli/index.ts | Adds withPrismaClient helper (ensures $disconnect in finally), parseStepsOption for validated CLI step parsing, and loadRuntimeConfig closure that merges file-based log level with CLI flags. |
| src/config/schema.ts | Adds validated fields disableLocking, skipChecksumValidation, lockTimeout (with safe-integer + positive guard); removes the unused prismaClient field. |
| src/logger/index.ts | Adds isLogLevel guard; setLogLevel and the level setter now throw on invalid values instead of silently casting; env-var log level is also validated at startup. |
Sequence Diagram
sequenceDiagram
participant CLI
participant withPrismaClient
participant Migrations
participant MigrationLock
participant DB
CLI->>withPrismaClient: command (up/down/status...)
withPrismaClient->>DB: createPrismaClient()
withPrismaClient->>Migrations: new Migrations(client, config)
alt locking enabled
Migrations->>MigrationLock: withLock(fn, timeout)
MigrationLock->>DB: CREATE TABLE IF NOT EXISTS _prisma_migrations_lock
MigrationLock->>DB: DELETE stale rows (locked_at < threshold)
MigrationLock->>DB: INSERT INTO _prisma_migrations_lock (id=1)
Note over MigrationLock,DB: Retries every 1s until timeout
end
Migrations->>DB: SELECT id, migration_name FROM _prisma_migrations
Migrations->>Migrations: hooks.beforeUp/beforeDown
loop each migration
Migrations->>DB: $transaction(tx => ...)
DB->>DB: run migration SQL via tx.$executeRawUnsafe
DB->>DB: INSERT/DELETE _prisma_migrations row
end
Migrations->>Migrations: hooks.afterUp/afterDown
MigrationLock->>DB: DELETE FROM _prisma_migrations_lock
withPrismaClient->>DB: client.$disconnect()
Reviews (8): Last reviewed commit: "chore: adds locking update" | Re-trigger Greptile
|
@greptile review |
|
@greptile review |
|
@greptile review |
Description
Adds small code tweaks + tests
Type
Testing
npm test)npm run build)