fix(enterprise): migrate Linear models to SQLAlchemy 2.0 [10/13] (#13856)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Rohit Malhotra
2026-04-22 12:53:45 -04:00
committed by GitHub
co-authored by openhands
parent 1605e97d80
commit 1509018ee2
3 changed files with 43 additions and 31 deletions
+14 -10
View File
@@ -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_column
from 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'),
+13 -9
View File
@@ -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_column
from 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'),
+16 -12
View File
@@ -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_column
from 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'),