This project uses Node v20.
The database itself is missing in this project, run the following command to create a database using migrations and seeds
npm run start
or
node index.js
that is the same.
The database will appear in src/database folder (src/database/db.sqlite)
Use DB Browser for SQLite see the contents of the generated database https://sqlitebrowser.org/dl/
This guide outlines how to create database migrations using Knex, a SQL query builder.
npx knex migrate:make create_some_table
This command will create a new file in the migrations directory src/database/migrations
with a timestamp prefixed filename,
e.g.: 20200916135224_create_some_table.js
npx knex migrate:latest
npx knex migrate:rollback
Seeds are used to populate your database with initial or sample data. Basically you use knex CLI to create a seed file:
node create_seed.js name_of_yor_new_seed_file
The script will create a new file in the seeds directory src/database/seeds
with a timestamp prefixed filename,
e.g.: 20200916135224_name_you_provided.js
and example content will be added to the file.
We recommend using the following script because Knex itself doesn't add timestamps to seed names. This additional functionality ensures that the seeds will be executed in the right order.