From 03a34521d58598301d7bceb0b750a84182e56f5d Mon Sep 17 00:00:00 2001 From: tramplay <65968861+vencho-mdp@users.noreply.github.com> Date: Mon, 7 Feb 2022 11:56:30 -0300 Subject: [PATCH 1/2] Use async / await syntax in seeds as default --- lib/migrations/seed/stub/js.stub | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/migrations/seed/stub/js.stub b/lib/migrations/seed/stub/js.stub index 980bca05c6..c81f0ee6a1 100644 --- a/lib/migrations/seed/stub/js.stub +++ b/lib/migrations/seed/stub/js.stub @@ -2,15 +2,13 @@ * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.seed = function(knex) { +exports.seed = async function(knex) { // Deletes ALL existing entries - return knex('table_name').del() - .then(function () { - // Inserts seed entries - return knex('table_name').insert([ - {id: 1, colName: 'rowValue1'}, - {id: 2, colName: 'rowValue2'}, - {id: 3, colName: 'rowValue3'} - ]); - }); + await knex('table_name').del() + await knex('table_name').insert([ + {id: 1, colName: 'rowValue1'}, + {id: 2, colName: 'rowValue2'}, + {id: 3, colName: 'rowValue3'} + ]); + return knex }; From c783ba865c241baee97e4da1b3fc5bb46a3b62c7 Mon Sep 17 00:00:00 2001 From: tramplay <65968861+vencho-mdp@users.noreply.github.com> Date: Tue, 8 Feb 2022 19:53:15 -0300 Subject: [PATCH 2/2] Update js.stub --- lib/migrations/seed/stub/js.stub | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/migrations/seed/stub/js.stub b/lib/migrations/seed/stub/js.stub index c81f0ee6a1..d0e6540316 100644 --- a/lib/migrations/seed/stub/js.stub +++ b/lib/migrations/seed/stub/js.stub @@ -10,5 +10,4 @@ exports.seed = async function(knex) { {id: 2, colName: 'rowValue2'}, {id: 3, colName: 'rowValue3'} ]); - return knex };