2.4 Create Todo table via knex-migrate

wb todoMVC Master >> 2.4 create todo table via knex-migr…

Steps

Open terminal & navigate to your project’s root folder

$ cd ~/Sites/swag/todo-api

Create the boiler plate todo table initialization script

$ knex migrate:make create_todo

Open your favorite editor and navigate to your migrations folder and open {timestamp}_create_todo.js.

cd ~/Sites/swag/todo-api/.knex/migrations

Your boiler plate migration script should look like the below:

Now we’re a going to reference our data model that we defined in swagger to help guide us while defining the todo table schema.

Modifiy your {timestamp}_create_todo.js to look like the below code.

Now run

$ knex migrate:latest --debug

AND

$ knex migrate:latest --debug --env test

DONE!! It should look something like the below. (I’m using “medium” instead of “todo_dev” to write this tutorial)

Tutorial Navigation

The master tutorial doc is located here: WB todoMVC MASTER

Previous Step: 2.3 install knex / knex-migrate

Next Step: [pending]

Show your support

Clapping shows how much you appreciated Will Barnes’s story.