Closed harsimrat99 closed 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
This is a complicated series of tasks. Please let me know if there are any questions.
Thank you for your co-operation.
-Harsimrat
Thanks for the detailed steps @harsimrat99 . I have added the email_verification
migration schema and pushed it to this branch.
Committed the example that harsimrat gave :)
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
Thank you @Lepabryce and @qingyuan-wu for your help in making the migrations. :)
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:
Make a backup of the cloudclub database.
Drop the pre-existing cloudclub database.
Create an empty database called "cloudclub".
Checkout this branch in your development environment.
Run
npm i
in the command line to install all packages.Add 2 new env. vars. to your .env file. (I will communicate those to you)
Run this command at the root of the repository:
npx db-migrate up --config .\database\database.json
Check the database to ensure that there are 6 new tables inside it.
Create a new migration using this command:
npx db-migrate create create_<TABLENAME>_table --config .\database\database.json
Populate the newly created migration file under the migrations directory to create a new table.
Re-run step 7 to create the new table.