-
Notifications
You must be signed in to change notification settings - Fork 2
Making migrations #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jdavid10001 <jdavid10001@gmail.com>
…the files payload
There was a problem hiding this 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.
There was a problem hiding this 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) |
There was a problem hiding this comment.
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).
| } | ||
| ` | ||
|
|
||
| writeFileSync(migrationPath, migrationTemplate, 'utf-8') |
There was a problem hiding this comment.
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.
There was a problem hiding this 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') |
There was a problem hiding this comment.
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.
| 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}` |
There was a problem hiding this comment.
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.
Note
Adds migration tooling and adopts migration-driven schema changes
vectorize:migrateCLI patches/creates migrations to manage IVFFLAT indexes and detectdims/ivfflatListschanges (rebuild index or destructive dims change with truncate)ensurePgvectorArtifactsnow verifies presence only (extension/column/index) and throws if missing; migrations are the source of truthbinand exposes_staticConfigsonVectorizedPayloadfor migration helper accessTests and tooling
initializePayloadWithMigrationsandcreateTestMigrationsDir; passmigrationDirandpush:falsemigrationCli.spec.tscovers CLI behavior, idempotency, schema-name qualification, and runtime checkstest:intadds tsx; lockfile updated)Docs
dims/ivfflatLists, development workflow, idempotency, and runtime behavior notesWritten by Cursor Bugbot for commit 2c8238a. This will update automatically on new commits. Configure here.