dipdup-io / dipdup

Modular framework for creating selective indexers and featureful backends for dapps
https://dipdup.io
MIT License
97 stars 52 forks source link

Database migrations with Aerich #1107

Closed droserasprout closed 1 month ago

droserasprout commented 1 month ago

https://github.com/tortoise/aerich

mitarumi commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a developer with years of experience in backend development and devops. I am skilled in python, solidity and cairo. And have studied this repo extensively

How I plan on tackling this issue

I would install and initialize Aerich. And include the aerich model in the Tortoise orm config. Make any model changes (if necessary). Then create and apply a migration with Aerich commands.

bigherc18 commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have over 5 years of professional experience as a Python developer, I've been involved in the Starknet Community early on and I worked on data indexing projects as you can see in my OnlyDust profile. I’ve already explored the DipDup codebase, including key components like database management, and ORM integration. I'm set to start contributing right away, the project is installed in my machine, and I'm able to make changes and test them

How I plan on tackling this issue

I’ll begin by installing Aerich and experimenting with its migration workflow, ensuring I understand its integration with Tortoise ORM, running basics commands like aerich init, migrate, and upgrade.

I will modify the database initialization and connection management in files like database.py to include Aerich for migrations. Specifically: • Add Aerich’s migration logic into the existing Tortoise ORM setup, ensuring that migration commands (like init-db, migrate, and upgrade or their interal functions) can be executed seamlessly within DipDup either by calling them as shown in the README or importing the functions they call and call them mysefl (will see what works best later). • Update the configuration to include aerich.models in the Tortoise setup.

I'll write integration tests, first against SQLite and why not against Postgres as you already have run_postgres_container function in the tests folder

Finally, I will update the project’s docs to provide clear instructions on how to use Aerich within DipDup. The Aerich docs is surely a good starting point for this

bigherc18 commented 1 month ago

Hello, thank you for assigning me to this issue, I'll start working on it right now and I'll keep you posted.