Skip to content

fix: Support SQLite in migration 0079_apitoken_data#2110

Closed
Om-A-osc wants to merge 1 commit into
aboutcode-org:mainfrom
Om-A-osc:fix/0079_apitoken_data.py
Closed

fix: Support SQLite in migration 0079_apitoken_data#2110
Om-A-osc wants to merge 1 commit into
aboutcode-org:mainfrom
Om-A-osc:fix/0079_apitoken_data.py

Conversation

@Om-A-osc
Copy link
Copy Markdown

Issues

  • Closes: N/A

Changes

  • Fixed a migration failure when using SQLite caused by a PostgreSQL-specific query.
  • Added a conditional check for the database backend and used the appropriate query for each.
  • Ensured that migrations run correctly for both PostgreSQL and SQLite setups.

The migration file scanpipe/migrations/0079_apitoken_data.py was checking if a table existed using PostgreSQL-specific syntax:

cursor.execute(
    "SELECT EXISTS (SELECT 1 FROM information_schema.tables "
    "WHERE table_name = 'authtoken_token')"
)

This syntax works for PostgreSQL but not for SQLite. SQLite uses a completely different system table called sqlite_master.

I updated the migration to detect which database is being used and use the correct SQL syntax for each:

Checklist

  • I have read the contributing guidelines
  • I have linked an existing issue above
  • I have added unit tests covering the new code
  • I have reviewed and understood every line of this PR

Signed-off-by: Om-A-osc <omanand8132@gmail.com>
@Om-A-osc Om-A-osc force-pushed the fix/0079_apitoken_data.py branch from d84593d to ba0ad2d Compare March 21, 2026 12:56
@Om-A-osc Om-A-osc closed this by deleting the head repository Mar 21, 2026
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.

1 participant