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>
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = "0007_add_oid_entries"
|
|
down_revision = "0006_update_calendar_entries"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Add order_id column
|
|
op.add_column(
|
|
"calendar_entries",
|
|
sa.Column("order_id", sa.Integer(), nullable=True),
|
|
)
|
|
op.create_foreign_key(
|
|
"fk_calendar_entries_order_id",
|
|
"calendar_entries",
|
|
"orders",
|
|
["order_id"],
|
|
["id"],
|
|
ondelete="SET NULL",
|
|
)
|
|
op.create_index(
|
|
"ix_calendar_entries_order_id",
|
|
"calendar_entries",
|
|
["order_id"],
|
|
unique=False,
|
|
)
|
|
|
|
# Optional: add an index on state if you want faster queries by state
|
|
op.create_index(
|
|
"ix_calendar_entries_state",
|
|
"calendar_entries",
|
|
["state"],
|
|
unique=False,
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
# Drop indexes and FK in reverse order
|
|
op.drop_index("ix_calendar_entries_state", table_name="calendar_entries")
|
|
|
|
op.drop_index("ix_calendar_entries_order_id", table_name="calendar_entries")
|
|
op.drop_constraint(
|
|
"fk_calendar_entries_order_id",
|
|
"calendar_entries",
|
|
type_="foreignkey",
|
|
)
|
|
op.drop_column("calendar_entries", "order_id")
|