Skip to content

Commit

Permalink
adding .mjs migration and seed stubs (#4631)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlhunter committed Aug 21, 2021
1 parent 5ac4224 commit e469766
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/migrations/migrate/stub/mjs.stub
@@ -0,0 +1,15 @@

export const up = async (knex) => {
<% if (d.tableName) { %>
await knex.schema.createTable("<%= d.tableName %>", function(t) {
t.increments();
t.timestamp();
});
<% } %>
};

export const down = async (knex) => {
<% if (d.tableName) { %>
await knex.schema.dropTable("<%= d.tableName %>");
<% } %>
};
12 changes: 12 additions & 0 deletions lib/migrations/seed/stub/mjs.stub
@@ -0,0 +1,12 @@

export const seed = async (knex) => {
// Deletes ALL existing entries
await knex('table_name').del();

// Inserts seed entries
await knex('table_name').insert([
{id: 1, colName: 'rowValue1'},
{id: 2, colName: 'rowValue2'},
{id: 3, colName: 'rowValue3'}
]);
};

0 comments on commit e469766

Please sign in to comment.