generated from shillerben/adonis-fullstack-app
Initial commit
This commit is contained in:
21
database/factory.js
Normal file
21
database/factory.js
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict'
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Factory
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories are used to define blueprints for database tables or Lucid
|
||||
| models. Later you can use these blueprints to seed your database
|
||||
| with dummy data.
|
||||
|
|
||||
*/
|
||||
|
||||
/** @type {import('@adonisjs/lucid/src/Factory')} */
|
||||
// const Factory = use('Factory')
|
||||
|
||||
// Factory.blueprint('App/Models/User', (faker) => {
|
||||
// return {
|
||||
// username: faker.username()
|
||||
// }
|
||||
// })
|
||||
22
database/migrations/1503248427885_user.js
Normal file
22
database/migrations/1503248427885_user.js
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict'
|
||||
|
||||
/** @type {import('@adonisjs/lucid/src/Schema')} */
|
||||
const Schema = use('Schema')
|
||||
|
||||
class UserSchema extends Schema {
|
||||
up () {
|
||||
this.create('users', (table) => {
|
||||
table.increments()
|
||||
table.string('username', 80).notNullable().unique()
|
||||
table.string('email', 254).notNullable().unique()
|
||||
table.string('password', 60).notNullable()
|
||||
table.timestamps()
|
||||
})
|
||||
}
|
||||
|
||||
down () {
|
||||
this.drop('users')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = UserSchema
|
||||
23
database/migrations/1503248427886_token.js
Normal file
23
database/migrations/1503248427886_token.js
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict'
|
||||
|
||||
/** @type {import('@adonisjs/lucid/src/Schema')} */
|
||||
const Schema = use('Schema')
|
||||
|
||||
class TokensSchema extends Schema {
|
||||
up () {
|
||||
this.create('tokens', (table) => {
|
||||
table.increments()
|
||||
table.integer('user_id').unsigned().references('id').inTable('users')
|
||||
table.string('token', 255).notNullable().unique().index()
|
||||
table.string('type', 80).notNullable()
|
||||
table.boolean('is_revoked').defaultTo(false)
|
||||
table.timestamps()
|
||||
})
|
||||
}
|
||||
|
||||
down () {
|
||||
this.drop('tokens')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TokensSchema
|
||||
Reference in New Issue
Block a user