23 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
from sqlalchemy import Integer, Column, String, Boolean
 | 
						|
from sqlalchemy.orm import relationship
 | 
						|
 | 
						|
from models import BaseModel
 | 
						|
 | 
						|
 | 
						|
class BarcodeTemplateAttribute(BaseModel):
 | 
						|
    __tablename__ = 'barcode_template_attributes'
 | 
						|
    id = Column(Integer, autoincrement=True, primary_key=True, index=True)
 | 
						|
    name = Column(String, nullable=False, index=True, comment='Название атрибута')
 | 
						|
    label = Column(String, nullable=False, index=True, comment='Метка атрибута')
 | 
						|
 | 
						|
 | 
						|
class BarcodeTemplate(BaseModel):
 | 
						|
    __tablename__ = 'barcode_templates'
 | 
						|
    id = Column(Integer, autoincrement=True, primary_key=True, index=True)
 | 
						|
    name = Column(String, nullable=False, index=True, comment='Название шаблона')
 | 
						|
    attributes = relationship('BarcodeTemplateAttributeLink',
 | 
						|
                              back_populates='barcode_template',
 | 
						|
                              cascade="all, delete-orphan",
 | 
						|
                              lazy='joined')
 | 
						|
    is_default = Column(Boolean, nullable=False, default=False, comment='По умолчанию')
 |