Implement decoupled plugin database model management system#2
Draft
Implement decoupled plugin database model management system#2
Conversation
Co-authored-by: ian-aqr-k <134844321+ian-aqr-k@users.noreply.github.com>
- Complete example plugin with 3 database models - Demonstrates table naming conventions - Shows plugin database initialization - Includes API endpoints for testing - Provides working example for plugin developers
Copilot
AI
changed the title
.
Implement decoupled plugin database model management system
Aug 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements a comprehensive plugin database model management system that provides isolated, maintainable database functionality for MoviePilot plugins. The system addresses the need for plugins to create and manage their own database models without interfering with the main application or other plugins.
Key Features
Plugin Database Isolation
plugin_{plugin_id_lowercase}_{model_name_lowercase}pattern with runtime validationAlembic Migration Management
alembic/directory with independent version controlenv.py,script.py.mako) to avoid duplicationOrphan Version Cleanup
Plugin Configuration
plugin_db_config.jsonwith database configurationImplementation Details
Core Components
Plugin Database Manager (
app/core/plugin_db.py):PluginDBConfig: Manages JSON configuration filesPluginBaseFactory: Creates plugin-specific Base classes with isolated metadataPluginDBManager: Coordinates overall plugin database operationsAlembic Integration (
app/core/plugin_alembic.py):PluginAlembicManager: Handles migration generation and database upgradesPluginVersionManager: Manages orphan cleanup and version validationUtilities (
app/core/plugin_db_utils.py):@with_plugin_dbdecorator: Automatically provides plugin-specific database sessionsPluginModelmixin: Common functionality for plugin modelsPlugin Integration
Enhanced
_PluginBaseclass with new database methods:Command-Line Interface
Complete CLI tool (
plugin_db_cli.py) for database management:Example Usage
Defining Plugin Models
Plugin Directory Structure
Problem Resolution
This implementation solves the core issues identified in the problem statement:
Testing
Comprehensive test suite validates:
Documentation
PLUGIN_DATABASE.mdThis system provides a robust, production-ready foundation for plugin database management that maintains clean separation of concerns while enabling powerful database functionality for MoviePilot plugins.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.