CloudClub-uoft / cloud-club-website

Club Website
https://cloudclub.ca
4 stars 4 forks source link

Wadhawan enhancement migrations db-migrate #87

Closed harsimrat99 closed 2 years ago

harsimrat99 commented 2 years ago

Hi @Lepabryce and @qingyuan-wu ,

I am creating this branch so that we can experiment with version controlling our database with the help of migrations. Currently, I have opted to use the db-migrate module as a DB migration tool. I have avoided Sequelize's built-in migration tool so that we are not locked into Sequelize's way of work.

It will be helpful if you could please try the following steps to understand how to create a migration. I am hoping that this knowledge will help you in creating migrations for tables required in PRs #86 and #82.

Steps:

  1. Make a backup of the cloudclub database.

  2. Drop the pre-existing cloudclub database.

  3. Create an empty database called "cloudclub".

  4. Checkout this branch in your development environment.

  5. Run npm i in the command line to install all packages.

  6. Add 2 new env. vars. to your .env file. (I will communicate those to you)

  7. Run this command at the root of the repository: npx db-migrate up --config .\database\database.json

  8. Check the database to ensure that there are 6 new tables inside it.

  9. Create a new migration using this command: npx db-migrate create create_<TABLENAME>_table --config .\database\database.json

  10. Populate the newly created migration file under the migrations directory to create a new table.

  11. Re-run step 7 to create the new table.

harsimrat99 commented 2 years ago

Attaching an example of the migration for creating the password_reset table for @Lepabryce's PR. @qingyuan-wu please use this file as an example for modifying an existing table, or creating any new tables for your PR (email_verification, logins table modification).

Reference: Adding columns

migration_pwd_reset.txt

This is a complicated series of tasks. Please let me know if there are any questions.

Thank you for your co-operation.

-Harsimrat

qingyuan-wu commented 2 years ago

Thanks for the detailed steps @harsimrat99 . I have added the email_verification migration schema and pushed it to this branch.

Lepabryce commented 2 years ago

Committed the example that harsimrat gave :)

harsimrat99 commented 2 years ago

Hi @qingyuan-wu ,

It will be helpful if you could please make the pending changes that you mentioned in the meeting today so that we can merge this branch.

Thank you, Harsimrat

harsimrat99 commented 2 years ago

Thank you @Lepabryce and @qingyuan-wu for your help in making the migrations. :)