gitscope
https://dev.kronoz.win/r/marzneshin.git
app/db/models.py · v0.3.1
Source
1 a47eb4c Dawsh 2y ago import os
2 a47eb4c Dawsh 2y ago from datetime import datetime
3 a47eb4c Dawsh 2y ago
4 cba9caa Dawsh 2y ago import sqlalchemy.sql
5 01cdf2e Dawsh 2y ago from sqlalchemy import (
6 01cdf2e Dawsh 2y ago BigInteger,
7 01cdf2e Dawsh 2y ago Boolean,
8 01cdf2e Dawsh 2y ago Column,
9 01cdf2e Dawsh 2y ago DateTime,
10 01cdf2e Dawsh 2y ago Enum,
11 01cdf2e Dawsh 2y ago Float,
12 01cdf2e Dawsh 2y ago ForeignKey,
13 01cdf2e Dawsh 2y ago Integer,
14 01cdf2e Dawsh 2y ago String,
15 01cdf2e Dawsh 2y ago Table,
16 01cdf2e Dawsh 2y ago UniqueConstraint,
17 0b152b5 Mrdn 2y ago JSON,
18 d377c4c Dawsh 2y ago and_,
19 d377c4c Dawsh 2y ago func,
20 01cdf2e Dawsh 2y ago )
21 d377c4c Dawsh 2y ago from sqlalchemy.ext.hybrid import hybrid_property
22 a47eb4c Dawsh 2y ago from sqlalchemy.orm import relationship
23 a47eb4c Dawsh 2y ago from sqlalchemy.sql.expression import text
24 a47eb4c Dawsh 2y ago
25 a47eb4c Dawsh 2y ago from app.db.base import Base
26 a47eb4c Dawsh 2y ago from app.models.node import NodeStatus
27 01cdf2e Dawsh 2y ago from app.models.proxy import (
28 01cdf2e Dawsh 2y ago InboundHostALPN,
29 01cdf2e Dawsh 2y ago InboundHostFingerprint,
30 01cdf2e Dawsh 2y ago InboundHostSecurity,
31 01cdf2e Dawsh 2y ago ProxyTypes,
32 01cdf2e Dawsh 2y ago )
33 f1ab16c Dawsh 2y ago from app.models.user import (
34 f1ab16c Dawsh 2y ago ReminderType,
35 d377c4c Dawsh 2y ago UserDataUsageResetStrategy,
36 f1ab16c Dawsh 2y ago UserStatus,
37 d377c4c Dawsh 2y ago UserExpireStrategy,
38 f1ab16c Dawsh 2y ago )
39 a47eb4c Dawsh 2y ago
40 a47eb4c Dawsh 2y ago
41 a47eb4c Dawsh 2y ago class Admin(Base):
42 a47eb4c Dawsh 2y ago __tablename__ = "admins"
43 a47eb4c Dawsh 2y ago
44 6457378 Dawsh 2y ago id = Column(Integer, primary_key=True)
45 a47eb4c Dawsh 2y ago username = Column(String(32), unique=True, index=True)
46 a47eb4c Dawsh 2y ago hashed_password = Column(String(128))
47 a47eb4c Dawsh 2y ago users = relationship("User", back_populates="admin")
48 a47eb4c Dawsh 2y ago created_at = Column(DateTime, default=datetime.utcnow)
49 a47eb4c Dawsh 2y ago is_sudo = Column(Boolean, default=False)
50 6457378 Dawsh 2y ago password_reset_at = Column(DateTime)
51 a47eb4c Dawsh 2y ago
52 a47eb4c Dawsh 2y ago
53 a47eb4c Dawsh 2y ago inbounds_services = Table(
54 a47eb4c Dawsh 2y ago "inbounds_services",
55 a47eb4c Dawsh 2y ago Base.metadata,
56 a47eb4c Dawsh 2y ago Column("inbound_id", ForeignKey("inbounds.id"), primary_key=True),
57 a47eb4c Dawsh 2y ago Column("service_id", ForeignKey("services.id"), primary_key=True),
58 a47eb4c Dawsh 2y ago )
59 a47eb4c Dawsh 2y ago
60 a47eb4c Dawsh 2y ago users_services = Table(
61 a47eb4c Dawsh 2y ago "users_services",
62 a47eb4c Dawsh 2y ago Base.metadata,
63 a47eb4c Dawsh 2y ago Column("user_id", ForeignKey("users.id"), primary_key=True),
64 a47eb4c Dawsh 2y ago Column("service_id", ForeignKey("services.id"), primary_key=True),
65 a47eb4c Dawsh 2y ago )
66 a47eb4c Dawsh 2y ago
67 a47eb4c Dawsh 2y ago
68 a47eb4c Dawsh 2y ago class Service(Base):
69 a47eb4c Dawsh 2y ago __tablename__ = "services"
70 6457378 Dawsh 2y ago id = Column(Integer, primary_key=True)
71 6457378 Dawsh 2y ago name = Column(String(64))
72 f1ab16c Dawsh 2y ago users = relationship(
73 f1ab16c Dawsh 2y ago "User", secondary=users_services, back_populates="services"
74 f1ab16c Dawsh 2y ago )
75 01cdf2e Dawsh 2y ago inbounds = relationship(
76 01cdf2e Dawsh 2y ago "Inbound", secondary=inbounds_services, back_populates="services"
77 01cdf2e Dawsh 2y ago )
78 a47eb4c Dawsh 2y ago
79 db68a58 Dawsh 2y ago @property
80 db68a58 Dawsh 2y ago def inbound_ids(self):
81 db68a58 Dawsh 2y ago return [inbound.id for inbound in self.inbounds]
82 db68a58 Dawsh 2y ago
83 db68a58 Dawsh 2y ago @property
84 db68a58 Dawsh 2y ago def user_ids(self):
85 db68a58 Dawsh 2y ago return [user.id for user in self.users]
86 db68a58 Dawsh 2y ago
87 a47eb4c Dawsh 2y ago
88 a47eb4c Dawsh 2y ago class User(Base):
89 a47eb4c Dawsh 2y ago __tablename__ = "users"
90 a47eb4c Dawsh 2y ago
91 6457378 Dawsh 2y ago id = Column(Integer, primary_key=True)
92 6457378 Dawsh 2y ago username = Column(String(32), unique=True, index=True)
93 6457378 Dawsh 2y ago key = Column(String(64), unique=True)
94 d377c4c Dawsh 2y ago activated = Column(Boolean, nullable=False, default=True)
95 cba9caa Dawsh 2y ago enabled = Column(
96 f1ab16c Dawsh 2y ago Boolean,
97 f1ab16c Dawsh 2y ago nullable=False,
98 f1ab16c Dawsh 2y ago default=True,
99 f1ab16c Dawsh 2y ago server_default=sqlalchemy.sql.true(),
100 cba9caa Dawsh 2y ago )
101 01cdf2e Dawsh 2y ago services = relationship(
102 f1ab16c Dawsh 2y ago "Service",
103 f1ab16c Dawsh 2y ago secondary=users_services,
104 f1ab16c Dawsh 2y ago back_populates="users",
105 f1ab16c Dawsh 2y ago lazy="joined",
106 01cdf2e Dawsh 2y ago )
107 12b255b Dawsh 2y ago inbounds = relationship(
108 12b255b Dawsh 2y ago "Inbound",
109 12b255b Dawsh 2y ago secondary="join(users_services, inbounds_services, inbounds_services.c.service_id == users_services.c.service_id)"
110 01cdf2e Dawsh 2y ago ".join(Inbound, Inbound.id == inbounds_services.c.inbound_id)",
111 01cdf2e Dawsh 2y ago viewonly=True,
112 12b255b Dawsh 2y ago distinct_target_key=True,
113 01cdf2e Dawsh 2y ago )
114 a47eb4c Dawsh 2y ago used_traffic = Column(BigInteger, default=0)
115 8ee2242 Dawsh 2y ago lifetime_used_traffic = Column(
116 8ee2242 Dawsh 2y ago BigInteger, default=0, server_default="0", nullable=False
117 8ee2242 Dawsh 2y ago )
118 42a1073 Dawsh 2y ago traffic_reset_at = Column(DateTime)
119 01cdf2e Dawsh 2y ago node_usages = relationship(
120 01cdf2e Dawsh 2y ago "NodeUserUsage",
121 01cdf2e Dawsh 2y ago back_populates="user",
122 01cdf2e Dawsh 2y ago cascade="all,delete,delete-orphan",
123 01cdf2e Dawsh 2y ago )
124 01cdf2e Dawsh 2y ago notification_reminders = relationship(
125 01cdf2e Dawsh 2y ago "NotificationReminder",
126 01cdf2e Dawsh 2y ago back_populates="user",
127 01cdf2e Dawsh 2y ago cascade="all,delete,delete-orphan",
128 01cdf2e Dawsh 2y ago )
129 6457378 Dawsh 2y ago data_limit = Column(BigInteger)
130 a47eb4c Dawsh 2y ago data_limit_reset_strategy = Column(
131 d377c4c Dawsh 2y ago Enum(UserDataUsageResetStrategy),
132 a47eb4c Dawsh 2y ago nullable=False,
133 d377c4c Dawsh 2y ago default=UserDataUsageResetStrategy.no_reset,
134 a47eb4c Dawsh 2y ago )
135 a47eb4c Dawsh 2y ago ip_limit = Column(Integer, nullable=False, default=-1)
136 010b05d Dawsh 2y ago settings = Column(String(1024))
137 d377c4c Dawsh 2y ago expire_strategy = Column(
138 d377c4c Dawsh 2y ago Enum(UserExpireStrategy),
139 d377c4c Dawsh 2y ago nullable=False,
140 d377c4c Dawsh 2y ago default=UserExpireStrategy.NEVER,
141 d377c4c Dawsh 2y ago )
142 d377c4c Dawsh 2y ago expire_date = Column(DateTime)
143 d377c4c Dawsh 2y ago usage_duration = Column(BigInteger)
144 d377c4c Dawsh 2y ago activation_deadline = Column(DateTime)
145 a47eb4c Dawsh 2y ago admin_id = Column(Integer, ForeignKey("admins.id"))
146 a47eb4c Dawsh 2y ago admin = relationship("Admin", back_populates="users")
147 6457378 Dawsh 2y ago sub_updated_at = Column(DateTime)
148 6457378 Dawsh 2y ago sub_last_user_agent = Column(String(512))
149 a47eb4c Dawsh 2y ago created_at = Column(DateTime, default=datetime.utcnow)
150 6457378 Dawsh 2y ago note = Column(String(500))
151 6457378 Dawsh 2y ago online_at = Column(DateTime)
152 6457378 Dawsh 2y ago edit_at = Column(DateTime)
153 a47eb4c Dawsh 2y ago
154 db68a58 Dawsh 2y ago @property
155 db68a58 Dawsh 2y ago def service_ids(self):
156 db68a58 Dawsh 2y ago return [service.id for service in self.services]
157 db68a58 Dawsh 2y ago
158 d377c4c Dawsh 2y ago @hybrid_property
159 d377c4c Dawsh 2y ago def expired(self):
160 d377c4c Dawsh 2y ago if self.expire_strategy == "fixed_date":
161 d377c4c Dawsh 2y ago return self.expire_date < datetime.utcnow()
162 d377c4c Dawsh 2y ago return False
163 d377c4c Dawsh 2y ago
164 d377c4c Dawsh 2y ago @expired.expression
165 d377c4c Dawsh 2y ago def expired(cls):
166 d377c4c Dawsh 2y ago return and_(
167 d377c4c Dawsh 2y ago cls.expire_strategy == "fixed_date", cls.expire_date < func.now()
168 d377c4c Dawsh 2y ago )
169 d377c4c Dawsh 2y ago
170 d377c4c Dawsh 2y ago @hybrid_property
171 d377c4c Dawsh 2y ago def data_limit_reached(self):
172 d377c4c Dawsh 2y ago if self.data_limit is not None:
173 d377c4c Dawsh 2y ago return self.used_traffic >= self.data_limit
174 d377c4c Dawsh 2y ago return False
175 d377c4c Dawsh 2y ago
176 d377c4c Dawsh 2y ago @data_limit_reached.expression
177 d377c4c Dawsh 2y ago def data_limit_reached(cls):
178 d377c4c Dawsh 2y ago return and_(
179 d377c4c Dawsh 2y ago cls.data_limit.isnot(None), cls.used_traffic >= cls.data_limit
180 d377c4c Dawsh 2y ago )
181 d377c4c Dawsh 2y ago
182 d377c4c Dawsh 2y ago @hybrid_property
183 d377c4c Dawsh 2y ago def is_active(self):
184 d377c4c Dawsh 2y ago return (
185 d377c4c Dawsh 2y ago self.enabled and not self.expired and not self.data_limit_reached
186 d377c4c Dawsh 2y ago )
187 d377c4c Dawsh 2y ago
188 d377c4c Dawsh 2y ago @is_active.expression
189 d377c4c Dawsh 2y ago def is_active(cls):
190 d377c4c Dawsh 2y ago return and_(cls.enabled == True, ~cls.expired, ~cls.data_limit_reached)
191 d377c4c Dawsh 2y ago
192 d377c4c Dawsh 2y ago @property
193 d377c4c Dawsh 2y ago def status(self):
194 d377c4c Dawsh 2y ago return UserStatus.ACTIVE if self.is_active else UserStatus.INACTIVE
195 d377c4c Dawsh 2y ago
196 a47eb4c Dawsh 2y ago
197 a47eb4c Dawsh 2y ago class Inbound(Base):
198 a47eb4c Dawsh 2y ago __tablename__ = "inbounds"
199 01cdf2e Dawsh 2y ago __table_args__ = (UniqueConstraint("node_id", "tag"),)
200 a47eb4c Dawsh 2y ago
201 a47eb4c Dawsh 2y ago id = Column(Integer, primary_key=True)
202 a47eb4c Dawsh 2y ago protocol = Column(Enum(ProxyTypes))
203 6457378 Dawsh 2y ago tag = Column(String(256), nullable=False)
204 010b05d Dawsh 2y ago config = Column(String(512), nullable=False)
205 a47eb4c Dawsh 2y ago node_id = Column(Integer, ForeignKey("nodes.id"), index=True)
206 a47eb4c Dawsh 2y ago node = relationship("Node", back_populates="inbounds")
207 01cdf2e Dawsh 2y ago services = relationship(
208 01cdf2e Dawsh 2y ago "Service", secondary=inbounds_services, back_populates="inbounds"
209 01cdf2e Dawsh 2y ago )
210 a47eb4c Dawsh 2y ago hosts = relationship(
211 f1ab16c Dawsh 2y ago "InboundHost",
212 f1ab16c Dawsh 2y ago back_populates="inbound",
213 f1ab16c Dawsh 2y ago cascade="all, delete, delete-orphan",
214 a47eb4c Dawsh 2y ago )
215 a47eb4c Dawsh 2y ago
216 db68a58 Dawsh 2y ago @property
217 db68a58 Dawsh 2y ago def service_ids(self):
218 db68a58 Dawsh 2y ago return [service.id for service in self.services]
219 db68a58 Dawsh 2y ago
220 a47eb4c Dawsh 2y ago
221 a47eb4c Dawsh 2y ago class InboundHost(Base):
222 a47eb4c Dawsh 2y ago __tablename__ = "hosts"
223 a47eb4c Dawsh 2y ago
224 a47eb4c Dawsh 2y ago id = Column(Integer, primary_key=True)
225 6457378 Dawsh 2y ago remark = Column(String(256), nullable=False)
226 6457378 Dawsh 2y ago address = Column(String(256), nullable=False)
227 6457378 Dawsh 2y ago port = Column(Integer)
228 6457378 Dawsh 2y ago path = Column(String(256))
229 1fde8fd Dawsh 2y ago sni = Column(String(1024))
230 1fde8fd Dawsh 2y ago host = Column(String(1024))
231 a47eb4c Dawsh 2y ago security = Column(
232 a47eb4c Dawsh 2y ago Enum(InboundHostSecurity),
233 a47eb4c Dawsh 2y ago nullable=False,
234 a47eb4c Dawsh 2y ago default=InboundHostSecurity.inbound_default,
235 a47eb4c Dawsh 2y ago )
236 a47eb4c Dawsh 2y ago alpn = Column(
237 a47eb4c Dawsh 2y ago Enum(InboundHostALPN),
238 a47eb4c Dawsh 2y ago nullable=False,
239 a47eb4c Dawsh 2y ago default=InboundHostSecurity.none,
240 01cdf2e Dawsh 2y ago server_default=InboundHostSecurity.none.name,
241 a47eb4c Dawsh 2y ago )
242 a47eb4c Dawsh 2y ago fingerprint = Column(
243 a47eb4c Dawsh 2y ago Enum(InboundHostFingerprint),
244 a47eb4c Dawsh 2y ago nullable=False,
245 a47eb4c Dawsh 2y ago default=InboundHostSecurity.none,
246 01cdf2e Dawsh 2y ago server_default=InboundHostSecurity.none.name,
247 a47eb4c Dawsh 2y ago )
248 a47eb4c Dawsh 2y ago
249 0b152b5 Mrdn 2y ago mux = Column(
250 f1ab16c Dawsh 2y ago Boolean,
251 f1ab16c Dawsh 2y ago default=False,
252 f1ab16c Dawsh 2y ago nullable=False,
253 f1ab16c Dawsh 2y ago server_default=sqlalchemy.sql.true(),
254 0b152b5 Mrdn 2y ago )
255 0b152b5 Mrdn 2y ago fragment = Column(JSON())
256 0b152b5 Mrdn 2y ago
257 a47eb4c Dawsh 2y ago inbound_id = Column(Integer, ForeignKey("inbounds.id"), nullable=False)
258 a47eb4c Dawsh 2y ago inbound = relationship("Inbound", back_populates="hosts")
259 6457378 Dawsh 2y ago allowinsecure = Column(Boolean, default=False)
260 6457378 Dawsh 2y ago is_disabled = Column(Boolean, default=False)
261 a47eb4c Dawsh 2y ago
262 a47eb4c Dawsh 2y ago
263 a47eb4c Dawsh 2y ago class System(Base):
264 a47eb4c Dawsh 2y ago __tablename__ = "system"
265 a47eb4c Dawsh 2y ago
266 6457378 Dawsh 2y ago id = Column(Integer, primary_key=True)
267 a47eb4c Dawsh 2y ago uplink = Column(BigInteger, default=0)
268 a47eb4c Dawsh 2y ago downlink = Column(BigInteger, default=0)
269 a47eb4c Dawsh 2y ago
270 a47eb4c Dawsh 2y ago
271 a47eb4c Dawsh 2y ago class JWT(Base):
272 a47eb4c Dawsh 2y ago __tablename__ = "jwt"
273 a47eb4c Dawsh 2y ago
274 a47eb4c Dawsh 2y ago id = Column(Integer, primary_key=True)
275 a47eb4c Dawsh 2y ago secret_key = Column(
276 a47eb4c Dawsh 2y ago String(64), nullable=False, default=lambda: os.urandom(32).hex()
277 a47eb4c Dawsh 2y ago )
278 a47eb4c Dawsh 2y ago
279 a47eb4c Dawsh 2y ago
280 a47eb4c Dawsh 2y ago class TLS(Base):
281 a47eb4c Dawsh 2y ago __tablename__ = "tls"
282 a47eb4c Dawsh 2y ago
283 a47eb4c Dawsh 2y ago id = Column(Integer, primary_key=True)
284 a47eb4c Dawsh 2y ago key = Column(String(4096), nullable=False)
285 a47eb4c Dawsh 2y ago certificate = Column(String(2048), nullable=False)
286 a47eb4c Dawsh 2y ago
287 a47eb4c Dawsh 2y ago
288 a47eb4c Dawsh 2y ago class Node(Base):
289 a47eb4c Dawsh 2y ago __tablename__ = "nodes"
290 01cdf2e Dawsh 2y ago __table_args__ = (UniqueConstraint("address", "port"),)
291 6457378 Dawsh 2y ago id = Column(Integer, primary_key=True)
292 6457378 Dawsh 2y ago name = Column(String(256), unique=True)
293 010b05d Dawsh 2y ago connection_backend = Column(String(32))
294 6457378 Dawsh 2y ago address = Column(String(256))
295 6457378 Dawsh 2y ago port = Column(Integer)
296 6457378 Dawsh 2y ago xray_version = Column(String(32))
297 f1ab16c Dawsh 2y ago inbounds = relationship(
298 f1ab16c Dawsh 2y ago "Inbound", back_populates="node", cascade="all, delete"
299 f1ab16c Dawsh 2y ago )
300 f1ab16c Dawsh 2y ago status = Column(
301 f1ab16c Dawsh 2y ago Enum(NodeStatus), nullable=False, default=NodeStatus.unhealthy
302 f1ab16c Dawsh 2y ago )
303 a47eb4c Dawsh 2y ago last_status_change = Column(DateTime, default=datetime.utcnow)
304 6457378 Dawsh 2y ago message = Column(String(1024))
305 a47eb4c Dawsh 2y ago created_at = Column(DateTime, default=datetime.utcnow)
306 a47eb4c Dawsh 2y ago uplink = Column(BigInteger, default=0)
307 a47eb4c Dawsh 2y ago downlink = Column(BigInteger, default=0)
308 01cdf2e Dawsh 2y ago user_usages = relationship(
309 f1ab16c Dawsh 2y ago "NodeUserUsage",
310 f1ab16c Dawsh 2y ago back_populates="node",
311 f1ab16c Dawsh 2y ago cascade="all, delete, delete-orphan",
312 01cdf2e Dawsh 2y ago )
313 01cdf2e Dawsh 2y ago usages = relationship(
314 f1ab16c Dawsh 2y ago "NodeUsage",
315 f1ab16c Dawsh 2y ago back_populates="node",
316 f1ab16c Dawsh 2y ago cascade="all, delete, delete-orphan",
317 01cdf2e Dawsh 2y ago )
318 01cdf2e Dawsh 2y ago usage_coefficient = Column(
319 01cdf2e Dawsh 2y ago Float, nullable=False, server_default=text("1.0"), default=1
320 01cdf2e Dawsh 2y ago )
321 a47eb4c Dawsh 2y ago
322 db68a58 Dawsh 2y ago @property
323 db68a58 Dawsh 2y ago def inbound_ids(self):
324 db68a58 Dawsh 2y ago return [inbound.id for inbound in self.inbounds]
325 db68a58 Dawsh 2y ago
326 a47eb4c Dawsh 2y ago
327 a47eb4c Dawsh 2y ago class NodeUserUsage(Base):
328 a47eb4c Dawsh 2y ago __tablename__ = "node_user_usages"
329 01cdf2e Dawsh 2y ago __table_args__ = (UniqueConstraint("created_at", "user_id", "node_id"),)
330 a47eb4c Dawsh 2y ago
331 6457378 Dawsh 2y ago id = Column(Integer, primary_key=True)
332 6457378 Dawsh 2y ago created_at = Column(DateTime, nullable=False) # one hour per record
333 a47eb4c Dawsh 2y ago user_id = Column(Integer, ForeignKey("users.id"))
334 a47eb4c Dawsh 2y ago user = relationship("User", back_populates="node_usages")
335 a47eb4c Dawsh 2y ago node_id = Column(Integer, ForeignKey("nodes.id"))
336 a47eb4c Dawsh 2y ago node = relationship("Node", back_populates="user_usages")
337 a47eb4c Dawsh 2y ago used_traffic = Column(BigInteger, default=0)
338 a47eb4c Dawsh 2y ago
339 a47eb4c Dawsh 2y ago
340 a47eb4c Dawsh 2y ago class NodeUsage(Base):
341 a47eb4c Dawsh 2y ago __tablename__ = "node_usages"
342 01cdf2e Dawsh 2y ago __table_args__ = (UniqueConstraint("created_at", "node_id"),)
343 a47eb4c Dawsh 2y ago
344 6457378 Dawsh 2y ago id = Column(Integer, primary_key=True)
345 6457378 Dawsh 2y ago created_at = Column(DateTime, nullable=False) # one hour per record
346 a47eb4c Dawsh 2y ago node_id = Column(Integer, ForeignKey("nodes.id"))
347 a47eb4c Dawsh 2y ago node = relationship("Node", back_populates="usages")
348 a47eb4c Dawsh 2y ago uplink = Column(BigInteger, default=0)
349 a47eb4c Dawsh 2y ago downlink = Column(BigInteger, default=0)
350 a47eb4c Dawsh 2y ago
351 a47eb4c Dawsh 2y ago
352 a47eb4c Dawsh 2y ago class NotificationReminder(Base):
353 a47eb4c Dawsh 2y ago __tablename__ = "notification_reminders"
354 a47eb4c Dawsh 2y ago
355 6457378 Dawsh 2y ago id = Column(Integer, primary_key=True)
356 a47eb4c Dawsh 2y ago user_id = Column(Integer, ForeignKey("users.id"))
357 a47eb4c Dawsh 2y ago user = relationship("User", back_populates="notification_reminders")
358 a47eb4c Dawsh 2y ago type = Column(Enum(ReminderType), nullable=False)
359 6457378 Dawsh 2y ago expires_at = Column(DateTime)
360 a47eb4c Dawsh 2y ago created_at = Column(DateTime, default=datetime.utcnow)
361 0178858 Dawsh 2y ago
362 0178858 Dawsh 2y ago
363 0178858 Dawsh 2y ago class Settings(Base):
364 0178858 Dawsh 2y ago __tablename__ = "settings"
365 0178858 Dawsh 2y ago
366 0178858 Dawsh 2y ago id = Column(Integer, primary_key=True, server_default=text("0"))
367 0178858 Dawsh 2y ago subscription = Column(JSON, nullable=False)
368 0178858 Dawsh 2y ago telegram = Column(JSON)