diff --git a/toardb/stationmeta/models_changelog.py b/toardb/stationmeta/models_changelog.py index 3848c9756dab4c00db06d7e2aa1a9829da4c6f80..f380265642287e10a4a8b136c349c4bb0561c832 100644 --- a/toardb/stationmeta/models_changelog.py +++ b/toardb/stationmeta/models_changelog.py @@ -10,15 +10,12 @@ from .models_core import StationmetaCore from toardb.auth_user.models import AuthUser from toardb.base import Base -STATIONMETA_CHANGELOG_ID_SEQ = Sequence('stationmeta_changelog_id_seq') # define sequence explicitly class StationmetaChangelog(Base): """ Table "public.stationmeta_changelog" +----------------+--------------------------+-----------+----------+--------------------------------------------------------+ | Column | Type | Collation | Nullable | Default | +================+==========================+===========+==========+========================================================+ - | id | bigint | | not null | nextval('stationmeta_changelog_id_seq'::regclass) | - +----------------+--------------------------+-----------+----------+--------------------------------------------------------+ | datetime | timestamp with time zone | | not null | now() | +----------------+--------------------------+-----------+----------+--------------------------------------------------------+ | station_id | bigint | | not null | | @@ -34,7 +31,7 @@ class StationmetaChangelog(Base): | author_id | integer | | not null | | +----------------+--------------------------+-----------+----------+--------------------------------------------------------+ Indexes: - "stationmeta_changelog_pkey" PRIMARY KEY, btree (id) + "timeseries_changelog_pkey" PRIMARY KEY, btree (datetime) Foreign-key constraints: "stationmeta_changelog_author_id_fk_auth_user_id" FOREIGN KEY (author_id) REFERENCES auth_user(id) "stationmeta_changelog_station_id_fk_stationmeta_core_id" FOREIGN KEY (station_id) REFERENCES stationmeta_core(id) @@ -42,8 +39,7 @@ class StationmetaChangelog(Base): """ __tablename__ = 'stationmeta_changelog' - id = Column(BigInteger, STATIONMETA_CHANGELOG_ID_SEQ, primary_key=True, server_default=STATIONMETA_CHANGELOG_ID_SEQ.next_value()) - datetime = Column(DateTime(True), nullable=False, server_default=text("now()")) + datetime = Column(DateTime(True), primary_key=True, nullable=False, server_default=text("now()")) description = Column(Text, nullable=False) old_value = Column(String(256), nullable=False) new_value = Column(String(256), nullable=False) diff --git a/toardb/stationmeta/schemas.py b/toardb/stationmeta/schemas.py index 520d3fcd48ac94ee61206aa29b49859ae9990082..cfb80467f5a4d5c3640050c65ada6a4ebc0179b3 100644 --- a/toardb/stationmeta/schemas.py +++ b/toardb/stationmeta/schemas.py @@ -452,7 +452,6 @@ class StationmetaRole(StationmetaRoleBase): # ======== StationmetaChangelog ========= class StationmetaChangelogBase(BaseModel): - id: int datetime: dt.datetime description: str old_value: str @@ -463,7 +462,6 @@ class StationmetaChangelogBase(BaseModel): class StationmetaChangelog(StationmetaChangelogBase): - id: int class Config: orm_mode = True diff --git a/toardb/timeseries/models_changelog.py b/toardb/timeseries/models_changelog.py index 235c464276273271ef3f7b12c7ba049f594fd3f9..6e97f382213207e49fe0aa4959da610e642d0bec 100644 --- a/toardb/timeseries/models_changelog.py +++ b/toardb/timeseries/models_changelog.py @@ -10,15 +10,12 @@ from .models_core import Timeseries from toardb.auth_user.models import AuthUser from toardb.base import Base -TIMESERIES_CHANGELOG_ID_SEQ = Sequence('timeseries_changelog_id_seq') # define sequence explicitly class TimeseriesChangelog(Base): """ Table "public.timeseries_changelog" +----------------+--------------------------+-----------+----------+--------------------------------------------------+ | Column | Type | Collation | Nullable | Default | +================+==========================+===========+==========+==================================================+ - | id | bigint | | not null | nextval('timeseries_changelog_id_seq'::regclass) | - +----------------+--------------------------+-----------+----------+--------------------------------------------------+ | datetime | timestamp with time zone | | not null | now() | +----------------+--------------------------+-----------+----------+--------------------------------------------------+ | timeseries_id | bigint | | not null | | @@ -40,7 +37,7 @@ class TimeseriesChangelog(Base): | author_id | integer | | not null | | +----------------+--------------------------+-----------+----------+--------------------------------------------------+ Indexes: - "timeseries_changelog_pkey" PRIMARY KEY, btree (id) + "timeseries_changelog_pkey" PRIMARY KEY, btree (datetime) Foreign-key constraints: "timeseries_changelog_author_id_fk_auth_user_id" FOREIGN KEY (author_id) REFERENCES auth_user(id) "timeseries_changelog_timeseries_id_fk_timeseries_id" FOREIGN KEY (timeseries_id) REFERENCES timeseries(id) @@ -49,8 +46,7 @@ class TimeseriesChangelog(Base): __tablename__ = 'timeseries_changelog' - id = Column(BigInteger, TIMESERIES_CHANGELOG_ID_SEQ, primary_key=True, server_default=TIMESERIES_CHANGELOG_ID_SEQ.next_value()) - datetime = Column(DateTime(True), nullable=False, server_default=text("now()")) + datetime = Column(DateTime(True), primary_key=True, nullable=False, server_default=text("now()")) description = Column(Text, nullable=False) old_value = Column(String(256), nullable=False) new_value = Column(String(256), nullable=False) diff --git a/toardb/timeseries/schemas.py b/toardb/timeseries/schemas.py index 8abc5f148abb50624199e2d24df212f6c5ed260d..6be64c7c473090e4ac3967763e5414197510ba8d 100644 --- a/toardb/timeseries/schemas.py +++ b/toardb/timeseries/schemas.py @@ -201,7 +201,6 @@ class TimeseriesProgramme(TimeseriesProgrammeBase): # ======== TimeseriesChangelog ========= class TimeseriesChangelogBase(BaseModel): - id: int datetime: dt.datetime description: str old_value: str @@ -215,7 +214,6 @@ class TimeseriesChangelogBase(BaseModel): class TimeseriesChangelog(TimeseriesChangelogBase): - id: int class Config: orm_mode = True