-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ad7597
commit 6cbbd8f
Showing
9 changed files
with
68 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules/ | |
**/*.DS_Store | ||
**/*-secret.json | ||
**/*.sh | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
This folder contains a small codebase to setup a database with some content. | ||
The database will contain information about users their projects and tasks. | ||
Tasks can be assigned to users optionally which make for some nice example queries. | ||
|
||
Create a database called `db_qa_session` or make changes to the `knexfile.js` | ||
|
||
``` | ||
npm install | ||
npx knex migrate:latest | ||
npx knex seed:run | ||
``` | ||
|
||
Your database should be filled with some demo content :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
exports.seed = async (knex) => { | ||
|
||
await knex.raw('SET foreign_key_checks = 0;'); | ||
await knex('project_users').truncate(); | ||
await knex('tasks').truncate(); | ||
await knex('projects').truncate(); | ||
await knex('users').truncate(); | ||
await knex.raw('SET foreign_key_checks = 1;'); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const createRelation = (i) => ({ | ||
// user 2 to 9 will have projects | ||
user_id: 1 + Math.ceil(Math.random() * 8), | ||
// project 4 to 18 will have projects | ||
project_id: 3 + Math.ceil(Math.random() * 15) | ||
}) | ||
|
||
exports.seed = async function (knex) { | ||
|
||
const fakes = []; | ||
const amount = 30; | ||
for (let i = 0; i < amount; i++) { | ||
fakes.push(createRelation(i)); | ||
} | ||
|
||
await knex('project_users').insert(fakes); | ||
}; |