Last active
September 13, 2019 15:09
-
-
Save kevinbreaker/457e5b9ede3576a057f4dc8929f807d1 to your computer and use it in GitHub Desktop.
Minhas migrations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
/** @type {import('@adonisjs/lucid/src/Schema')} */ | |
const Schema = use('Schema') | |
class AvaliationsSchema extends Schema { | |
up () { | |
this.create('avaliations', (table) => { | |
table.increments() | |
table | |
.string('user_email') | |
.unsigned() | |
.notNullable() | |
.references('id') | |
.inTable('users') | |
.onUpdate('CASCADE') | |
.onDelete('CASCADE') | |
table.string('comment', 400), | |
table.string('placeId', 255).notNullable() | |
table.integer('rating', 5).defaultTo(0) | |
table.timestamps() | |
}) | |
} | |
down () { | |
this.drop('avaliations') | |
} | |
} | |
module.exports = AvaliationsSchema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
/** @type {import('@adonisjs/lucid/src/Schema')} */ | |
const Schema = use('Schema') | |
class FavoritesSchema extends Schema { | |
up () { | |
this.create('favorites', (table) => { | |
table.increments() | |
table | |
.integer('user_id') | |
.unsigned() | |
.notNullable() | |
.references('id') | |
.inTable('users') | |
.onUpdate('CASCADE') | |
.onDelete('CASCADE') | |
table.string('placeId', 255).notNullable() | |
table.string('placeName', 255).notNullable() | |
table.string('placeIcon', 255) | |
table.timestamps() | |
}) | |
} | |
down () { | |
this.drop('favorites') | |
} | |
} | |
module.exports = FavoritesSchema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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('name', 80).notNullable() | |
table.string('email', 254).notNullable().unique() | |
table.string('password', 60).notNullable() | |
table.timestamps() | |
}) | |
} | |
down () { | |
this.drop('users') | |
} | |
} | |
module.exports = UserSchema |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment