prisma-safety
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -29,3 +29,3 @@ import { exec } from 'child_process'; | ||
const allIssues = []; | ||
const currentTables = tablesFromSchema(currentSchema); | ||
const currentModels = modelsFromSchema(currentSchema); | ||
const tableChanges = diffModels(previousSchema, currentSchema); | ||
@@ -46,3 +46,3 @@ allIssues.push(...tableChanges.deleted.flatMap((model) => { | ||
if (typeof field.fieldType === 'string') { | ||
if (currentTables.has(field.fieldType)) { | ||
if (currentModels.has(field.fieldType)) { | ||
return true; | ||
@@ -106,2 +106,11 @@ } | ||
} | ||
function modelsFromSchema(schema) { | ||
const models = new Map(); | ||
for (const block of schema.list) { | ||
if (block.type === 'model') { | ||
models.set(block.name, block); | ||
} | ||
} | ||
return models; | ||
} | ||
function diffModels(previousSchema, currentSchema) { | ||
@@ -108,0 +117,0 @@ const previousTables = tablesFromSchema(previousSchema); |
{ | ||
"name": "prisma-safety", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "A safe migration checker for Prisma.", | ||
@@ -43,3 +43,3 @@ "repository": { | ||
"@typescript-eslint/eslint-plugin": "^7.4.0", | ||
"@typescript-eslint/parser": "^7.5.0", | ||
"@typescript-eslint/parser": "^8.1.0", | ||
"eslint": "^8.46.0", | ||
@@ -46,0 +46,0 @@ "eslint-config-prettier": "^9.0.0", |
11703
213