Database
The developer documentation is still under construction and this page is not complete.
Viseron runs a PostgreSQL database to store all the data needed for the application.
The database runs within the container and is not exposed to the host machine.
You can point Viseron to an external database by setting the POSTGRES_DATABASE_URL environment variable.
See the storage component documentation for more information.
Models
The database models are defined in the viseron/components/storage/models.py file.
Migrations
The database is managed using alembic.
To create a new migration, you can run the following command:
cd viseron/components/storage
alembic revision --autogenerate -m "Your message here"
Using the VSCode Dev Container, you can run the Python: Generate database migration task to create a new migration.
Recreating the database
To recreate the database, you can run the following command:
python3 -u -m scripts.recreate_db