aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-06-24 16:24:09 -0500
committerParker <contact@pkrm.dev>2024-06-24 16:24:09 -0500
commit5b92454760a8af14bd1031e72024946f868d1de6 (patch)
treef8384cbf0d142777d9bff341e13fd5882182908b /models.py
parent80a39d38bf829193c655a7320c86df2a3146db2a (diff)
Major overhaul + Bare bones web UI
Diffstat (limited to 'models.py')
-rw-r--r--models.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/models.py b/models.py
new file mode 100644
index 0000000..dad81a0
--- /dev/null
+++ b/models.py
@@ -0,0 +1,40 @@
+from sqlalchemy import (
+ Column,
+ ForeignKey,
+ Integer,
+ String,
+ Text,
+ DateTime,
+)
+
+from database import Base
+
+
+class User(Base):
+ __tablename__ = "users"
+ id = Column(Integer, primary_key=True)
+ username = Column(String, unique=True, nullable=False)
+ password = Column(Text, nullable=False)
+ api_key = Column(String(20), unique=True, nullable=False)
+
+
+class Link(Base):
+ __tablename__ = "links"
+ link = Column(String, primary_key=True)
+ owner = Column(Integer, ForeignKey("users.id"), nullable=False)
+ redirect_link = Column(String, nullable=False)
+ expire_date = Column(DateTime, nullable=False)
+
+
+class Record(Base):
+ __tablename__ = "records"
+ id = Column(Integer, primary_key=True)
+ owner = Column(Integer, ForeignKey("users.id"), nullable=False)
+ link = Column(String, ForeignKey("links.link"), nullable=False)
+ timestamp = Column(DateTime, nullable=False)
+ ip = Column(String, nullable=False)
+ location = Column(String, nullable=False)
+ browser = Column(String, nullable=False)
+ os = Column(String, nullable=False)
+ user_agent = Column(String, nullable=False)
+ isp = Column(String, nullable=False)