refactor(quota): canonical <entity>_<action> taxonomy for quota events
The quota-attribution action keys were inconsistent (mixed verbs, ad-hoc names, English-only labels). Introduce a QuotaAction constants holder (one source of truth), rename every attribution call site to it, and add migration 0020 to rename historical quota_events.action values. The display label now resolves from i18n (quotaActions.<key>, EN/HU/DE) instead of a hard-coded English map. Scheduler job ids and progress phase labels are a separate namespace and are left untouched.
This commit is contained in:
parent
1ce035ca9e
commit
b23f805533
12 changed files with 151 additions and 33 deletions
51
backend/alembic/versions/0020_rename_quota_actions.py
Normal file
51
backend/alembic/versions/0020_rename_quota_actions.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
"""rename quota_events.action to the canonical <entity>_<action> taxonomy
|
||||
|
||||
Revision ID: 0020_rename_quota_actions
|
||||
Revises: 0019_user_yt_channel_id
|
||||
Create Date: 2026-06-19
|
||||
|
||||
The quota-attribution action keys were inconsistent (mixed verbs, ad-hoc names). Rename the
|
||||
stored historical values to the canonical scheme defined in app.quota.QuotaAction:
|
||||
``<entity>_<action>``, snake_case, explicit pull/push. Pure data migration on quota_events;
|
||||
fully reversible. (Scheduler job ids and progress phase labels are a separate namespace and
|
||||
are NOT touched.)
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "0020_rename_quota_actions"
|
||||
down_revision: Union[str, None] = "0019_user_yt_channel_id"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
# old action value -> new canonical key (mirrors app.quota.QuotaAction).
|
||||
RENAMES: list[tuple[str, str]] = [
|
||||
("sync_subscriptions", "subscriptions_pull"),
|
||||
("subscription_resync", "subscriptions_resync"),
|
||||
("playlist_sync", "playlists_pull"),
|
||||
("playlist_push", "playlists_push"),
|
||||
("playlist_delete", "playlists_delete"),
|
||||
("backfill_recent", "videos_backfill_recent"),
|
||||
("backfill_deep", "videos_backfill_full"),
|
||||
("enrich", "videos_enrich"),
|
||||
("video_lookup", "videos_lookup"),
|
||||
("discovery", "channels_discover"),
|
||||
("subscribe", "channels_subscribe"),
|
||||
("unsubscribe", "channels_unsubscribe"),
|
||||
("maintenance", "maintenance_revalidate"),
|
||||
("api", "other"),
|
||||
]
|
||||
|
||||
_SQL = sa.text("UPDATE quota_events SET action = :to WHERE action = :frm")
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
for frm, to in RENAMES:
|
||||
op.execute(_SQL.bindparams(frm=frm, to=to))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
for frm, to in RENAMES:
|
||||
op.execute(_SQL.bindparams(frm=to, to=frm))
|
||||
Loading…
Add table
Add a link
Reference in a new issue