Skip to content

Commit 323555d

Browse files
authored
fix: Use BigInteger for *_time colums
When using Postgres time value as integer dosn't fit in 4 bytes integer which raises psycopg2.errors.NumericValueOutOfRange
1 parent 576fecf commit 323555d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

jupyter_scheduler/orm.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from uuid import uuid4
44

55
import sqlalchemy.types as types
6-
from sqlalchemy import Boolean, Column, Integer, String, create_engine, inspect
6+
from sqlalchemy import Boolean, Column, Integer, BigInteger, String, create_engine, inspect
77
from sqlalchemy.orm import declarative_base, declarative_mixin, registry, sessionmaker
88
from sqlalchemy.sql import text
99

@@ -83,8 +83,8 @@ class CommonColumns:
8383
max_retries = Column(Integer, default=0)
8484
min_retry_interval_millis = Column(Integer, default=0)
8585
output_filename_template = Column(String(256))
86-
update_time = Column(Integer, default=get_utc_timestamp, onupdate=get_utc_timestamp)
87-
create_time = Column(Integer, default=get_utc_timestamp)
86+
update_time = Column(BigInteger().with_variant(Integer, "sqlite"), default=get_utc_timestamp, onupdate=get_utc_timestamp)
87+
create_time = Column(BigInteger().with_variant(Integer, "sqlite"), default=get_utc_timestamp)
8888
# All new columns added to this table must be nullable to ensure compatibility during database migrations.
8989
# Any default values specified for new columns will be ignored during the migration process.
9090
package_input_folder = Column(Boolean)
@@ -98,8 +98,8 @@ class Job(CommonColumns, Base):
9898
job_definition_id = Column(String(36))
9999
status = Column(String(64), default=Status.STOPPED)
100100
status_message = Column(String(1024))
101-
start_time = Column(Integer)
102-
end_time = Column(Integer)
101+
start_time = Column(BigInteger().with_variant(Integer, "sqlite"))
102+
end_time = Column(BigInteger().with_variant(Integer, "sqlite"))
103103
url = Column(String(256), default=generate_jobs_url)
104104
pid = Column(Integer)
105105
idempotency_token = Column(String(256))
@@ -114,7 +114,6 @@ class JobDefinition(CommonColumns, Base):
114114
schedule = Column(String(256))
115115
timezone = Column(String(36))
116116
url = Column(String(256), default=generate_job_definitions_url)
117-
create_time = Column(Integer, default=get_utc_timestamp)
118117
active = Column(Boolean, default=True)
119118
# All new columns added to this table must be nullable to ensure compatibility during database migrations.
120119
# Any default values specified for new columns will be ignored during the migration process.

0 commit comments

Comments
 (0)