- Add VkConnection model with is_online/last_checked_at fields - Add /vk OAuth flow (connect/callback/disconnect/page) - Add VK entry to connections dashboard - Extend background health checker to check VK tokens via users.get - Add Alembic migration for vk_connections table - Add VK_CLIENT_ID/SECRET/SCOPES/API_VERSION config settings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
"""add vk_connections table
|
|
|
|
Revision ID: b2c3d4e5f6a7
|
|
Revises: a1b2c3d4e5f6
|
|
Create Date: 2026-03-06 00:01:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = 'b2c3d4e5f6a7'
|
|
down_revision = 'a1b2c3d4e5f6'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
'vk_connections',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('access_token', sa.Text(), nullable=False),
|
|
sa.Column('vk_user_id', sa.String(50), nullable=True),
|
|
sa.Column('first_name', sa.String(255), nullable=True),
|
|
sa.Column('last_name', sa.String(255), nullable=True),
|
|
sa.Column('is_online', sa.Boolean(), nullable=False, server_default='0'),
|
|
sa.Column('last_checked_at', sa.DateTime(), nullable=True),
|
|
sa.Column('connected_at', sa.DateTime(), nullable=False, server_default=sa.func.now()),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=False, server_default=sa.func.now(), onupdate=sa.func.now()),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('user_id'),
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table('vk_connections')
|