Add optional PostgreSQL database support

Bambuddy can now use an external PostgreSQL database via the
  DATABASE_URL environment variable. SQLite remains the default.
  Dialect-aware helpers handle upserts, PRAGMAs, FTS (FTS5 vs
  tsvector+GIN), backup/restore, and health checks. All migration
  blocks use savepoints to prevent Postgres transaction poisoning.
  Backups are always portable SQLite format regardless of backend.
  Cross-database restore imports SQLite backups into PostgreSQL
  with automatic boolean/datetime conversion, NOT NULL default
  filling, and FK constraint handling.
This commit is contained in:
maziggy
2026-04-03 11:33:29 +02:00
parent 76adf70fd4
commit 610431d6b7
22 changed files with 1514 additions and 1309 deletions
+3 -1
View File
@@ -15,7 +15,9 @@ class VirtualPrinter(Base):
name: Mapped[str] = mapped_column(String(100), default="Bambuddy")
enabled: Mapped[bool] = mapped_column(Boolean, default=False)
mode: Mapped[str] = mapped_column(String(20), default="immediate") # immediate|review|print_queue|proxy
auto_dispatch: Mapped[bool] = mapped_column(Boolean, default=True) # print_queue mode: auto-start or manual
auto_dispatch: Mapped[bool] = mapped_column(
Boolean, server_default="true"
) # print_queue mode: auto-start or manual
model: Mapped[str | None] = mapped_column(String(50), nullable=True) # SSDP model code (server mode)
access_code: Mapped[str | None] = mapped_column(String(8), nullable=True) # 8 chars (server mode)
target_printer_id: Mapped[int | None] = mapped_column(