Rework migrations schemes

This commit is contained in:
2021-08-16 22:32:08 +02:00
parent e22e0b55c5
commit 09e5b2f76f
11 changed files with 32 additions and 37 deletions

View File

@@ -6,9 +6,9 @@ export default class Locations extends BaseSchema {
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary()
table.string('place')
table.string('left')
table.date('since')
table.string('place').notNullable()
table.string('left').notNullable()
table.date('since').notNullable()
table.timestamps(true, true)
})
}

View File

@@ -6,10 +6,15 @@ export default class Projects extends BaseSchema {
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary()
table.string('name')
table.string('description')
table.string('url')
table.integer('progress')
table.string('name').notNullable()
table.string('description').notNullable()
table.string('url').notNullable()
table.integer('progress').notNullable()
table
.integer('file_id')
.unsigned()
.references('files.id')
.onDelete('CASCADE')
table.timestamps(true, true)
})
}

View File

@@ -6,10 +6,10 @@ export default class Forms extends BaseSchema {
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary()
table.string('name')
table.string('email')
table.string('subject')
table.string('content')
table.string('name').notNullable()
table.string('email').notNullable()
table.string('subject').notNullable()
table.string('content').notNullable()
table.timestamps(true, true)
})
}

View File

@@ -9,7 +9,10 @@ export default class Users extends BaseSchema {
table.increments('id').primary()
table.string('username', 255).notNullable()
table.string('email', 255).notNullable()
table.string('password', 180).defaultTo(this.randomPassword()).notNullable()
table
.string('password', 180)
.defaultTo(this.randomPassword())
.notNullable()
table.boolean('is_confirmed').defaultTo(false).notNullable()
table.string('remember_me_token').defaultTo(null).nullable()
table.string('confirmation_token').defaultTo(null).nullable()

View File

@@ -6,7 +6,11 @@ export default class ApiTokens extends BaseSchema {
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary()
table.integer('user_id').unsigned().references('id').inTable('users').onDelete('CASCADE')
table.integer('user_id')
.unsigned()
.references('id')
.inTable('users')
.onDelete('CASCADE')
table.string('name').notNullable()
table.string('type').notNullable()
table.string('token', 64).notNullable()

View File

@@ -11,7 +11,7 @@ export default class GuestbookMessages extends BaseSchema {
.unsigned()
.references('users.id')
.onDelete('CASCADE')
table.text('message')
table.text('message').notNullable()
table.timestamps(true, true)
})
}

View File

@@ -5,7 +5,7 @@ export default class Translations extends BaseSchema {
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.increments('id').primary()
table.string('code').notNullable()
table.string('french').defaultTo('Traduction manquante')
table.string('english').defaultTo('Missing translation')

View File

@@ -1,17 +0,0 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
export default class Projects extends BaseSchema {
protected tableName = 'projects'
public async up () {
this.schema.table(this.tableName, (table) => {
table.integer('file_id').unsigned().references('files.id').onDelete('CASCADE')
})
}
public async down () {
this.schema.table(this.tableName, (table) => {
table.dropColumn('file_id')
})
}
}

View File

@@ -5,8 +5,8 @@ export default class Announces extends BaseSchema {
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.string('color')
table.increments('id').primary()
table.string('color').notNullable()
table.string('hover_color')
table
.integer('translation_id')

View File

@@ -5,8 +5,8 @@ export default class Skills extends BaseSchema {
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.string('name')
table.increments('id').primary()
table.string('name').notNullable()
table
.integer('file_id')
.unsigned()

View File

@@ -5,7 +5,7 @@ export default class Informations extends BaseSchema {
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.increments('id').primary()
table.integer('age').notNullable()
table
.integer('translation_id')