gabriel / musehub public
0072_fetch_mpack_cache.py python
57 lines 1.7 KB
Raw
sha256:5dfc96524e3921eb9acb8372241b6bec70b5f3e6598f79099a0ead16ff7cbb75 feat(phase1): add musehub_fetch_mpack_cache table (issue #9… Sonnet 4.6 patch 21 hours ago
1 """Add musehub_fetch_mpack_cache table.
2
3 Pre-built fetch mpacks are cached here after every push so that
4 wire_fetch_mpack can return a presigned URL immediately (sub-second)
5 instead of building the mpack synchronously in the request path.
6
7 Revision ID: 0072
8 Revises: 0071
9 """
10 from __future__ import annotations
11
12 import sqlalchemy as sa
13 from alembic import op
14
15 revision: str = "0072"
16 down_revision: str = "0071"
17 branch_labels = None
18 depends_on = None
19
20
21 def upgrade() -> None:
22 op.create_table(
23 "musehub_fetch_mpack_cache",
24 sa.Column("cache_id", sa.String(128), primary_key=True),
25 sa.Column("repo_id", sa.String(128), nullable=False),
26 sa.Column("tip_commit_id", sa.String(128), nullable=False),
27 sa.Column("mpack_id", sa.String(128), nullable=False),
28 sa.Column(
29 "created_at",
30 sa.DateTime(timezone=True),
31 nullable=False,
32 server_default=sa.text("now()"),
33 ),
34 sa.Column(
35 "expires_at",
36 sa.DateTime(timezone=True),
37 nullable=False,
38 server_default=sa.text("now() + interval '7 days'"),
39 ),
40 )
41 op.create_index(
42 "ix_fetch_mpack_cache_repo_tip",
43 "musehub_fetch_mpack_cache",
44 ["repo_id", "tip_commit_id"],
45 unique=True,
46 )
47 op.create_index(
48 "ix_fetch_mpack_cache_expires_at",
49 "musehub_fetch_mpack_cache",
50 ["expires_at"],
51 )
52
53
54 def downgrade() -> None:
55 op.drop_index("ix_fetch_mpack_cache_expires_at", table_name="musehub_fetch_mpack_cache")
56 op.drop_index("ix_fetch_mpack_cache_repo_tip", table_name="musehub_fetch_mpack_cache")
57 op.drop_table("musehub_fetch_mpack_cache")
File History 1 commit
sha256:5dfc96524e3921eb9acb8372241b6bec70b5f3e6598f79099a0ead16ff7cbb75 feat(phase1): add musehub_fetch_mpack_cache table (issue #9… Sonnet 4.6 patch 21 hours ago