gabriel / musehub public

0055_dmca_hold_missing_tables.py file-level

at sha256:3 · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:2 refactor: rename 0054/0055 migrations to standard convention Remove ha… · gabriel · May 28, 2026
1 """0055_dmca_hold_missing_tables
2
3 Revision ID: 0055
4 Revises: 0054
5 Create Date: 2026-05-11 20:09:22.365298+00:00
6
7 """
8 from __future__ import annotations
9
10 from typing import Sequence, Union
11
12 from alembic import op
13 import sqlalchemy as sa
14 from sqlalchemy.dialects import postgresql
15
16 # revision identifiers, used by Alembic.
17 revision: str = '0055'
18 down_revision: Union[str, None] = '0054'
19 branch_labels: Union[str, Sequence[str], None] = None
20 depends_on: Union[str, Sequence[str], None] = None
21
22
23 def upgrade() -> None:
24 # ### commands auto generated by Alembic - please adjust! ###
25 op.create_table('musehub_blocked_hashes',
26 sa.Column('object_id', sa.String(length=128), nullable=False),
27 sa.Column('reason', sa.Text(), nullable=True),
28 sa.Column('added_by', sa.String(length=128), nullable=True),
29 sa.Column('added_at', sa.DateTime(timezone=True), nullable=False),
30 sa.PrimaryKeyConstraint('object_id')
31 )
32 op.create_table('musehub_daily_push_bytes',
33 sa.Column('identity_id', sa.String(length=128), nullable=False),
34 sa.Column('date', sa.Date(), nullable=False),
35 sa.Column('bytes_uploaded', sa.BigInteger(), nullable=False),
36 sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False),
37 sa.PrimaryKeyConstraint('identity_id', 'date')
38 )
39 op.create_index('ix_daily_push_bytes_identity_date', 'musehub_daily_push_bytes', ['identity_id', 'date'], unique=False)
40 op.create_table('musehub_push_anomalies',
41 sa.Column('anomaly_id', sa.String(length=128), nullable=False),
42 sa.Column('identity_id', sa.String(length=128), nullable=False),
43 sa.Column('detected_at', sa.DateTime(timezone=True), nullable=False),
44 sa.Column('bytes_today', sa.BigInteger(), nullable=False),
45 sa.Column('rolling_avg_bytes', sa.Float(), nullable=False),
46 sa.Column('ratio', sa.Float(), nullable=False),
47 sa.PrimaryKeyConstraint('anomaly_id')
48 )
49 op.create_index(op.f('ix_musehub_push_anomalies_identity_id'), 'musehub_push_anomalies', ['identity_id'], unique=False)
50 op.create_index('ix_push_anomalies_identity', 'musehub_push_anomalies', ['identity_id'], unique=False)
51 op.create_table('musehub_stream_rejections',
52 sa.Column('rejection_id', sa.String(length=128), nullable=False),
53 sa.Column('repo_id', sa.String(length=128), nullable=False),
54 sa.Column('identity_id', sa.String(length=128), nullable=True),
55 sa.Column('reason', sa.String(length=32), nullable=False),
56 sa.Column('detail', sa.Text(), nullable=False),
57 sa.Column('rejected_at', sa.DateTime(timezone=True), nullable=False),
58 sa.ForeignKeyConstraint(['repo_id'], ['musehub_repos.repo_id'], ondelete='CASCADE'),
59 sa.PrimaryKeyConstraint('rejection_id')
60 )
61 op.create_index('ix_stream_rejections_identity', 'musehub_stream_rejections', ['identity_id'], unique=False)
62 op.create_index('ix_stream_rejections_repo', 'musehub_stream_rejections', ['repo_id'], unique=False)
63 op.add_column('musehub_background_jobs', sa.Column('quarantine_reason', sa.Text(), nullable=True))
64 op.add_column('musehub_repos', sa.Column('dmca_hold', sa.Boolean(), server_default=sa.text('false'), nullable=False))
65 op.alter_column('musehub_snapshots', 'manifest_blob',
66 existing_type=postgresql.BYTEA(),
67 nullable=True)
68 # ### end Alembic commands ###
69
70
71 def downgrade() -> None:
72 # ### commands auto generated by Alembic - please adjust! ###
73 op.alter_column('musehub_snapshots', 'manifest_blob',
74 existing_type=postgresql.BYTEA(),
75 nullable=False)
76 op.drop_column('musehub_repos', 'dmca_hold')
77 op.drop_column('musehub_background_jobs', 'quarantine_reason')
78 op.drop_index('ix_stream_rejections_repo', table_name='musehub_stream_rejections')
79 op.drop_index('ix_stream_rejections_identity', table_name='musehub_stream_rejections')
80 op.drop_table('musehub_stream_rejections')
81 op.drop_index('ix_push_anomalies_identity', table_name='musehub_push_anomalies')
82 op.drop_index(op.f('ix_musehub_push_anomalies_identity_id'), table_name='musehub_push_anomalies')
83 op.drop_table('musehub_push_anomalies')
84 op.drop_index('ix_daily_push_bytes_identity_date', table_name='musehub_daily_push_bytes')
85 op.drop_table('musehub_daily_push_bytes')
86 op.drop_table('musehub_blocked_hashes')
87 # ### end Alembic commands ###