Conversation
Collaborator
|
this is interesting, i need the same for the tasks so i will review this soon and probaby extend, thank you for the idea! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a generic
attributescolumn to the machines table to store extra per-machine data — whether generic (e.g. last shutdown date) or machinery-specific (e.g. VNC connection details).The goal is to avoid changing the DB structure for every new field. Any data that doesn't warrant a dedicated column goes into this JSON bag as a key/value pair, so upstream, custom and extension implementations can all add fields without changing DB structure. This keeps the schema stable across releases and avoids the compatibility problems that frequent structural changes cause for downstream forks.
For optimisation the column is stored as real
jsonbon Postgres, with a fallback to plain JSON on other back-ends (SQLite/MySQL).Machine.attributesis a plain Pythondictbacked by a JSON/JSONB column. Changes are auto-tracked via SQLAlchemy's MutableDict — direct in-place mutation (machine.attributes["k"] = v) is fully supported.The helpers are still provided as convenience wrappers:
get_attribute(key)for safeNone-guard reads, andset_attribute(key, value)which also lazy-inits the dict and removes the key whenvalue=None.The column name
attributesis a proposal — it's a generic key/value bag, soproperties,extra,params, or similar name would work equally well. Open to maintainer preference :)