generated from HackYourFuture-CPH/boilerplate-for-fp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from HackYourFuture-CPH/createSeeds
Create seeds
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
packages/server/migrations/20240416153144_drop_retro_id_column.js
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,27 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = async (knex) => { | ||
await knex.raw( | ||
'ALTER TABLE `Questions` DROP CONSTRAINT questions_retro_id_foreign', | ||
); | ||
await knex.schema.alterTable('Questions', (table) => { | ||
table.dropColumn('retro_id'); | ||
}); | ||
}; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = async (knex) => { | ||
await knex.schema.alterTable('Answers', (table) => { | ||
table | ||
.integer('retro_id') | ||
.unsigned() | ||
.notNullable() | ||
.references('id') | ||
.inTable('Retro'); | ||
}); | ||
}; |
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,14 @@ | ||
exports.seed = function (knex) { | ||
// Deletes all existing entries | ||
return knex('Questions') | ||
.del() | ||
.then(() => { | ||
// Inserts seed entries | ||
return knex('Questions').insert([ | ||
{ id: 1, title: 'What went well?', color: 'green' }, | ||
{ id: 2, title: "What didn't go well?", color: 'red' }, | ||
{ id: 3, title: 'What can be improved?', color: 'yellow' }, | ||
{ id: 4, title: 'Any other comments?', color: 'blue' }, | ||
]); | ||
}); | ||
}; |
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,14 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.seed = async function (knex) { | ||
// Deletes ALL existing entries | ||
await knex('Teams').insert([ | ||
{ team_name: 'Team A', team_code: 'A001' }, | ||
{ team_name: 'Team B', team_code: 'B002' }, | ||
{ team_name: 'Team C', team_code: 'C003' }, | ||
{ team_name: 'Team D', team_code: 'D004' }, | ||
{ team_name: 'Team E', team_code: 'E005' }, | ||
]); | ||
}; |