Skip to content

Detect database migration tool #6

@mvoutov

Description

@mvoutov

What

Add database migration tool detection to the scanner. When a repo uses Prisma, Drizzle, Alembic, Rails migrations, etc., report it in the scan results.

Why

Database tools are architecturally significant — they define the data model. Knowing "this project uses Prisma with 8 models" gives Claude important context for writing skills.

How

Edit src/lib/scanner.js. Add a detectDatabaseTools(repoPath) function that checks for these files:

Tool Detection Signal
Prisma prisma/schema.prisma
Drizzle drizzle.config.ts or drizzle.config.js or drizzle/ directory
TypeORM ormconfig.json or ormconfig.ts or ormconfig.js
Sequelize .sequelizerc or config/config.json with Sequelize patterns
Knex knexfile.js or knexfile.ts
Alembic alembic.ini and alembic/versions/ directory
Django migrations Any */migrations/ directory inside a directory containing models.py
ActiveRecord (Rails) db/migrate/ directory
Flyway db/migration/ with files matching V*.sql
golang-migrate migrations/ with files matching *.up.sql

All checks are existsSync() calls. For Prisma, you can optionally count models by grepping schema.prisma for lines matching ^model\s+\w+.

Implementation steps

  1. Add detectDatabaseTools(repoPath) to src/lib/scanner.js:

    function detectDatabaseTools(repoPath) {
      const detected = [];
      if (existsSync(join(repoPath, 'prisma', 'schema.prisma'))) {
        detected.push('prisma');
      }
      if (existsSync(join(repoPath, 'drizzle.config.ts')) ||
          existsSync(join(repoPath, 'drizzle.config.js'))) {
        detected.push('drizzle');
      }
      if (existsSync(join(repoPath, 'alembic.ini'))) {
        detected.push('alembic');
      }
      if (existsSync(join(repoPath, 'db', 'migrate'))) {
        detected.push('activerecord');
      }
      // ... etc
      return detected;
    }
  2. Call from scanRepo(): result.database = detectDatabaseTools(repoPath);

  3. Display in src/commands/scan.js:

    if (result.database && result.database.length > 0) {
      console.log(pc.cyan('  Database: ') + result.database.join(', '));
    }
  4. Add tests in tests/scanner.test.js:

    describe('database tool detection', () => {
      it('detects Prisma', () => {
        const dir = createFixture('db-prisma', {
          'prisma/schema.prisma': 'model User { id Int @id }',
        });
        const scan = scanRepo(dir);
        expect(scan.database).toContain('prisma');
      });
    
      it('detects Alembic', () => {
        const dir = createFixture('db-alembic', {
          'alembic.ini': '[alembic]',
        });
        const scan = scanRepo(dir);
        expect(scan.database).toContain('alembic');
      });
    });

Files to change

  • src/lib/scanner.js — add detectDatabaseTools(), call from scanRepo()
  • src/commands/scan.js — display in output
  • tests/scanner.test.js — add tests

Acceptance criteria

  • npm test passes
  • At least Prisma, Drizzle, Alembic, and ActiveRecord detected
  • aspens scan displays detected database tools

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions