Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WCM-291: Add forgotten date_last_modified column #861

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/docs/changelog/WCM-291.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WCM-291: Add forgotten date_last_modified column
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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')
4 changes: 4 additions & 0 deletions core/src/zeit/connector/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions core/src/zeit/connector/tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://',
Expand Down