31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
"""
|
|
项目Git仓库模型
|
|
"""
|
|
from sqlalchemy import Column, BigInteger, String, Integer, DateTime, SmallInteger, ForeignKey
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from app.core.database import Base
|
|
|
|
|
|
class ProjectGitRepo(Base):
|
|
"""项目Git仓库表模型"""
|
|
|
|
__tablename__ = "project_git_repos"
|
|
|
|
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="ID")
|
|
project_id = Column(BigInteger, ForeignKey("projects.id", ondelete="CASCADE"), nullable=False, index=True, comment="项目ID")
|
|
name = Column(String(50), nullable=False, comment="仓库别名")
|
|
repo_url = Column(String(255), nullable=False, comment="Git仓库地址")
|
|
branch = Column(String(50), default="main", comment="Git分支")
|
|
username = Column(String(100), comment="Git用户名")
|
|
token = Column(String(255), comment="Git访问令牌/密码")
|
|
is_default = Column(SmallInteger, default=0, comment="是否默认仓库")
|
|
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
|
|
|
# 关系
|
|
# project = relationship("Project", back_populates="git_repos")
|
|
|
|
def __repr__(self):
|
|
return f"<ProjectGitRepo(id={self.id}, name='{self.name}', repo_url='{self.repo_url}')>"
|