"""器谱_设备配对与逐项授契 Revision ID: 010 Revises: 009 Create Date: 2026-08-28 09:25:57.705846 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision: str = '010' down_revision: Union[str, Sequence[str], None] = '009' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: """Upgrade schema.""" # ### commands auto generated by Alembic - please adjust! ### op.create_table('device_grants', sa.Column('id', sa.String(length=80), nullable=False), sa.Column('device_id', sa.String(length=80), nullable=False), sa.Column('owner_scope', sa.String(length=80), nullable=False), sa.Column('capability', sa.String(length=60), nullable=False), sa.Column('scope_json', sa.Text(), nullable=False), sa.Column('status', sa.String(length=20), nullable=False), sa.Column('granted_at', sa.DateTime(timezone=True), nullable=False), sa.Column('revoked_at', sa.DateTime(timezone=True), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_device_grants_capability'), 'device_grants', ['capability'], unique=False) op.create_index(op.f('ix_device_grants_device_id'), 'device_grants', ['device_id'], unique=False) op.create_index(op.f('ix_device_grants_owner_scope'), 'device_grants', ['owner_scope'], unique=False) op.create_index(op.f('ix_device_grants_status'), 'device_grants', ['status'], unique=False) op.create_table('devices', sa.Column('id', sa.String(length=80), nullable=False), sa.Column('owner_scope', sa.String(length=80), nullable=False), sa.Column('kind', sa.String(length=30), nullable=False), sa.Column('name', sa.String(length=120), nullable=False), sa.Column('key_fingerprint', sa.String(length=128), nullable=False), sa.Column('status', sa.String(length=20), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), sa.Column('last_seen_at', sa.DateTime(timezone=True), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_devices_owner_scope'), 'devices', ['owner_scope'], unique=False) op.create_index(op.f('ix_devices_status'), 'devices', ['status'], unique=False) op.drop_index(op.f('ix_character_profile_candidates_character_id'), table_name='character_profile_candidates') op.drop_index(op.f('ix_character_profile_candidates_import_job_id'), table_name='character_profile_candidates') op.drop_index(op.f('ix_character_profile_candidates_status'), table_name='character_profile_candidates') op.drop_table('character_profile_candidates') op.drop_index(op.f('ix_memory_candidates_character_id'), table_name='memory_candidates') op.drop_index(op.f('ix_memory_candidates_cycle_id'), table_name='memory_candidates') op.drop_index(op.f('ix_memory_candidates_import_job_id'), table_name='memory_candidates') op.drop_index(op.f('ix_memory_candidates_status'), table_name='memory_candidates') op.drop_table('memory_candidates') # ### end Alembic commands ### def downgrade() -> None: """Downgrade schema.""" # ### commands auto generated by Alembic - please adjust! ### op.create_table('memory_candidates', sa.Column('id', sa.VARCHAR(length=80), nullable=False), sa.Column('character_id', sa.VARCHAR(length=80), nullable=False), sa.Column('import_job_id', sa.VARCHAR(length=80), nullable=True), sa.Column('cycle_id', sa.VARCHAR(length=80), nullable=True), sa.Column('type', sa.VARCHAR(length=60), nullable=False), sa.Column('title', sa.VARCHAR(length=200), nullable=False), sa.Column('content', sa.TEXT(), nullable=False), sa.Column('confidence', sa.FLOAT(), nullable=False), sa.Column('importance', sa.FLOAT(), nullable=False), sa.Column('sensitivity', sa.VARCHAR(length=40), nullable=False), sa.Column('evidence_ids_json', sa.TEXT(), nullable=False), sa.Column('status', sa.VARCHAR(length=40), nullable=False), sa.Column('reason', sa.TEXT(), nullable=True), sa.Column('reviewed_at', sa.DATETIME(), nullable=True), sa.Column('created_at', sa.DATETIME(), nullable=False), sa.Column('updated_at', sa.DATETIME(), nullable=False), sa.ForeignKeyConstraint(['character_id'], ['characters.id'], ), sa.ForeignKeyConstraint(['cycle_id'], ['big_cycles.id'], ), sa.ForeignKeyConstraint(['import_job_id'], ['character_import_jobs.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_memory_candidates_status'), 'memory_candidates', ['status'], unique=False) op.create_index(op.f('ix_memory_candidates_import_job_id'), 'memory_candidates', ['import_job_id'], unique=False) op.create_index(op.f('ix_memory_candidates_cycle_id'), 'memory_candidates', ['cycle_id'], unique=False) op.create_index(op.f('ix_memory_candidates_character_id'), 'memory_candidates', ['character_id'], unique=False) op.create_table('character_profile_candidates', sa.Column('id', sa.VARCHAR(length=80), nullable=False), sa.Column('character_id', sa.VARCHAR(length=80), nullable=False), sa.Column('import_job_id', sa.VARCHAR(length=80), nullable=True), sa.Column('field', sa.VARCHAR(length=60), nullable=False), sa.Column('value', sa.TEXT(), nullable=False), sa.Column('confidence', sa.FLOAT(), nullable=False), sa.Column('evidence_ids_json', sa.TEXT(), nullable=False), sa.Column('status', sa.VARCHAR(length=40), nullable=False), sa.Column('reason', sa.TEXT(), nullable=True), sa.Column('reviewed_at', sa.DATETIME(), nullable=True), sa.Column('created_at', sa.DATETIME(), nullable=False), sa.Column('updated_at', sa.DATETIME(), nullable=False), sa.ForeignKeyConstraint(['character_id'], ['characters.id'], ), sa.ForeignKeyConstraint(['import_job_id'], ['character_import_jobs.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_character_profile_candidates_status'), 'character_profile_candidates', ['status'], unique=False) op.create_index(op.f('ix_character_profile_candidates_import_job_id'), 'character_profile_candidates', ['import_job_id'], unique=False) op.create_index(op.f('ix_character_profile_candidates_character_id'), 'character_profile_candidates', ['character_id'], unique=False) op.drop_index(op.f('ix_devices_status'), table_name='devices') op.drop_index(op.f('ix_devices_owner_scope'), table_name='devices') op.drop_table('devices') op.drop_index(op.f('ix_device_grants_status'), table_name='device_grants') op.drop_index(op.f('ix_device_grants_owner_scope'), table_name='device_grants') op.drop_index(op.f('ix_device_grants_device_id'), table_name='device_grants') op.drop_index(op.f('ix_device_grants_capability'), table_name='device_grants') op.drop_table('device_grants') # ### end Alembic commands ###