/u3_lab_sequelize_migrations_exercise

In this lab, we'll practice Sequelize commands and migrations.

Primary LanguageJavaScript

Sequelize Migrations Exercise

Objectives

  • Practice running migrations
  • Fixing schema errors
  • Renaming columns, tables and changing field types

Getting Started

  • Fork and Clone

Step 1: Installing Dependencies

npm install

Ensure our tests run correctly:

npm run test

Step 2: Setting Up Our Database

sequelize db:create
sequelize db:migrate
psql sequelize_migrations_lab_development

\dt

Lab

READ ALL THE INSTRUCTIONS BEFORE PERFORMING ANY ACTIONS, DOING OTHERWISE WILL ENSURE THAT YOU HAVE TO START OVER

All operations need to be completed in order! You'll be creating migrations for each step. Run sequelize db:migrate after each step unless directed otherwise. Check your work often using npm run test and psql to check the table names and columns.

  1. Businesses has a huge problem, the table is uppercased! Fix the table name to be lowercased and plural. HINT: Look at the Business model for the correct tableName.

  2. Locations shares the same problem as Businesses, correct the table naming conflict.

If you've completed steps 1 and 2, at this point you can run the provided seed files, sequelize db:seed:all.

  1. The businesses table phoneNmber column is spelled incorrectly, the column should be phoneNumber, create a migration to rename the column name. Once the migration is successful, you'll need to make sure to update the Business model.

  2. The businesses table has another problem, the businessName column is redundant, rename this field to just name. Run your migration and make the necessary modifications in the Business model. Remember the businessName key should reference the new name column.

At this point you should have 4 passing tests

Resources