π OpenHands: AI-Driven Development
fix(enterprise): migrate Jira models to SQLAlchemy 2.0 [9/13] (#13855)
Rohit Malhotra3b0e201a4e90
diff --git a/enterprise/storage/jira_conversation.py b/enterprise/storage/jira_conversation.pyindex 9b6fd0e295..dacefb660a 100644--- a/enterprise/storage/jira_conversation.py+++ b/enterprise/storage/jira_conversation.py@@ -1,21 +1,25 @@-from sqlalchemy import Column, DateTime, Integer, String, text+from datetime import datetime++from sqlalchemy import DateTime, String, text+from sqlalchemy.orm import Mapped, mapped_columnfrom storage.base import Base-class JiraConversation(Base): # type: ignore+class JiraConversation(Base):__tablename__ = 'jira_conversations'- id = Column(Integer, primary_key=True, autoincrement=True)- conversation_id = Column(String, nullable=False, index=True)- issue_id = Column(String, nullable=False, index=True)- issue_key = Column(String, nullable=False, index=True)- parent_id = Column(String, nullable=True)- jira_user_id = Column(Integer, nullable=False, index=True)- created_at = Column(++ id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)+ conversation_id: Mapped[str] = mapped_column(String, nullable=False, index=True)+ issue_id: Mapped[str] = mapped_column(String, nullable=False, index=True)+ issue_key: Mapped[str] = mapped_column(String, nullable=False, index=True)+ parent_id: Mapped[str | None] = mapped_column(String, nullable=True)+ jira_user_id: Mapped[int] = mapped_column(nullable=False, index=True)+ created_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),nullable=False,)- updated_at = Column(+ updated_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),onupdate=text('CURRENT_TIMESTAMP'),diff --git a/enterprise/storage/jira_dc_conversation.py b/enterprise/storage/jira_dc_conversation.pyindex 347e5e6068..6839819a18 100644--- a/enterprise/storage/jira_dc_conversation.py+++ b/enterprise/storage/jira_dc_conversation.py@@ -1,21 +1,25 @@-from sqlalchemy import Column, DateTime, Integer, String, text+from datetime import datetime++from sqlalchemy import DateTime, String, text+from sqlalchemy.orm import Mapped, mapped_columnfrom storage.base import Base-class JiraDcConversation(Base): # type: ignore+class JiraDcConversation(Base):__tablename__ = 'jira_dc_conversations'- id = Column(Integer, primary_key=True, autoincrement=True)- conversation_id = Column(String, nullable=False, index=True)- issue_id = Column(String, nullable=False, index=True)- issue_key = Column(String, nullable=False, index=True)- parent_id = Column(String, nullable=True)- jira_dc_user_id = Column(Integer, nullable=False, index=True)- created_at = Column(++ id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)+ conversation_id: Mapped[str] = mapped_column(String, nullable=False, index=True)+ issue_id: Mapped[str] = mapped_column(String, nullable=False, index=True)+ issue_key: Mapped[str] = mapped_column(String, nullable=False, index=True)+ parent_id: Mapped[str | None] = mapped_column(String, nullable=True)+ jira_dc_user_id: Mapped[int] = mapped_column(nullable=False, index=True)+ created_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),nullable=False,)- updated_at = Column(+ updated_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),onupdate=text('CURRENT_TIMESTAMP'),diff --git a/enterprise/storage/jira_dc_user.py b/enterprise/storage/jira_dc_user.pyindex b8d95336a2..29394fcf7f 100644--- a/enterprise/storage/jira_dc_user.py+++ b/enterprise/storage/jira_dc_user.py@@ -1,20 +1,24 @@-from sqlalchemy import Column, DateTime, Integer, String, text+from datetime import datetime++from sqlalchemy import DateTime, String, text+from sqlalchemy.orm import Mapped, mapped_columnfrom storage.base import Base-class JiraDcUser(Base): # type: ignore+class JiraDcUser(Base):__tablename__ = 'jira_dc_users'- id = Column(Integer, primary_key=True, autoincrement=True)- keycloak_user_id = Column(String, nullable=False, index=True)- jira_dc_user_id = Column(String, nullable=False, index=True)- jira_dc_workspace_id = Column(Integer, nullable=False, index=True)- status = Column(String, nullable=False)- created_at = Column(++ id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)+ keycloak_user_id: Mapped[str] = mapped_column(String, nullable=False, index=True)+ jira_dc_user_id: Mapped[str] = mapped_column(String, nullable=False, index=True)+ jira_dc_workspace_id: Mapped[int] = mapped_column(nullable=False, index=True)+ status: Mapped[str] = mapped_column(String, nullable=False)+ created_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),nullable=False,)- updated_at = Column(+ updated_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),onupdate=text('CURRENT_TIMESTAMP'),diff --git a/enterprise/storage/jira_dc_workspace.py b/enterprise/storage/jira_dc_workspace.pyindex 1ed05dbd3c..cb1acfd742 100644--- a/enterprise/storage/jira_dc_workspace.py+++ b/enterprise/storage/jira_dc_workspace.py@@ -1,22 +1,26 @@-from sqlalchemy import Column, DateTime, Integer, String, text+from datetime import datetime++from sqlalchemy import DateTime, String, text+from sqlalchemy.orm import Mapped, mapped_columnfrom storage.base import Base-class JiraDcWorkspace(Base): # type: ignore+class JiraDcWorkspace(Base):__tablename__ = 'jira_dc_workspaces'- id = Column(Integer, primary_key=True, autoincrement=True)- name = Column(String, nullable=False)- admin_user_id = Column(String, nullable=False)- webhook_secret = Column(String, nullable=False)- svc_acc_email = Column(String, nullable=False)- svc_acc_api_key = Column(String, nullable=False)- status = Column(String, nullable=False)- created_at = Column(++ id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)+ name: Mapped[str] = mapped_column(String, nullable=False)+ admin_user_id: Mapped[str] = mapped_column(String, nullable=False)+ webhook_secret: Mapped[str] = mapped_column(String, nullable=False)+ svc_acc_email: Mapped[str] = mapped_column(String, nullable=False)+ svc_acc_api_key: Mapped[str] = mapped_column(String, nullable=False)+ status: Mapped[str] = mapped_column(String, nullable=False)+ created_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),nullable=False,)- updated_at = Column(+ updated_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),onupdate=text('CURRENT_TIMESTAMP'),diff --git a/enterprise/storage/jira_user.py b/enterprise/storage/jira_user.pyindex 5fcde8b4d0..f7f914ec0a 100644--- a/enterprise/storage/jira_user.py+++ b/enterprise/storage/jira_user.py@@ -1,20 +1,24 @@-from sqlalchemy import Column, DateTime, Integer, String, text+from datetime import datetime++from sqlalchemy import DateTime, String, text+from sqlalchemy.orm import Mapped, mapped_columnfrom storage.base import Base-class JiraUser(Base): # type: ignore+class JiraUser(Base):__tablename__ = 'jira_users'- id = Column(Integer, primary_key=True, autoincrement=True)- keycloak_user_id = Column(String, nullable=False, index=True)- jira_user_id = Column(String, nullable=False, index=True)- jira_workspace_id = Column(Integer, nullable=False, index=True)- status = Column(String, nullable=False)- created_at = Column(++ id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)+ keycloak_user_id: Mapped[str] = mapped_column(String, nullable=False, index=True)+ jira_user_id: Mapped[str] = mapped_column(String, nullable=False, index=True)+ jira_workspace_id: Mapped[int] = mapped_column(nullable=False, index=True)+ status: Mapped[str] = mapped_column(String, nullable=False)+ created_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),nullable=False,)- updated_at = Column(+ updated_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),onupdate=text('CURRENT_TIMESTAMP'),diff --git a/enterprise/storage/jira_workspace.py b/enterprise/storage/jira_workspace.pyindex 828d872fc4..3d085ba68d 100644--- a/enterprise/storage/jira_workspace.py+++ b/enterprise/storage/jira_workspace.py@@ -1,23 +1,27 @@-from sqlalchemy import Column, DateTime, Integer, String, text+from datetime import datetime++from sqlalchemy import DateTime, String, text+from sqlalchemy.orm import Mapped, mapped_columnfrom storage.base import Base-class JiraWorkspace(Base): # type: ignore+class JiraWorkspace(Base):__tablename__ = 'jira_workspaces'- id = Column(Integer, primary_key=True, autoincrement=True)- name = Column(String, nullable=False)- jira_cloud_id = Column(String, nullable=False)- admin_user_id = Column(String, nullable=False)- webhook_secret = Column(String, nullable=False)- svc_acc_email = Column(String, nullable=False)- svc_acc_api_key = Column(String, nullable=False)- status = Column(String, nullable=False)- created_at = Column(++ id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)+ name: Mapped[str] = mapped_column(String, nullable=False)+ jira_cloud_id: Mapped[str] = mapped_column(String, nullable=False)+ admin_user_id: Mapped[str] = mapped_column(String, nullable=False)+ webhook_secret: Mapped[str] = mapped_column(String, nullable=False)+ svc_acc_email: Mapped[str] = mapped_column(String, nullable=False)+ svc_acc_api_key: Mapped[str] = mapped_column(String, nullable=False)+ status: Mapped[str] = mapped_column(String, nullable=False)+ created_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),nullable=False,)- updated_at = Column(+ updated_at: Mapped[datetime] = mapped_column(DateTime,server_default=text('CURRENT_TIMESTAMP'),onupdate=text('CURRENT_TIMESTAMP'),