mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-17 07:45:24 +01:00
c8265a8d53
Default target version is 1.5.0 This is mainly for VIC-appliance upgrade, and should be considered experimental for oss due to limited test. Tested with 1.2 and 1.3 harbor.cfg from VIC appliance.
233 lines
9.3 KiB
Python
233 lines
9.3 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import sessionmaker, relationship
|
|
from sqlalchemy.dialects import mysql
|
|
|
|
|
|
Base = declarative_base()
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = 'user'
|
|
|
|
user_id = sa.Column(sa.Integer, primary_key=True)
|
|
username = sa.Column(sa.String(255), unique=True)
|
|
email = sa.Column(sa.String(255), unique=True)
|
|
password = sa.Column(sa.String(40), nullable=False)
|
|
realname = sa.Column(sa.String(255), nullable=False)
|
|
comment = sa.Column(sa.String(30))
|
|
deleted = sa.Column(sa.Integer, nullable=False, server_default=sa.text("'0'"))
|
|
reset_uuid = sa.Column(sa.String(40))
|
|
salt = sa.Column(sa.String(40))
|
|
sysadmin_flag = sa.Column(sa.Integer)
|
|
creation_time = sa.Column(mysql.TIMESTAMP)
|
|
update_time = sa.Column(mysql.TIMESTAMP)
|
|
|
|
|
|
class Properties(Base):
|
|
__tablename__ = 'properties'
|
|
|
|
id = sa.Column(sa.Integer, primary_key=True)
|
|
k = sa.Column(sa.String(64), unique=True)
|
|
v = sa.Column(sa.String(128), nullable = False)
|
|
|
|
|
|
class ProjectMember(Base):
|
|
__tablename__ = 'project_member'
|
|
|
|
project_id = sa.Column(sa.Integer(), primary_key = True)
|
|
user_id = sa.Column(sa.Integer(), primary_key = True)
|
|
role = sa.Column(sa.Integer(), nullable = False)
|
|
creation_time = sa.Column(mysql.TIMESTAMP, nullable = True)
|
|
update_time = sa.Column(mysql.TIMESTAMP, nullable = True)
|
|
sa.ForeignKeyConstraint(['project_id'], [u'project.project_id'], ),
|
|
sa.ForeignKeyConstraint(['role'], [u'role.role_id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], [u'user.user_id'], ),
|
|
|
|
|
|
class UserProjectRole(Base):
|
|
__tablename__ = 'user_project_role'
|
|
|
|
upr_id = sa.Column(sa.Integer(), primary_key = True)
|
|
user_id = sa.Column(sa.Integer(), sa.ForeignKey('user.user_id'))
|
|
pr_id = sa.Column(sa.Integer(), sa.ForeignKey('project_role.pr_id'))
|
|
project_role = relationship("ProjectRole")
|
|
|
|
|
|
class ProjectRole(Base):
|
|
__tablename__ = 'project_role'
|
|
|
|
pr_id = sa.Column(sa.Integer(), primary_key = True)
|
|
project_id = sa.Column(sa.Integer(), nullable = False)
|
|
role_id = sa.Column(sa.Integer(), nullable = False)
|
|
sa.ForeignKeyConstraint(['role_id'], [u'role.role_id'])
|
|
sa.ForeignKeyConstraint(['project_id'], [u'project.project_id'])
|
|
|
|
|
|
class Access(Base):
|
|
__tablename__ = 'access'
|
|
|
|
access_id = sa.Column(sa.Integer(), primary_key = True)
|
|
access_code = sa.Column(sa.String(1))
|
|
comment = sa.Column(sa.String(30))
|
|
|
|
|
|
class Role(Base):
|
|
__tablename__ = 'role'
|
|
|
|
role_id = sa.Column(sa.Integer, primary_key=True)
|
|
role_mask = sa.Column(sa.Integer, nullable=False, server_default=sa.text("'0'"))
|
|
role_code = sa.Column(sa.String(20))
|
|
name = sa.Column(sa.String(20))
|
|
|
|
|
|
class Project(Base):
|
|
__tablename__ = 'project'
|
|
|
|
project_id = sa.Column(sa.Integer, primary_key=True)
|
|
owner_id = sa.Column(sa.ForeignKey(u'user.user_id'), nullable=False, index=True)
|
|
name = sa.Column(sa.String(255), nullable=False, unique=True)
|
|
creation_time = sa.Column(mysql.TIMESTAMP)
|
|
update_time = sa.Column(mysql.TIMESTAMP)
|
|
deleted = sa.Column(sa.Integer, nullable=False, server_default=sa.text("'0'"))
|
|
owner = relationship(u'User')
|
|
|
|
|
|
class ProjectMetadata(Base):
|
|
__tablename__ = 'project_metadata'
|
|
|
|
id = sa.Column(sa.Integer, primary_key=True)
|
|
project_id = sa.Column(sa.ForeignKey(u'project.project_id'), nullable=False)
|
|
name = sa.Column(sa.String(255), nullable=False)
|
|
value = sa.Column(sa.String(255))
|
|
creation_time = sa.Column(mysql.TIMESTAMP, server_default=sa.text("CURRENT_TIMESTAMP"))
|
|
update_time = sa.Column(mysql.TIMESTAMP, server_default=sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
|
deleted = sa.Column(mysql.TINYINT(1), nullable=False, server_default='0')
|
|
|
|
__table_args__ = (sa.UniqueConstraint('project_id', 'name', name='unique_project_id_and_name'),)
|
|
|
|
|
|
class ReplicationPolicy(Base):
|
|
__tablename__ = "replication_policy"
|
|
|
|
id = sa.Column(sa.Integer, primary_key=True)
|
|
name = sa.Column(sa.String(256))
|
|
project_id = sa.Column(sa.Integer, nullable=False)
|
|
target_id = sa.Column(sa.Integer, nullable=False)
|
|
enabled = sa.Column(mysql.TINYINT(1), nullable=False, server_default=sa.text("'1'"))
|
|
description = sa.Column(sa.Text)
|
|
cron_str = sa.Column(sa.String(256))
|
|
filters = sa.Column(sa.String(1024))
|
|
replicate_deletion = sa.Column(mysql.TINYINT(1), nullable=False, server_default='0')
|
|
start_time = sa.Column(mysql.TIMESTAMP)
|
|
creation_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP"))
|
|
update_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
|
|
|
|
|
class ReplicationTarget(Base):
|
|
__tablename__ = "replication_target"
|
|
|
|
id = sa.Column(sa.Integer, primary_key=True)
|
|
name = sa.Column(sa.String(64))
|
|
url = sa.Column(sa.String(64))
|
|
username = sa.Column(sa.String(255))
|
|
password = sa.Column(sa.String(40))
|
|
target_type = sa.Column(mysql.TINYINT(1), nullable=False, server_default=sa.text("'0'"))
|
|
insecure = sa.Column(mysql.TINYINT(1), nullable=False, server_default='0')
|
|
creation_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP"))
|
|
update_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
|
|
|
|
|
class ReplicationJob(Base):
|
|
__tablename__ = "replication_job"
|
|
|
|
id = sa.Column(sa.Integer, primary_key=True)
|
|
status = sa.Column(sa.String(64), nullable=False)
|
|
policy_id = sa.Column(sa.Integer, nullable=False)
|
|
repository = sa.Column(sa.String(256), nullable=False)
|
|
operation = sa.Column(sa.String(64), nullable=False)
|
|
tags = sa.Column(sa.String(16384))
|
|
creation_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP"))
|
|
update_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
|
|
|
__table_args__ = (sa.Index('policy', 'policy_id'),)
|
|
|
|
|
|
class ReplicationImmediateTrigger(Base):
|
|
__tablename__ = 'replication_immediate_trigger'
|
|
|
|
id = sa.Column(sa.Integer, primary_key=True)
|
|
policy_id = sa.Column(sa.Integer, nullable=False)
|
|
namespace = sa.Column(sa.String(256), nullable=False)
|
|
on_push = sa.Column(mysql.TINYINT(1), nullable=False, server_default='0')
|
|
on_deletion = sa.Column(mysql.TINYINT(1), nullable=False, server_default='0')
|
|
creation_time = sa.Column(mysql.TIMESTAMP, server_default=sa.text("CURRENT_TIMESTAMP"))
|
|
update_time = sa.Column(mysql.TIMESTAMP, server_default=sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
|
|
|
|
|
class Repository(Base):
|
|
__tablename__ = "repository"
|
|
|
|
repository_id = sa.Column(sa.Integer, primary_key=True)
|
|
name = sa.Column(sa.String(255), nullable=False, unique=True)
|
|
project_id = sa.Column(sa.Integer, nullable=False)
|
|
owner_id = sa.Column(sa.Integer, nullable=False)
|
|
description = sa.Column(sa.Text)
|
|
pull_count = sa.Column(sa.Integer,server_default=sa.text("'0'"), nullable=False)
|
|
star_count = sa.Column(sa.Integer,server_default=sa.text("'0'"), nullable=False)
|
|
creation_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP"))
|
|
update_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
|
|
|
|
|
class AccessLog(Base):
|
|
__tablename__ = "access_log"
|
|
|
|
user_id = sa.Column(sa.Integer, nullable=False)
|
|
log_id = sa.Column(sa.Integer, primary_key=True)
|
|
username = sa.Column(sa.String(255), nullable=False)
|
|
project_id = sa.Column(sa.Integer, nullable=False)
|
|
repo_name = sa.Column(sa.String(256))
|
|
repo_tag = sa.Column(sa.String(128))
|
|
GUID = sa.Column(sa.String(64))
|
|
operation = sa.Column(sa.String(20))
|
|
op_time = sa.Column(mysql.TIMESTAMP)
|
|
update_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
|
|
|
__table_args__ = (sa.Index('project_id', "op_time"),)
|
|
|
|
|
|
class ImageScanJob(Base):
|
|
__tablename__ = "img_scan_job"
|
|
|
|
id = sa.Column(sa.Integer, nullable=False, primary_key=True)
|
|
status = sa.Column(sa.String(64), nullable=False)
|
|
repository = sa.Column(sa.String(256), nullable=False)
|
|
tag = sa.Column(sa.String(128), nullable=False)
|
|
digest = sa.Column(sa.String(128))
|
|
creation_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP"))
|
|
update_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
|
|
|
|
|
class ImageScanOverview(Base):
|
|
__tablename__ = "img_scan_overview"
|
|
|
|
id = sa.Column(sa.Integer, nullable=False, primary_key=True)
|
|
image_digest = sa.Column(sa.String(128), nullable=False)
|
|
scan_job_id = sa.Column(sa.Integer, nullable=False)
|
|
severity = sa.Column(sa.Integer, nullable=False, server_default=sa.text("'0'"))
|
|
components_overview = sa.Column(sa.String(2048))
|
|
details_key = sa.Column(sa.String(128))
|
|
creation_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP"))
|
|
update_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
|
|
|
|
|
class ClairVulnTimestamp(Base):
|
|
__tablename__ = "clair_vuln_timestamp"
|
|
|
|
id = sa.Column(sa.Integer, nullable=False, primary_key=True)
|
|
namespace = sa.Column(sa.String(128), nullable=False, unique=True)
|
|
last_update = sa.Column(mysql.TIMESTAMP)
|