first commit
This commit is contained in:
19
backend/app/models/backup.py
Normal file
19
backend/app/models/backup.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from app.db.session import Base
|
||||
|
||||
|
||||
class Backup(Base):
|
||||
__tablename__ = "backups"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
router_id = Column(Integer, ForeignKey("routers.id"), nullable=False, index=True)
|
||||
file_path = Column(String(500), nullable=False)
|
||||
file_name = Column(String(255), nullable=False)
|
||||
backup_type = Column(String(50), nullable=False, default="export")
|
||||
checksum = Column(String(64), nullable=True)
|
||||
created_at = Column(DateTime, server_default=func.now(), nullable=False)
|
||||
|
||||
router = relationship("Router", back_populates="backups")
|
||||
12
backend/app/models/log.py
Normal file
12
backend/app/models/log.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from sqlalchemy import Column, DateTime, Integer, Text
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from app.db.session import Base
|
||||
|
||||
|
||||
class OperationLog(Base):
|
||||
__tablename__ = "operation_logs"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
message = Column(Text, nullable=False)
|
||||
timestamp = Column(DateTime, server_default=func.now(), nullable=False)
|
||||
28
backend/app/models/router.py
Normal file
28
backend/app/models/router.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from app.db.session import Base
|
||||
|
||||
|
||||
class Router(Base):
|
||||
__tablename__ = "routers"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
owner_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
|
||||
name = Column(String(120), nullable=False)
|
||||
host = Column(String(255), nullable=False)
|
||||
port = Column(Integer, nullable=False, default=22)
|
||||
ssh_user = Column(String(120), nullable=False, default="admin")
|
||||
ssh_key = Column(Text, nullable=True)
|
||||
ssh_password = Column(String(255), nullable=True)
|
||||
last_connection_status = Column(Boolean, nullable=True)
|
||||
last_connection_tested_at = Column(DateTime, nullable=True)
|
||||
last_connection_error = Column(Text, nullable=True)
|
||||
last_connection_hostname = Column(String(255), nullable=True)
|
||||
last_connection_model = Column(String(255), nullable=True)
|
||||
last_connection_version = Column(String(255), nullable=True)
|
||||
last_connection_uptime = Column(String(255), nullable=True)
|
||||
created_at = Column(DateTime, server_default=func.now(), nullable=False)
|
||||
|
||||
backups = relationship("Backup", back_populates="router", cascade="all, delete-orphan")
|
||||
26
backend/app/models/settings.py
Normal file
26
backend/app/models/settings.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from sqlalchemy import Boolean, Column, Integer, String, Text
|
||||
|
||||
from app.db.session import Base
|
||||
|
||||
|
||||
class GlobalSettings(Base):
|
||||
__tablename__ = "global_settings"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
backup_retention_days = Column(Integer, default=7)
|
||||
log_retention_days = Column(Integer, default=7)
|
||||
export_cron = Column(String(64), default="")
|
||||
binary_cron = Column(String(64), default="")
|
||||
retention_cron = Column(String(64), default="")
|
||||
enable_auto_export = Column(Boolean, default=False)
|
||||
connection_test_interval_minutes = Column(Integer, default=0)
|
||||
global_ssh_key = Column(Text, nullable=True)
|
||||
pushover_token = Column(String(255), nullable=True)
|
||||
pushover_userkey = Column(String(255), nullable=True)
|
||||
notify_failures_only = Column(Boolean, default=True)
|
||||
smtp_host = Column(String(255), nullable=True)
|
||||
smtp_port = Column(Integer, default=587)
|
||||
smtp_login = Column(String(255), nullable=True)
|
||||
smtp_password = Column(String(255), nullable=True)
|
||||
smtp_notifications_enabled = Column(Boolean, default=False)
|
||||
recipient_email = Column(String(255), nullable=True)
|
||||
15
backend/app/models/user.py
Normal file
15
backend/app/models/user.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from sqlalchemy import Column, DateTime, Integer, String
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from app.db.session import Base
|
||||
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String(120), unique=True, nullable=False, index=True)
|
||||
password_hash = Column(String(255), nullable=False)
|
||||
created_at = Column(DateTime, server_default=func.now(), nullable=False)
|
||||
preferred_language = Column(String(8), nullable=False, default='pl')
|
||||
preferred_font = Column(String(32), nullable=False, default='default')
|
||||
Reference in New Issue
Block a user