Test Database Conventions
The *_test DSN guard and per-task scoped test databases.
Source: docs/dev/test-databases.md
Test Database Safety
v1 and v2 currently share the same VM but not the same database.
| Surface | URL | Database | Repo |
|---|---|---|---|
| v1 SciDEX | https://scidex.ai |
scidex |
/home/ubuntu/scidex |
| v2 Prism + Substrate | https://prism.scidex.ai |
scidex_v2 |
/home/ubuntu/scidex-prism, /home/ubuntu/scidex-substrate |
scidex and scidex_v2 are live databases. Do not run pytest, seeders,
migration smoke tests, cleanup scripts, or ad hoc destructive SQL against
either one.
Use an isolated test database whose name ends in _test:
createdb scidex_v2_test
SCIDEX_TEST_DSN=postgresql:///scidex_v2_test pytest tests/unit
Task-scoped names are fine as long as they keep the suffix, for example
scidex_v2_migration_abc123_test.
The root tests/conftest.py guard fails the whole pytest session if
SCIDEX_TEST_DSN or SCIDEX_DSN points at scidex, scidex_v2, or any
database without a _test suffix. SCIDEX_TEST_DSN_ALLOW_PROD is ignored.
Some tests intentionally use TRUNCATE, DROP TABLE, or DROP SCHEMA to
reset fixtures or verify migrations. They are only acceptable against isolated
test databases.
For v1-to-v2 ETL or migration work, use separate variables:
SCIDEX_V1_DSN=postgresql://<read-only-v1-role>@127.0.0.1:5432/scidex
SCIDEX_DSN=postgresql://<v2-role>@127.0.0.1:5432/scidex_v2
The v1 DSN must be read-only. v2 tests still need a _test target.