mirror of
https://github.com/Donkie/Spoolman.git
synced 2026-10-21 17:42:16 -05:00
The validator fix only guards the write path. Instances that already hit #780 keep 500ing on GET /filament because the stored value exceeds the response model's max_length, and the UI can't repair what it can't list. Filament.from_db now strips the # and returns None when the stored value still isn't a valid 6/8 character code, so a single bad row no longer takes down the whole list. A migration chained from 415a8f855e14 rewrites existing rows one by one through op.get_bind() rather than with SQL string functions, so it behaves the same on sqlite, postgres, mysql and cockroachdb. downgrade() is a no-op.
Migrations
Migrations are used to create and update the database schema. They are run automatically every time Spoolman starts.
To create a new migration, edit the tables as desired in spoolman/database/models.py, then start the Spoolman server to update your local sqlite database.
pdm run python -m spoolman.main
Stop the server once it's up.
Then, let Alembic automatically create a new migration file:
pdm run alembic revision -m "some title" --autogenerate
Go into the created migration and make sure it looks good, that the column changes etc are as desired. Format it with Black and Ruff. Commit.