Skip to content

Commit

Permalink
Merge pull request #129 from story-squad/update/words
Browse files Browse the repository at this point in the history
Update/words
  • Loading branch information
trevorjamesmartin authored Apr 1, 2021
2 parents 39ad0fd + ef863bf commit 3b25fed
Show file tree
Hide file tree
Showing 142 changed files with 561 additions and 497 deletions.
9 changes: 9 additions & 0 deletions data/migrations/20210401182811_word-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// rename the "Played" table to "Score"

exports.up = function (knex) {
return knex.schema.renameTable("Words", "words");
};

exports.down = function (knex) {
return knex.schema.renameTable("words", "Words");
};
23 changes: 23 additions & 0 deletions data/migrations/20210401182916_word-upgrade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const tableName = "words";
// alter score table to include timestamps & points
exports.up = async function (knex) {
await knex.schema.alterTable(tableName, function (tbl) {
// add timestamps
tbl.timestamps(false, true);
tbl.string("format", 255).defaultTo("word");
});

await knex.raw(`
CREATE TRIGGER update_timestamp
BEFORE UPDATE
ON ${tableName}
FOR EACH ROW
EXECUTE PROCEDURE update_timestamp();`);
};

exports.down = async function (knex) {
await knex.schema.alterTable(tableName, function (tbl) {
tbl.dropTimestamps();
tbl.dropColumns(["format"]);
});
};
2 changes: 1 addition & 1 deletion data/seeds/01-words.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ const words = [
};
});
exports.seed = function (knex) {
return knex("Words").insert(words);
return knex("words").insert(words);
};
2 changes: 1 addition & 1 deletion data/seeds/03-big_chonk_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.seed = async function (knex) {
total -= chunk.length;
start += chunk.length;
try {
await knex("Words").insert(chunk);
await knex("words").insert(chunk);
inserts += 1;
} catch (err) {
// console.log(err)
Expand Down
9 changes: 9 additions & 0 deletions dist/data/migrations/20210401182811_word-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// rename the "Played" table to "Score"

exports.up = function (knex) {
return knex.schema.renameTable("Words", "words");
};

exports.down = function (knex) {
return knex.schema.renameTable("words", "Words");
};
23 changes: 23 additions & 0 deletions dist/data/migrations/20210401182916_word-upgrade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const tableName = "words";
// alter score table to include timestamps & points
exports.up = async function (knex) {
await knex.schema.alterTable(tableName, function (tbl) {
// add timestamps
tbl.timestamps(false, true);
tbl.string("format", 255).defaultTo("word");
});

await knex.raw(`
CREATE TRIGGER update_timestamp
BEFORE UPDATE
ON ${tableName}
FOR EACH ROW
EXECUTE PROCEDURE update_timestamp();`);
};

exports.down = async function (knex) {
await knex.schema.alterTable(tableName, function (tbl) {
tbl.dropTimestamps();
tbl.dropColumns(["format"]);
});
};
2 changes: 1 addition & 1 deletion dist/data/seeds/01-words.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ const words = [
};
});
exports.seed = function (knex) {
return knex("Words").insert(words);
return knex("words").insert(words);
};
2 changes: 1 addition & 1 deletion dist/data/seeds/03-big_chonk_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.seed = async function (knex) {
total -= chunk.length;
start += chunk.length;
try {
await knex("Words").insert(chunk);
await knex("words").insert(chunk);
inserts += 1;
} catch (err) {
// console.log(err)
Expand Down
4 changes: 2 additions & 2 deletions dist/src/api/admin/model.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/src/api/game/model.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions dist/src/api/words/model.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3b25fed

Please sign in to comment.