# Model Generators

Custom SQLAlchemy model generators used by `sqlacodegen`.

## What is sqlacodegen?

[sqlacodegen](https://github.com/agronholm/sqlacodegen) is a tool that reads database schemas and generates corresponding SQLAlchemy model code. We use it to:

- Generate models from existing database tables
- Maintain consistency across models
- Speed up model creation for consolidation
- Apply Abacus-specific conventions automatically

## Available Generators

### [`AbacusGenerator`](./abacus/abacus_generator.py)

Custom generator for Abacus platform models with SQLAlchemy 2.0 patterns.

## Usage

```bash
# Make and edit your .env
cp .env.shadow .env

# Generate the models
make generate
```

## Best Practices

Generated models are a starting point. Always review and refine:
1. Relationship directions (one-to-many vs many-to-one)
1. Type annotations
1. Domain-specific conventions
1. Custom methods or properties

## Resources

- **sqlacodegen Documentation**: https://github.com/agronholm/sqlacodegen
- **SQLAlchemy 2.0 Documentation**: https://docs.sqlalchemy.org/en/20/
