File size: 1,413 Bytes
551658a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
from sqlalchemy.sql import text
from database import Base

class ProductCertification(Base):
    __tablename__ = "product_certifications"
    
    id = Column(Integer, primary_key=True, index=True, comment='主键 ID')
    product_id = Column(Integer, ForeignKey('products.id'), nullable=True, index=True, comment='产品 ID(外键)')
    product_number = Column(String(11), nullable=False, server_default="", index=True, comment='产品货号')
    certification_type = Column(String(50), nullable=False, server_default="", index=True, comment='认证类型:CE, FDA, RoHS, FCC, ISO, OTHER')
    r2_url = Column(String(500), nullable=False, server_default="", comment='认证文件 URL(R2 URL)')
    thumbnail_r2_url = Column(String(500), nullable=False, server_default="", comment='认证缩略图路径(R2 URL)')
    media_id = Column(String(32), nullable=False, server_default="", comment='素材ID')
    company_code = Column(String(50), nullable=False, server_default="", index=True, comment='公司编码,用于数据隔离')
    created_at = Column(DateTime(timezone=True), nullable=False, server_default=text('CURRENT_TIMESTAMP'), comment='创建时间')
    updated_at = Column(DateTime(timezone=True), nullable=False, server_default=text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), comment='更新时间')