- Start the postgresql server using brew and ensure relaunch on login more
$ brew services start postgresql
If needed, install postgresql
with $ brew install postgresql
and note the version installed.
- Create a postgres database to use
$ psql postgres
psql> CREATE DATABASE kale;
Note the ending semi-colon ;
- Install postgresql sequelize and sequelize cli for your project
$ npm i --save pg sequelize sequelize-cli
- Run the sequelize init command
$ node_modules/.bin/sequelize init
This will create the folders config
, migrations
, models
and seeders
- Create the model and migration files
$ node_modules/.bin/sequelize model:generate --name User \
--attributes firstName:string,lastName:string,email:string
This will:
-
Create a
user
model file in ourmodels
directory -
Create a timestamped migration file in our
migrations
directory -
Run the migration
$ node_modules/.bin/sequelize db:migrate