-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New model definitions for version 2 API #64
Merged
Merged
Conversation
This file contains 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
The organizations table is the basis of a multi-tenant installation.
These models allow us to create tags that have a many-to-many relationship with Products (via the ProductTags association). Tags are sequestered within an organization.
It should be the function rather than a constructed instance of datetime which would effectively be the time when the app started up. In practice, this default was overriden by the POST or PATCH handlers.
This model stores references to dashboard templates. These templates are owned by an organization.
This relationship is currently nullable during the migration, but can be changed to non-nullable later.
This column will replace Build.git_refs, where in practice we never use the multiple ref feature.
This allows us to identify who uploaded a build.
This enumeration column allows us to classify the edition's kind, which is useful information for edition dashboards.
Use the version from flask-sqlalchemy rather than the one directly from sqlalchemy for consistency.
This removes the ForeignKeyConstraint in the most complex version of https://docs.sqlalchemy.org/en/13/orm/relationship_persistence.html#rows-that-point-to-themselves-mutually-dependent-rows which was causing us trouble.
jonathansick
force-pushed
the
u/jsickcodes/v2-tables
branch
from
June 26, 2021 23:20
72ed0f0
to
f016ab4
Compare
This seems to be a better way to handle compound unique constraints?
jonathansick
force-pushed
the
u/jsickcodes/v2-tables
branch
from
July 5, 2021 15:01
2449f10
to
ef54fa5
Compare
This is based on https://michaelcho.me/article/using-python-enums-in-sqlalchemy-models The idea is that the native enum support will store the string value in the database. It's easier in fact to just store the integer to the DB and handle the enum at the Python level.
jonathansick
force-pushed
the
u/jsickcodes/v2-tables
branch
from
July 5, 2021 20:28
666d153
to
a6b54e2
Compare
This is necessary for the initial database migration, but can be reset to be non-nullable once the content can be update.
This lets us run the dev server at the same time as running tox.
jonathansick
force-pushed
the
u/jsickcodes/v2-tables
branch
from
July 6, 2021 17:12
4dd0646
to
71ecee5
Compare
In the migration, apply a default value then make the column non-nullable.
We do this by creating a default organization during the migration and then updating all products to associate with that default organization.
To fall back to the original LTD API, the new_product() handler gets teh first organization, which is the default organization created by the DB migration for the v2 tables. New installations of LTD, therefore, should use the v2 API in order to use the organizations feature.
This matches how the v2 table migration automatically associates a default organization with existing products, but otherwise the organization feature isn't exposed by the v1 API.
Structlog requires text for the event now.
This order of type checking is correct because InEnum is a subclass of int.
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.
This PR contains revised SQLAlchemy models to power the new version 2 features of LTD Keeper.
These models are currently backwards compatible to aid adoption in current deployments.
New models include:
Organization
(to power multi-tenant installations)Tag
(tags are associated with products using theproducttags
association table)DashboardTemplate
model to power template-based customization of version dashboards.