Skip to content
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

Add defaults to models with DB defaults set #796

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions database/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from helpers.config import should_write_data_to_storage_config_check


class User(CodecovBaseModel):
class User(CodecovBaseModel, MixinBaseClass):
__tablename__ = "users"
id_ = Column("id", types.BigInteger, primary_key=True)

Expand Down Expand Up @@ -136,7 +136,7 @@ class Repository(CodecovBaseModel):
updatestamp = Column(types.DateTime)
yaml = Column(postgresql.JSON)
deleted = Column(types.Boolean, nullable=False, default=False)
branch = Column(types.Text)
branch = Column(types.Text, default="main")
image_token = Column(
types.Text,
default=lambda: "".join(
Expand Down Expand Up @@ -184,7 +184,7 @@ class GithubAppInstallation(CodecovBaseModel, MixinBaseClass):
# replacement for owner.integration_id
# installation id GitHub sends us in the installation-related webhook events
installation_id = Column(types.Integer, server_default=FetchedValue())
name = Column(types.Text, server_default=FetchedValue())
name = Column(types.Text, default=GITHUB_APP_INSTALLATION_DEFAULT_NAME)
# if null, all repos are covered by this installation
# otherwise, it's a list of repo.id values
repository_service_ids = Column(
Expand All @@ -199,7 +199,7 @@ class GithubAppInstallation(CodecovBaseModel, MixinBaseClass):
Owner, foreign_keys=[ownerid], back_populates="github_app_installations"
)

is_suspended = Column(types.Boolean, server_default=FetchedValue())
is_suspended = Column(types.Boolean, default=False)

def repository_queryset(self, dbsession: Session):
"""Returns a query set of repositories covered by this installation"""
Expand Down Expand Up @@ -364,7 +364,7 @@ class Branch(CodecovBaseModel):
__tablename__ = "branches"

repoid = Column(types.Integer, ForeignKey("repos.repoid"), primary_key=True)
updatestamp = Column(types.DateTime)
updatestamp = Column(types.DateTime, default=datetime.now)
branch = Column(types.Text, nullable=False, primary_key=True)
base = Column(types.Text)
head = Column(types.Text, nullable=False)
Expand Down
Loading