diff --git a/core/docs/changelog/WCM-291.change b/core/docs/changelog/WCM-291.change new file mode 100644 index 0000000000..51ab6534e1 --- /dev/null +++ b/core/docs/changelog/WCM-291.change @@ -0,0 +1 @@ +WCM-291: Add forgotten date_last_modified column diff --git a/core/src/zeit/connector/migrations/predeploy/20240918_0829-b7304b8f2b06_add_modified_publish_info_datetime_.py b/core/src/zeit/connector/migrations/predeploy/20240918_0829-b7304b8f2b06_add_timestamp_columns.py similarity index 97% rename from core/src/zeit/connector/migrations/predeploy/20240918_0829-b7304b8f2b06_add_modified_publish_info_datetime_.py rename to core/src/zeit/connector/migrations/predeploy/20240918_0829-b7304b8f2b06_add_timestamp_columns.py index dbed5d6681..8dc6913d72 100644 --- a/core/src/zeit/connector/migrations/predeploy/20240918_0829-b7304b8f2b06_add_modified_publish_info_datetime_.py +++ b/core/src/zeit/connector/migrations/predeploy/20240918_0829-b7304b8f2b06_add_timestamp_columns.py @@ -1,10 +1,11 @@ -"""add modified publish info datetime columns +"""add timestamp columns Revision ID: b7304b8f2b06 Revises: 9aba9394d011 Create Date: 2024-09-18 08:29:25.572847 """ + from typing import Sequence, Union from alembic import op diff --git a/core/src/zeit/connector/migrations/predeploy/20240926_1150-28355ecfa735_add_modified_column.py b/core/src/zeit/connector/migrations/predeploy/20240926_1150-28355ecfa735_add_modified_column.py new file mode 100644 index 0000000000..4fd20ae7cc --- /dev/null +++ b/core/src/zeit/connector/migrations/predeploy/20240926_1150-28355ecfa735_add_modified_column.py @@ -0,0 +1,30 @@ +"""add modified column + +(was forgotten in b7304b8f2b06) + +Revision ID: 28355ecfa735 +Revises: b7304b8f2b06 +Create Date: 2024-09-26 11:50:35.942786 +""" + +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '28355ecfa735' +down_revision: Union[str, None] = 'b7304b8f2b06' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + op.add_column( + 'properties', sa.Column('date_last_modified', sa.TIMESTAMP(timezone=True), nullable=True) + ) + + +def downgrade() -> None: + op.drop_column('properties', 'date_last_modified') diff --git a/core/src/zeit/connector/models.py b/core/src/zeit/connector/models.py index c35a9622de..04b937e1e6 100644 --- a/core/src/zeit/connector/models.py +++ b/core/src/zeit/connector/models.py @@ -66,6 +66,10 @@ class Modified: TIMESTAMP, info={'namespace': 'document', 'name': 'date_last_checkout'}, ) + date_last_modified = mapped_column( + TIMESTAMP, + info={'namespace': 'document', 'name': 'date_last_modified'}, + ) class PublishInfo: diff --git a/core/src/zeit/connector/tests/test_migrations.py b/core/src/zeit/connector/tests/test_migrations.py index 88ac71a2de..99e2cf53ac 100644 --- a/core/src/zeit/connector/tests/test_migrations.py +++ b/core/src/zeit/connector/tests/test_migrations.py @@ -56,6 +56,12 @@ def _dump(sql, *args, **kw): # for example `USING gin (mycolumn jsonb_path_ops)` metadata.reflect(connection) + # We don't care about column order here. (sqlalchemy sorts them in + # python source declaration order, but migrations sort them in + # chronological add order, since postgres can only append columns). + for table in metadata.tables.values(): + table.columns._collection.sort() # XXX internal API, might break. + result = [] engine = sqlalchemy.create_mock_engine( 'postgresql://',