mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
fix(backend): resolve database index naming conflicts
Each table now has uniquely prefixed index names to avoid SQLAlchemy conflicts: - Workflow indexes: idx_workflow_* - Execution indexes: idx_execution_* - AuditLog indexes: idx_audit_* - Project indexes: idx_project_* - Workspace indexes: idx_workspace_* - ProjectCanvasItem indexes: idx_canvas_* This allows database initialization to complete successfully. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -58,11 +58,11 @@ class Workflow(db.Model):
|
||||
|
||||
# Indexes for efficient querying
|
||||
__table_args__ = (
|
||||
db.Index('idx_tenant_id', 'tenant_id'),
|
||||
db.Index('idx_tenant_name', 'tenant_id', 'name'),
|
||||
db.Index('idx_project_id', 'project_id'),
|
||||
db.Index('idx_workspace_id', 'workspace_id'),
|
||||
db.Index('idx_tenant_project', 'tenant_id', 'project_id'),
|
||||
db.Index('idx_workflow_tenant_id', 'tenant_id'),
|
||||
db.Index('idx_workflow_tenant_name', 'tenant_id', 'name'),
|
||||
db.Index('idx_workflow_project_id', 'project_id'),
|
||||
db.Index('idx_workflow_workspace_id', 'workspace_id'),
|
||||
db.Index('idx_workflow_tenant_project', 'tenant_id', 'project_id'),
|
||||
)
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
@@ -130,9 +130,9 @@ class Execution(db.Model):
|
||||
|
||||
# Indexes for efficient querying
|
||||
__table_args__ = (
|
||||
db.Index('idx_workflow_id', 'workflow_id'),
|
||||
db.Index('idx_tenant_workflow', 'tenant_id', 'workflow_id'),
|
||||
db.Index('idx_status', 'status'),
|
||||
db.Index('idx_execution_workflow_id', 'workflow_id'),
|
||||
db.Index('idx_execution_tenant_workflow', 'tenant_id', 'workflow_id'),
|
||||
db.Index('idx_execution_status', 'status'),
|
||||
)
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
@@ -241,9 +241,9 @@ class AuditLog(db.Model):
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
__table_args__ = (
|
||||
db.Index('idx_workflow_id', 'workflow_id'),
|
||||
db.Index('idx_tenant_id', 'tenant_id'),
|
||||
db.Index('idx_action', 'action'),
|
||||
db.Index('idx_audit_workflow_id', 'workflow_id'),
|
||||
db.Index('idx_audit_tenant_id', 'tenant_id'),
|
||||
db.Index('idx_audit_action', 'action'),
|
||||
)
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
@@ -281,7 +281,7 @@ class Workspace(db.Model):
|
||||
projects = db.relationship('Project', backref='workspace', cascade='all, delete-orphan', lazy=True)
|
||||
|
||||
__table_args__ = (
|
||||
db.Index('idx_tenant_id', 'tenant_id'),
|
||||
db.Index('idx_workspace_tenant_id', 'tenant_id'),
|
||||
)
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
@@ -332,10 +332,10 @@ class Project(db.Model):
|
||||
canvas_items = db.relationship('ProjectCanvasItem', backref='project', cascade='all, delete-orphan', lazy=True)
|
||||
|
||||
__table_args__ = (
|
||||
db.Index('idx_workspace_id', 'workspace_id'),
|
||||
db.Index('idx_tenant_id', 'tenant_id'),
|
||||
db.Index('idx_starred', 'starred'),
|
||||
db.Index('idx_tenant_workspace', 'tenant_id', 'workspace_id'),
|
||||
db.Index('idx_project_workspace_id', 'workspace_id'),
|
||||
db.Index('idx_project_tenant_id', 'tenant_id'),
|
||||
db.Index('idx_project_starred', 'starred'),
|
||||
db.Index('idx_project_tenant_workspace', 'tenant_id', 'workspace_id'),
|
||||
)
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
@@ -388,9 +388,9 @@ class ProjectCanvasItem(db.Model):
|
||||
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
|
||||
|
||||
__table_args__ = (
|
||||
db.Index('idx_project_id', 'project_id'),
|
||||
db.Index('idx_workflow_id', 'workflow_id'),
|
||||
db.Index('idx_project_workflow', 'project_id', 'workflow_id'),
|
||||
db.Index('idx_canvas_project_id', 'project_id'),
|
||||
db.Index('idx_canvas_workflow_id', 'workflow_id'),
|
||||
db.Index('idx_canvas_project_workflow', 'project_id', 'workflow_id'),
|
||||
)
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user