π OpenHands: AI-Driven Development
fix(enterprise): migrate Linear models to SQLAlchemy 2.0 [10/13] (#13856)
Rohit Malhotra1509018ee274
diff --git a/enterprise/storage/linear_conversation.py b/enterprise/storage/linear_conversation.pyindex d911a69459..15bff4db78 100644--- a/enterprise/storage/linear_conversation.py+++ b/enterprise/storage/linear_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 LinearConversation(Base): # type: ignore+class LinearConversation(Base):__tablename__ = 'linear_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)- linear_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)+ linear_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/linear_user.py b/enterprise/storage/linear_user.pyindex a3ff2de43f..459fccd309 100644--- a/enterprise/storage/linear_user.py+++ b/enterprise/storage/linear_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 LinearUser(Base): # type: ignore+class LinearUser(Base):__tablename__ = 'linear_users'- id = Column(Integer, primary_key=True, autoincrement=True)- keycloak_user_id = Column(String, nullable=False, index=True)- linear_user_id = Column(String, nullable=False, index=True)- linear_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)+ linear_user_id: Mapped[str] = mapped_column(String, nullable=False, index=True)+ linear_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/linear_workspace.py b/enterprise/storage/linear_workspace.pyindex 0f7774c685..cb6e1988b0 100644--- a/enterprise/storage/linear_workspace.py+++ b/enterprise/storage/linear_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 LinearWorkspace(Base): # type: ignore+class LinearWorkspace(Base):__tablename__ = 'linear_workspaces'- id = Column(Integer, primary_key=True, autoincrement=True)- name = Column(String, nullable=False)- linear_org_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)+ linear_org_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'),