gabriel / musehub public
0008_auth_key_algorithm.py python
57 lines 1.6 KB
Raw
sha256:a10adeeb7a0169cb9900f9806ed7a973047258abb6283724fe55e8eb68ff3f0a init: musehub initial commit Human 171 days ago
1 """Add algorithm column and widen public_key_b64 to Text on musehub_auth_keys.
2
3 Quantum-readiness migration: the auth key table now carries an algorithm
4 identifier so Ed25519 and future post-quantum algorithms (ML-DSA-65 / FIPS 204)
5 can coexist. The public_key_b64 column is widened from VARCHAR(64) to TEXT
6 because ML-DSA-65 public keys are 1952 bytes → ~2604 base64 chars.
7
8 All existing rows default to "ed25519" — no data migration required.
9
10 Revision ID: 0008
11 Revises: 0007
12 """
13 from __future__ import annotations
14
15 import sqlalchemy as sa
16 from alembic import op
17
18 revision = "0008"
19 down_revision = "0007"
20 branch_labels = None
21 depends_on = None
22
23
24 def upgrade() -> None:
25 # Add algorithm column with "ed25519" as the default for existing rows
26 op.add_column(
27 "musehub_auth_keys",
28 sa.Column(
29 "algorithm",
30 sa.String(32),
31 nullable=False,
32 server_default="ed25519",
33 ),
34 )
35 # Widen public_key_b64 from VARCHAR(64) to TEXT for post-quantum keys
36 op.alter_column(
37 "musehub_auth_keys",
38 "public_key_b64",
39 type_=sa.Text(),
40 existing_nullable=False,
41 )
42 op.create_index(
43 "ix_musehub_auth_keys_algorithm",
44 "musehub_auth_keys",
45 ["algorithm"],
46 )
47
48
49 def downgrade() -> None:
50 op.drop_index("ix_musehub_auth_keys_algorithm", table_name="musehub_auth_keys")
51 op.alter_column(
52 "musehub_auth_keys",
53 "public_key_b64",
54 type_=sa.String(64),
55 existing_nullable=False,
56 )
57 op.drop_column("musehub_auth_keys", "algorithm")
File History 1 commit
sha256:a10adeeb7a0169cb9900f9806ed7a973047258abb6283724fe55e8eb68ff3f0a init: musehub initial commit Human 171 days ago