akarpov/redirect/db/models.py
Damir Modyarov 21c02df7f0
Implement short link redirect service (#180)
* Implement short link redirect service

* Silence linter where imports needs to be below setup

* Improve unknown link error

* Provide session to worker to convert it to user id

* Remove main entrypoint in favor of uvicorn command

* Add base path for relative URLs

* Add docs on launching redirect service to README.md

* Fix wrong task argument name

* Lint service code
2023-08-08 13:57:32 +03:00

19 lines
515 B
Python

from sqlalchemy import Boolean, Column, DateTime, Integer, String
from redirect.db import Base
class Link(Base):
"""Model of a short link that defines slug and target of a redirect."""
__tablename__ = "short_link"
id = Column(Integer, primary_key=True, index=True)
created = Column(DateTime)
modified = Column(DateTime)
source = Column(String)
slug = Column(String, index=True)
enabled = Column(Boolean)
viewed = Column(Integer)
creator_id = Column(Integer, index=True)