Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Utilise flask-migrate to support SQLAlchemy migration using alembic #211

Open
mtreacy002 opened this issue Mar 9, 2021 · 10 comments
Assignees
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Type: Maintenance Repository maintenance.

Comments

@mtreacy002
Copy link
Member

mtreacy002 commented Mar 9, 2021

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

At the moment BIT backend doesn't have db migration management. This will cause issue in case we have to alter the database schemas.

Describe the solution you'd like

Utilise flask-migrate to handle SQLalchemy schemas migration using Alembic.

Describe alternatives you've considered

To simplify migration script, bit and ms schema can be integrated as one schema. This is only possible when the idea proposed on zulip discussion is approved (to fully integrate BIT backend into MS backend).

Additional context

The migration script/s should be able to handle the multiple schemas accordingly.
I have attempted this before using the following files (while the initial migration was successfully created, there's still work to be done like sorting out how to read the changes made to bit_schema)

@mtreacy002 mtreacy002 added Category: Coding Changes to code base or refactored code that doesn't fix a bug. Status: Available Issue was approved and available to claim or abandoned for over 3 days. Type: Maintenance Repository maintenance. labels Mar 9, 2021
@mtreacy002 mtreacy002 changed the title Feat: Add a migration script to manage changes on database schemas Feat: Utilise flask-migrate to support SQLAlchemy migration using alembic Mar 9, 2021
@Amulya-coder
Copy link
Member

@mtreacy002 now it's open to OSH contributors they'll surely pick this issue.

@mtreacy002
Copy link
Member Author

mtreacy002 commented Mar 28, 2021

@Amulya-coder , would this be a bit hard for the new contributors? I'm not sure if it's a good idea to open it as OSH issue. 🤔.

@epicadk
Copy link
Member

epicadk commented Mar 28, 2021

Agreed it doesn't seem like a good issue for OSH

@decon-harsh
Copy link
Member

@mtreacy002 I can give it a try

@mtreacy002
Copy link
Member Author

Ok, @decon-harsh , you can pick up the issue. Thank you 😉

@mtreacy002 mtreacy002 removed the Status: Available Issue was approved and available to claim or abandoned for over 3 days. label Mar 28, 2021
@mtreacy002
Copy link
Member Author

@decon-harsh , I've shared the files I worked on before in the issue description. Feel free to ask anything if you're in doubt.

@decon-harsh
Copy link
Member

Hey @mtreacy002 need some help

When I followed the docs and made migration

Tables of only public schema were getting created. Why is it happening?

  • Screenshot from 2021-03-30 11-28-34

  • Screenshot from 2021-03-30 11-32-40

  • Screenshot from 2021-03-30 11-33-00

  • Screenshot from 2021-03-30 11-33-02

I used your gist, the upgrade & downgrade function only had pass. So I was unable to get the exact idea of what was happening.

@decon-harsh
Copy link
Member

decon-harsh commented Mar 30, 2021

Then I made a new empty database, and made migrations there,

  • Screenshot from 2021-03-30 12-28-08

  • Screenshot from 2021-03-30 12-28-14

  • Screenshot from 2021-03-30 12-28-22

  • Screenshot from 2021-03-30 12-28-25

  • Screenshot from 2021-03-30 12-28-29

All tables were getting created. I am pretty confused ,What do we want in the end?

@mtreacy002
Copy link
Member Author

mtreacy002 commented Mar 30, 2021

🤔. It seems like we cannot avoid recreating the db from scratch if we want to have the correct schema. I don't think it's a bad idea considering we still in very early stage of development.
@decon-harsh , can you check with the new db you've created from running migration, when you change the program_id attribute in the mentorship_relation_extension model to not unique, does the change get applied to the db correctly? You should be able to see a new version under migration folder an sql syntax alter db in pgadmin4 on the table if this is successful.

@decon-harsh
Copy link
Member

There is an issue regarding that @mtreacy002 i cannot upgrade that migration because in line 67 there is more than 255 arguments getting passed which throws that error , however when I checked about it and it said it was removed in python3.7 version but i was using that only.

Now I have to pass it as a list there.
Will share you the error and ll try that method in the morning.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Type: Maintenance Repository maintenance.
Projects
None yet
Development

No branches or pull requests

4 participants