Skip to content

Conversation

@techiejd
Copy link
Owner

@techiejd techiejd commented Jan 16, 2026

Note

Adds migration tooling and adopts migration-driven schema changes

  • New vectorize:migrate CLI patches/creates migrations to manage IVFFLAT indexes and detect dims/ivfflatLists changes (rebuild index or destructive dims change with truncate)
  • ensurePgvectorArtifacts now verifies presence only (extension/column/index) and throws if missing; migrations are the source of truth
  • Registers CLI via plugin bin and exposes _staticConfigs on VectorizedPayload for migration helper access

Tests and tooling

  • Large refactor of specs to run against real migrations: add initializePayloadWithMigrations and createTestMigrationsDir; pass migrationDir and push:false
  • New migrationCli.spec.ts covers CLI behavior, idempotency, schema-name qualification, and runtime checks
  • Update scripts/deps (test:int adds tsx; lockfile updated)

Docs

  • README: add initial migration setup, guidance for changing dims/ivfflatLists, development workflow, idempotency, and runtime behavior notes

Written by Cursor Bugbot for commit 2c8238a. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on February 14

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 4 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

}
postgresPayload.logger.info('[payloadcms-vectorize] pgvector extension/columns/index ensured')
if (postgresPayload.db.drizzle?.execute) {
return postgresPayload.db.drizzle.execute(sql)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drizzle fallback path ignores query parameters

Medium Severity

The runQuery helper function accepts a params parameter and correctly passes it to pool.query, but the drizzle fallback path at line 117 ignores params entirely, calling drizzle.execute(sql) without the parameters. This causes failure when queries with $1, $2, $3 placeholders are executed via the drizzle path (used for column check at line 145 and index check at line 169).

Fix in Cursor Fix in Web

}
`

writeFileSync(migrationPath, migrationTemplate, 'utf-8')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing directory creation before writing migration file

Medium Severity

When creating a migration file manually for index-only changes (the else branch at line 538), the code calls writeFileSync at line 570 without ensuring the migrations directory exists first. If migrationsDir doesn't exist, this throws an ENOENT: no such file or directory error, crashing the CLI.

Fix in Cursor Fix in Web

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

`[payloadcms-vectorize] payloadcmsVectorize: Vector search endpoint registered at "${path}"`,
)
} else {
console.log('[payloadcms-vectorize] payloadcmsVectorize: Vector search endpoint disabled')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statements in production plugin code

Medium Severity

Numerous console.log statements were added throughout the plugin initialization code in src/index.ts. These appear to be debug/development logging statements that will pollute the console output for anyone using this plugin in production. The plugin already has proper logging via payload.logger in the onInit hook and ensurePgvectorArtifacts function, but these new console.log calls occur during config building before a logger is available.

Fix in Cursor Fix in Web

if (lastFileBrace !== -1) {
const beforeLastBrace = newContent.substring(0, lastFileBrace)
const afterLastBrace = newContent.substring(lastFileBrace)
const downFunctionCode = `\n\nexport async function down({ payload, req }: { payload: any; req: any }): Promise<void> {\n${vectorDownCode.join('\n')}\n}`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated down function missing db parameter causes runtime error

High Severity

When a migration file doesn't have a down function, the code generates one with the signature { payload, req } but the inserted code references db.execute(sql.raw(...)). The db parameter is missing from the function signature, causing a ReferenceError: db is not defined when the down migration runs. Functions like generateIvfflatRebuildCode and generateColumnTypeChangeCode all produce code using db.execute(), but the generated down function doesn't have access to db.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants