mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 08:25:54 +02:00
[PR #432] [CLOSED] [Feature] - Adding MySql support #1045
Labels
No labels
A1
automated
automated
bug
bug
Closed due to inactivity
contrib
dependencies
dependencies
duplicate
enhancement
feedback
hold
invalid
Notes
P1S
pull-request
security
ThumbsUp
user-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/bambuddy-maziggy-1#1045
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/maziggy/bambuddy/pull/432
Author: @wreuel
Created: 2/18/2026
Status: ❌ Closed
Base:
0.2.1b3← Head:feature/addingMySQLSupport📝 Commits (10+)
392c192Adding support to mysql52b4263Adding migrationa3feadfFixing unit tests12d3067Merge branch '0.2.1b' into feature/addingMySQLSupport412e354Merge branch '0.2.1b' into feature/addingMySQLSupporta954f0eMerge branch '0.2.1' into feature/addingMySQLSupport6f5504bMerge branch '0.2.1b2' into feature/addingMySQLSupport76c80abAdding the migrations2e03253Merge branch '0.2.1b2' into feature/addingMySQLSupport2d90006Merge branch '0.2.1b3' into feature/addingMySQLSupport📊 Changes
16 files changed (+1767 additions, -80 deletions)
View changed files
📝
.env.example(+11 -0)➕
backend/alembic.ini(+37 -0)➕
backend/alembic/env.py(+107 -0)➕
backend/alembic/script.py.mako(+26 -0)➕
backend/alembic/versions/0001_initial_schema.py(+815 -0)➕
backend/alembic/versions/0002_add_virtual_printers_and_spool_core_weight_catalog_id.py(+55 -0)📝
backend/app/api/routes/archives.py(+34 -14)📝
backend/app/api/routes/auth.py(+6 -21)📝
backend/app/api/routes/settings.py(+2 -6)📝
backend/app/core/config.py(+40 -3)📝
backend/app/core/database.py(+116 -28)📝
backend/app/services/email_service.py(+2 -8)📝
backend/tests/conftest.py(+1 -0)➕
backend/tests/unit/test_mysql_compat.py(+442 -0)➕
docker-compose.mysql.yml(+71 -0)📝
requirements.txt(+2 -0)📄 Description
Description
Adds optional MySQL/MariaDB support as an alternative database backend to SQLite. This is aimed at users running larger farms or multi-instance setups where SQLite's single-writer concurrency becomes a bottleneck.
DB_TYPE=mysqlenvironment variable to switch from SQLite to MySQL/MariaDBdocker-compose.mysql.ymlwith MariaDB 11Related Issue
Fixes #130
Type of Change
Changes Made
Database layer
backend/app/core/config.py— Newdb_type,db_host,db_port,db_name,db_user,db_passwordsettings withmysql+aiomysqlURL builderbackend/app/core/database.py— Dual-path init:create_all()+ inline migrations for SQLite, Alembicupgrade headfor MySQL. MySQL-specific connection pooling (pool_recycle,pool_pre_ping)backend/alembic/— Full Alembic setup with async engine supportenv.pyregisters all models withBase.metadata0001_initial_schema.py— Baseline migration matching the current SQLite schema (50+ tables)0002_add_virtual_printers_and_spool_core_weight_catalog_id.py— Catches up with model changes from0.2.1b2mergeDocker
docker-compose.mysql.yml— Standalone compose file with Bambuddy + MariaDB 11, health checks, named volumesTests
backend/tests/unit/test_mysql_compat.py— 442-line test suite validating MySQL schema compatibilityEnvironment variables
DB_TYPEsqlitesqliteormysqlDB_HOSTlocalhostDB_PORT3306DB_NAMEbambuddyDB_USERDB_PASSWORDHow to add new Alembic migrations
When contributing model changes that add/remove/alter tables or columns, a new Alembic migration is needed for MySQL support. Here's how:
Prerequisites
DB_TYPE=mysqland valid credentialspip install alembic)Option A: Auto-generate (recommended)
Alembic can diff your models against the live database and generate the migration automatically:
This creates a new file in
backend/alembic/versions/with the detectedupgrade()anddowngrade()operations.Option B: Manual migration
If you prefer to write the migration by hand (or don't have a live MySQL instance):
Then edit the generated file and add your
op.create_table(),op.add_column(), etc.Applying migrations
Quick reference (Alembic)
alembic revision --autogenerate -m "Name"alembic upgrade headalembic downgrade -1alembic downgrade <revision>Screenshots
Testing
Checklist
Additional Notes
Important notes
database.pydowngrade()— Every migration must be reversible0001_,0002_,0003_, etc.down_revisionchain — Each migration must point to the previous one (e.g.,down_revision = "0002")🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.