Junior — Middle
What types of migrations have you used when working with SQLAlchemy?
sobes.tech AI
Answer from AI
When working with SQLAlchemy for managing migrations, Alembic is usually used — a tool for database schema versioning.
Types of migrations applied:
- Automatic migrations: Alembic can automatically generate migration scripts based on changes in SQLAlchemy models.
- Manual migrations: sometimes it is necessary to write migrations manually for complex changes (e.g., data transformation).
- Rollback migrations: each migration typically contains instructions for applying and rolling back, allowing safe schema version management.
Example command for generating a migration:
alembic revision --autogenerate -m "Adding a new column"
Thus, when working with SQLAlchemy, both automatic and manual migrations are used to manage changes in the database structure.