bed5c7abef
- Separate workspace landing from login for better UX - Referral system rewards both parties with Pro days - Quota enforcement prevents abuse without breaking endpoints - 7-day free trial with auto-downgrade on expiry - Admin-managed search provider config (SearXNG, Bing) - 15% discount on annual subscriptions - MCP search server wrapping opencode search - Fix discovery module field name mismatch causing 422
67 lines
2.9 KiB
Python
67 lines
2.9 KiB
Python
"""add search_providers table
|
|
|
|
Revision ID: 7fe16f1f9962
|
|
Revises: ecab04cc0e1d
|
|
Create Date: 2026-05-25 10:18:37.103091
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
revision: str = '7fe16f1f9962'
|
|
down_revision: Union[str, None] = 'ecab04cc0e1d'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('referral_codes',
|
|
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column('code', sa.String(length=20), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_referral_codes_code'), 'referral_codes', ['code'], unique=True)
|
|
op.create_index(op.f('ix_referral_codes_user_id'), 'referral_codes', ['user_id'], unique=False)
|
|
op.create_table('referrals',
|
|
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column('referrer_id', postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column('referred_id', postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column('code', sa.String(length=20), nullable=False),
|
|
sa.Column('reward_days', sa.Integer(), nullable=True),
|
|
sa.Column('status', sa.String(length=20), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('referred_id')
|
|
)
|
|
op.create_index(op.f('ix_referrals_referrer_id'), 'referrals', ['referrer_id'], unique=False)
|
|
op.create_table('search_providers',
|
|
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column('name', sa.String(length=100), nullable=False),
|
|
sa.Column('provider_type', sa.String(length=50), nullable=False),
|
|
sa.Column('api_key', sa.Text(), nullable=True),
|
|
sa.Column('api_endpoint', sa.String(length=500), nullable=True),
|
|
sa.Column('extra_config', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
|
sa.Column('priority', sa.Integer(), nullable=True),
|
|
sa.Column('enabled', sa.Boolean(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('search_providers')
|
|
op.drop_index(op.f('ix_referrals_referrer_id'), table_name='referrals')
|
|
op.drop_table('referrals')
|
|
op.drop_index(op.f('ix_referral_codes_user_id'), table_name='referral_codes')
|
|
op.drop_index(op.f('ix_referral_codes_code'), table_name='referral_codes')
|
|
op.drop_table('referral_codes')
|
|
# ### end Alembic commands ### |