PythonNest / PyNest

PyNest is a Python framework built on top of FastAPI that follows the modular architecture of NestJS
https://pythonnest.github.io/PyNest
MIT License
666 stars 47 forks source link

[FeatureRequest] Add Support for Database Migrations with Alembic #17

Open ItayTheDar opened 9 months ago

ItayTheDar commented 9 months ago

Is your feature request related to a problem? Please describe.

As applications evolve, changes in the database structure are often required, and managing these changes across different environments and different instances of the database can become challenging. Currently, PyNest users handle database schema changes manually, which is error-prone and not scalable.

Describe the solution you'd like

Implementing database migration support using Alembic could streamline this process. Alembic is a lightweight database migration tool for SQLAlchemy and is widely used in the Python community.

Integration of Alembic would allow developers to:

Proposed Implementation

  1. Alembic Configuration: Set up Alembic in the PyNest project, including the alembic.ini file for configuration and the env.py script to specify the database connection and other settings.

  2. Migration Scripts: Introduce commands to generate automatic migration scripts based on changes detected in the SQLAlchemy models. These scripts should be reviewed and edited as necessary before being applied.

  3. Documentation: Update the project documentation to include detailed instructions on creating migration scripts, applying migrations to the database, and common Alembic commands and practices.

  4. Testing: Ensure robust testing procedures are in place for migrations, possibly in a staging environment before deployment, to ensure that changes will not adversely affect the current application.

Additional context

Implementing Alembic migrations would make the PyNest framework more robust and production-ready, simplifying schema change management and reducing the risk of database-related errors during deployment.

We believe this feature is in line with PyNest's goals of scalability and maintainability, empowering developers to handle database changes more efficiently and reliably.

Request for Contributors

We welcome contributions from the community for this enhancement. Please feel free to discuss your approach, propose changes to the proposed implementation, or submit a PR addressing this issue.

khaledadrani commented 7 months ago

Hello, need a hand?

ItayTheDar commented 7 months ago

Hi @khaledadrani, i would super appreciate your help on this one! Didn't find the time to work on this

ItayTheDar commented 2 months ago

@khaledadrani Hi Hi, I know it's been a while, but are there any chance that you manage to create something?

khaledadrani commented 2 months ago

Hello @ItayTheDar , I am sorry, I forgot completely. I remember that I tried to start something. I believe I did make some notes about the current architecture of the framework. I will return to it and I will inform you shortly (in this weekend)

ItayTheDar commented 2 months ago

@khaledadrani Can't wait for it!!