45 lines
1.9 KiB
Python
45 lines
1.9 KiB
Python
|
|
from datetime import datetime
|
|
from sqlalchemy import Column, BigInteger, Integer, String, ForeignKey, JSON, Boolean
|
|
from sqlalchemy.dialects.postgresql import TIMESTAMP
|
|
from sqlalchemy.orm import relationship
|
|
from app.core.models.base import BaseModel
|
|
|
|
|
|
class UserContent(BaseModel):
|
|
__tablename__ = 'users_content'
|
|
|
|
# Legacy compatibility fields
|
|
type = Column(String(128), nullable=False, default='license/listen')
|
|
onchain_address = Column(String(1024), nullable=True)
|
|
owner_address = Column(String(1024), nullable=True)
|
|
code_hash = Column(String(128), nullable=True)
|
|
data_hash = Column(String(128), nullable=True)
|
|
|
|
content_id = Column(String(36), ForeignKey('my_network_content.id'), nullable=True)
|
|
|
|
meta = Column(JSON, nullable=False, default=dict)
|
|
user_id = Column(String(36), ForeignKey('users.id'), nullable=False)
|
|
wallet_connection_id = Column(String(36), ForeignKey('wallet_connections.id'), nullable=True)
|
|
|
|
user = relationship('User', uselist=False, foreign_keys=[user_id])
|
|
wallet_connection = relationship('WalletConnection', uselist=False, foreign_keys=[wallet_connection_id])
|
|
content = relationship('StoredContent', uselist=False, foreign_keys=[content_id])
|
|
|
|
|
|
class UserAction(BaseModel):
|
|
__tablename__ = 'users_actions'
|
|
|
|
type = Column(String(128), nullable=False) # 'purchase'
|
|
user_id = Column(String(36), ForeignKey('users.id'), nullable=False)
|
|
content_id = Column(String(36), ForeignKey('my_network_content.id'), nullable=True)
|
|
telegram_message_id = Column(BigInteger, nullable=True)
|
|
|
|
to_address = Column(String(1024), nullable=True)
|
|
from_address = Column(String(1024), nullable=True)
|
|
meta = Column(JSON, nullable=False, default=dict)
|
|
|
|
user = relationship('User', uselist=False, foreign_keys=[user_id])
|
|
content = relationship('StoredContent', uselist=False, foreign_keys=[content_id])
|
|
|