Skip to content

test: add PostgreSQL schema smoke tests (#613)#916

Open
antharya05 wants to merge 1 commit into
imDarshanGK:mainfrom
antharya05:issue-613-schema-smoke-tests
Open

test: add PostgreSQL schema smoke tests (#613)#916
antharya05 wants to merge 1 commit into
imDarshanGK:mainfrom
antharya05:issue-613-schema-smoke-tests

Conversation

@antharya05
Copy link
Copy Markdown
Contributor

Description

This PR adds PostgreSQL-backed schema smoke tests to CI to validate database schema creation and common database operations against the same database engine used in production.

After auditing the repository, I found that the project currently manages schema creation through SQLAlchemy's Base.metadata.create_all() and does not use a migration framework such as Alembic or Prisma. Existing backend tests primarily run against SQLite, while production uses PostgreSQL 16.

This creates a gap where schema or constraint issues may pass CI but fail after deployment.

Changes made

  • Added a dedicated GitHub Actions workflow:

    • .github/workflows/schema-tests.yml
  • Added PostgreSQL schema smoke tests:

    • backend/tests/test_schema_smoke.py
  • Configured a PostgreSQL 16 service container in CI

  • Validated:

    • Database connectivity
    • Schema creation via Base.metadata.create_all()
    • Table existence
    • CRUD operations
    • UNIQUE constraint enforcement
    • Foreign key relationships
    • Cascade delete behavior
    • Shared snippet functionality
    • Digest subscription functionality
    • History database initialization
    • FTS5 search functionality
    • History record deletion

Why this change

The existing test suite validates database functionality using SQLite. Production deployments run on PostgreSQL 16, which may enforce constraints and schema rules differently.

These smoke tests help catch schema-related issues before deployment and reduce the risk of production database failures.

Related Issue

Fixes #613

Type of change

  • Bug fix
  • New feature / enhancement
  • Documentation update
  • Test addition
  • Refactor

Checklist

  • I have read CONTRIBUTING.md
  • My branch is up to date with main
  • I have run pytest -v and all tests pass
  • I have not introduced duplicate issues or features
  • My PR title follows the format: feat/fix/docs/test: short description
  • I have added tests for new features (Level 2 and 3 issues)
  • No hardcoded secrets or API keys in my code
  • This PR is linked to a GSSoC 2026 issue

Screenshots (if frontend change)

N/A

Test evidence

pytest -v

# Schema smoke tests passed successfully
# PostgreSQL schema validation completed
# All assertions passed

@antharya05 antharya05 requested a review from imDarshanGK as a code owner June 7, 2026 09:35
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.

Add schema migration tests to CI

1 participant