Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.

Commit 672ea05

Browse files
committed
modify migration/seed js format
1 parent 173cc1a commit 672ea05

File tree

2 files changed

+21
-28
lines changed

2 files changed

+21
-28
lines changed

Diff for: migrations/20180720184521_user.js

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
exports.up = function (knex, Promise) {
2-
return knex.schema.createTable('user', (table) => {
3-
table.increments('id')
4-
table.dateTime('created_at').notNull().defaultTo(knex.fn.now())
5-
table.dateTime('updated_at').nullable()
6-
table.dateTime('deleted_at').nullable()
7-
8-
table.string('name', 50).notNull()
9-
table.string('email', 100).notNull()
10-
table.string('password', 200).notNull()
1+
exports.up = async (knex) => {
2+
await knex.schema.createTable('user', (t) => {
3+
t.increments()
4+
t.timestamps(false, true)
5+
t.string('name', 50).notNull()
6+
t.string('email', 100).notNull()
7+
t.string('password', 200).notNull()
118
})
12-
};
9+
}
1310

14-
exports.down = function (knex, Promise) {
15-
return knex.schema.dropTable('user')
16-
};
11+
exports.down = async(knex) {
12+
await knex.schema.dropTable('user')
13+
}

Diff for: seeds/01_user.js

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
const md5 = require('md5')
22

3-
exports.seed = function (knex, Promise) {
4-
// Deletes ALL existing entries
5-
return knex('user').del()
6-
.then(function () {
7-
// Inserts seed entries
8-
return knex('user').insert([
9-
{
10-
name: 'Test User',
11-
12-
password: md5('u53rtest'),
13-
},
14-
]);
15-
});
16-
};
3+
exports.seed = async (knex) => {
4+
await knex('user').del()
5+
await knex('user').insert([
6+
{
7+
name: 'Test User',
8+
9+
password: md5('u53rtest'),
10+
},
11+
])
12+
}

0 commit comments

Comments
 (0)