I just ran an alembic upgrade on my postgresql db. The diff between "before" and "after" revealed that all tables were rewritten despite the fact that only some tables were modified. The change occured only in the datetime column like so:
< 202 dac1d06a-e9e1-4739-a80c-9ae913e345c3 2023-05-23 12:05:58.972111+00 199 \N 139 \N dut001 f \N script initial commit f
< 203 410ced4d-e2cf-4006-8cf0-f143f744f953 2023-05-23 12:05:58.980174+00 199 \N 141 201 duthandler t \N script initial commit f
> 202 dac1d06a-e9e1-4739-a80c-9ae913e345c3 2023-05-23 14:05:58.972111+02 199 \N 139 \N dut001 f \N script initial commit f
> 203 410ced4d-e2cf-4006-8cf0-f143f744f953 2023-05-23 14:05:58.980174+02 199 \N 141 201 duthandler t \N script initial commit f
The tables were initially generated via sqlalchemy:
class MyClass(Base):
__tablename__ = "alias_map_expanded"
seq2 = Sequence(name="seq2")
id = Column(
BigInteger, sumo_seq2, server_default=seq2.next_value(), primary_key=True
)
uuid = Column(
UUID(as_uuid=True), server_default=func.gen_random_uuid(), nullable=False
)
creation_date = Column(
DateTime(timezone=True), server_default=func.current_timestamp(), nullable=False
)
...
Now I already read about naive and non-naive timestamps and got an idea on how to get from one to the other in python, but I am really stuck with the question why that even happens during the upgrade and how to avoid having the timestamps changed all together.
Thanks in advance!