This repository has been archived on 2026-02-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
shared/alembic/old_versions/20251021_add_user_and_magic_link.py
giles 668d9c7df8 feat: initial shared library extraction
Contains shared infrastructure for all coop services:
- shared/ (factory, urls, user_loader, context, internal_api, jinja_setup)
- models/ (User, Order, Calendar, Ticket, Product, Ghost CMS)
- db/ (SQLAlchemy async session, base)
- suma_browser/app/ (csrf, middleware, errors, authz, redis_cacher, payments, filters, utils)
- suma_browser/templates/ (shared base layouts, macros, error pages)
- static/ (CSS, JS, fonts, images)
- alembic/ (database migrations)
- config/ (app-config.yaml)
- editor/ (Lexical editor Node.js build)
- requirements.txt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:11:36 +00:00

48 lines
2.2 KiB
Python

"""add users and magic_links tables
Revision ID: 20251021_add_user_and_magic_link
Revises: a1b2c3d4e5f6 # <-- REPLACE with your actual head
Create Date: 2025-10-21
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '20251021_add_user_and_magic_link'
down_revision: Union[str, None] = '20251021211617' # <-- REPLACE THIS
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
'users',
sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True),
sa.Column('email', sa.String(length=255), nullable=False, unique=True),
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
sa.Column('last_login_at', sa.DateTime(timezone=True), nullable=True),
)
op.create_index('ix_users_email', 'users', ['email'], unique=True)
op.create_table(
'magic_links',
sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True),
sa.Column('token', sa.String(length=128), nullable=False, unique=True),
sa.Column('user_id', sa.Integer(), sa.ForeignKey('users.id', ondelete='CASCADE'), nullable=False),
sa.Column('purpose', sa.String(length=32), nullable=False),
sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False),
sa.Column('used_at', sa.DateTime(timezone=True), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
sa.Column('ip', sa.String(length=64), nullable=True),
sa.Column('user_agent', sa.String(length=256), nullable=True),
)
op.create_index('ix_magic_links_token', 'magic_links', ['token'], unique=True)
op.create_index('ix_magic_links_user', 'magic_links', ['user_id'])
def downgrade() -> None:
op.drop_index('ix_magic_links_user', table_name='magic_links')
op.drop_index('ix_magic_links_token', table_name='magic_links')
op.drop_table('magic_links')
op.drop_index('ix_users_email', table_name='users')
op.drop_table('users')