slot_snapshot.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from sqlalchemy import Column, Integer, String, DateTime, Enum, JSON, Text
  2. from datetime import datetime
  3. from app.core.database import Base
  4. class VasSlotSnapshot(Base):
  5. __tablename__ = "vas_slot_snapshot"
  6. __ddl__ = """
  7. CREATE TABLE IF NOT EXISTS `vas_slot_snapshot` (
  8. `id` INT NOT NULL AUTO_INCREMENT,
  9. `country` VARCHAR(100) NOT NULL,
  10. `city` VARCHAR(100) NOT NULL,
  11. `visa_type` VARCHAR(100) NOT NULL,
  12. `routing_key` VARCHAR(255) NOT NULL,
  13. `availability_status` ENUM('None','Available','Waitlist') NOT NULL,
  14. `website` TEXT NOT NULL,
  15. `earliest_date` DATETIME NULL,
  16. `availability` JSON NOT NULL,
  17. `snapshot_source` ENUM('worker','manual','sync') NOT NULL,
  18. `snapshot_at` DATETIME NOT NULL,
  19. PRIMARY KEY (`id`),
  20. KEY `idx_vas_slot_snap_routing` (`routing_key`),
  21. KEY `idx_vas_slot_snap_snapshot_at` (`snapshot_at`)
  22. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='考位可用状态历史快照表';
  23. """
  24. id = Column(Integer, primary_key=True, autoincrement=True)
  25. country = Column(String(100), nullable=False)
  26. city = Column(String(100), nullable=False)
  27. visa_type = Column(String(100), nullable=False)
  28. routing_key = Column(String(255), nullable=False)
  29. availability_status = Column(
  30. Enum('None','Available','Waitlist'),
  31. nullable=False
  32. )
  33. website = Column(Text, nullable=False)
  34. earliest_date = Column(DateTime)
  35. availability = Column(JSON, nullable=False)
  36. snapshot_source = Column(Enum('worker','manual','sync'), nullable=False)
  37. snapshot_at = Column(DateTime, nullable=False)