mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
This change utilizes pytest-xdist to perform a multiproc test run and reworks aurweb.db's code. We no longer use a global engine, session or Session, but we now use a memo of engines and sessions as they are requested, based on the PYTEST_CURRENT_TEST environment variable, which is available during testing. Additionally, this change strips several SQLite components out of the Python code-base. SQLite is still compatible with PHP and sharness tests, but not with our FastAPI implementation. More changes: ------------ - Remove use of aurweb.db.session global in other code. - Use new aurweb.db.name() dynamic db name function in env.py. - Added 'addopts' to pytest.ini which utilizes multiprocessing. - Highly recommended to leave this be or modify `-n auto` to `-n {cpu_threads}` where cpu_threads is at least 2. Signed-off-by: Kevin Morris <kevr@0cost.org> |
||
---|---|---|
.. | ||
versions | ||
env.py | ||
README | ||
script.py.mako |
This directory contains Alembic's environment for managing database migrations. From Alembic's documentation: Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python. https://alembic.sqlalchemy.org/en/latest/index.html Upgrading to the latest version ------------------------------- Simply run `alembic upgrade head` from aurweb's root. Creating new migrations ----------------------- When working with Alembic and SQLAlchemy, you should never edit the database schema manually. Please proceed like this instead: 1. Edit `aurweb/schema.py` to your liking. 2. Run `alembic revision --autogenerate -m "your message"` 3. Proofread the generated migration. 4. Run `alembic upgrade head` to apply the changes to the database. 5. Commit the new migration. To revert a migration, you may run `alembic downgrade -1` and then manually delete the migration file. Note that SQLite is limited and that it's sometimes easier to recreate the database. For anything more complicated, please read Alembic's documentation. Troubleshooting --------------- - `ModuleNotFoundError: No module named 'aurweb'` You may either install the aurweb module with pip, or set PYTHONPATH to your aurweb repository. Since alembic must be run from the aurweb root, you may simply use: `PYTHONPATH=. alembic [...]`. - `FAILED: No config file 'alembic.ini' found, or file has no '[alembic]' section` You need to run Alembic from the project's root, and not from `migrations/`. - `configparser.NoSectionError: No section: 'database'` You need to set AUR_CONFIG, as explained in `TESTING`.