blob: 168647f4a8a29e7451a6eb2099e2e040a776b0c6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
#
# SPDX-License-Identifier: BSD-3-Clause
"""Track the last successful source scan.
Revision ID: 2b4c6e8a0d12
Revises: ef8a9b6c2d41
"""
import sqlalchemy as sa
from alembic import op
revision = "2b4c6e8a0d12"
down_revision = "ef8a9b6c2d41"
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
"scan_state",
sa.Column("id", sa.Integer(), primary_key=True),
sa.Column("last_completed_at", sa.DateTime(timezone=True), nullable=False),
)
# Seed a best-effort historical completion time from previously scanned
# sources. The next completed scan will update the authoritative value.
op.execute(
sa.text(
"INSERT INTO scan_state (id, last_completed_at) "
"SELECT 1, MAX(last_seen_at) FROM source_documents "
"HAVING COUNT(*) > 0"
)
)
def downgrade():
op.drop_table("scan_state")
|