Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change(fastapi): refactor database ORM model definitions
We don't want to depend on the database to load up data about the models we define. We now leverage the existing `aurweb.schema` module for table definitions and set __table_args__["autoload"] to False. Signed-off-by: Kevin Morris <kevr@0cost.org>
- Loading branch information
Showing
31 changed files
with
210 additions
and
354 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,21 @@ | ||
from sqlalchemy import Column, Integer | ||
|
||
from aurweb import db | ||
from aurweb import schema | ||
from aurweb.models.declarative import Base | ||
|
||
DEPENDS = "depends" | ||
MAKEDEPENDS = "makedepends" | ||
CHECKDEPENDS = "checkdepends" | ||
OPTDEPENDS = "optdepends" | ||
|
||
DEPENDS_ID = 1 | ||
MAKEDEPENDS_ID = 2 | ||
CHECKDEPENDS_ID = 3 | ||
OPTDEPENDS_ID = 4 | ||
|
||
class DependencyType(Base): | ||
__tablename__ = "DependencyTypes" | ||
|
||
ID = Column(Integer, primary_key=True) | ||
|
||
__mapper_args__ = {"primary_key": [ID]} | ||
class DependencyType(Base): | ||
__table__ = schema.DependencyTypes | ||
__tablename__ = __table__.name | ||
__mapper_args__ = {"primary_key": [__table__.c.ID]} | ||
|
||
def __init__(self, Name: str = None): | ||
self.Name = Name | ||
|
||
|
||
DEPENDS_ID = db.query(DependencyType).filter( | ||
DependencyType.Name == DEPENDS).first().ID | ||
MAKEDEPENDS_ID = db.query(DependencyType).filter( | ||
DependencyType.Name == MAKEDEPENDS).first().ID | ||
CHECKDEPENDS_ID = db.query(DependencyType).filter( | ||
DependencyType.Name == CHECKDEPENDS).first().ID | ||
OPTDEPENDS_ID = db.query(DependencyType).filter( | ||
DependencyType.Name == OPTDEPENDS).first().ID |
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
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
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
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
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
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
Oops, something went wrong.