Fix SQLAlchemy "index ix_users_email already exists" error in CI#12
Draft
Copilot wants to merge 6 commits into
Draft
Fix SQLAlchemy "index ix_users_email already exists" error in CI#12Copilot wants to merge 6 commits into
Copilot wants to merge 6 commits into
Conversation
❌ Deploy Preview for spectacular-strudel-d144b2 failed.
|
…ite and PostgreSQL Co-authored-by: Hellinferno <142572627+Hellinferno@users.noreply.github.com>
Co-authored-by: Hellinferno <142572627+Hellinferno@users.noreply.github.com>
Co-authored-by: Hellinferno <142572627+Hellinferno@users.noreply.github.com>
Co-authored-by: Hellinferno <142572627+Hellinferno@users.noreply.github.com>
…ation Co-authored-by: Hellinferno <142572627+Hellinferno@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix test suite to clean up database before running tests
Fix SQLAlchemy "index ix_users_email already exists" error in CI
Jan 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
CI test runs fail with
sqlalchemy.exc.OperationalError: index ix_users_email already existsbecause the PostgreSQL test database persists between runs. Indexes created in previous runs conflict with subsequentcreate_all()calls.Type of Change
Related Issues
Changes Made
tests/conftest.py (new)
pytest_sessionstart,pytest_sessionfinish) drop all tables before/after test sessions:memory:) to avoid overheadtests/test_database_integration.py
test_dbfixture now respectsDATABASE_URLenv var (PostgreSQL in CI, SQLite locally)drop_all()beforecreate_all()in fixture setup/teardownsrc/database.py
reset_db()utility for manual database reset with loggingTesting
Test Commands
Screenshots
N/A
Checklist
Additional Notes
The fix operates at two levels:
conftest.pyhooks ensure clean state between CI runstest_dbfixture ensures clean state between individual testsExample of the cleanup logic:
CodeQL security scan: 0 alerts
Deployment Notes
Reviewer Notes:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.