Skip to content

Extract reflex-orm package #6243

@masenf

Description

@masenf

Extract database functionality into a separately installable reflex-orm package as part of the monorepo split.

What reflex-orm Provides

  • rx.session — thin abstraction over SQLAlchemy engine/session, configured via REFLEX_DB_URL environment variable
  • reflex db subcommand — generates alembic.ini with proper configuration pointing at REFLEX_DB_URL, then delegates to standard Alembic commands
  • That's it. No custom migration logic, no wrapper ORM.

What It Removes

  • rx.Model — gone entirely. Users bring their own model base: DeclarativeBase, SQLModel, MappedAsDataclass, or whatever they prefer
  • All custom migration/autogenerate logic — standard Alembic handles this
  • Any implicit schema management magic

Motivation

The current rx.Model creates a parallel ORM that's always slightly behind SQLAlchemy, confuses users who already know SQLAlchemy, and is a maintenance burden. By getting out of the way, Reflex becomes compatible with the entire SQLAlchemy ecosystem (async sessions, partitioning, sharding, read replicas) without having to support it explicitly.

Tracking

Parent: ENG-9181 (Database & ORM Standardization)
Roadmap: #2727 — Section 5a

Metadata

Metadata

Assignees

No one assigned

    Labels

    roadmaphttps://github.com/reflex-dev/reflex/issues/2727

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions