mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 12:14:33 +01:00
@@ -1,17 +0,0 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class Subscribers extends BaseSchema {
|
||||
protected tableName = 'subscribers'
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').primary()
|
||||
table.string('email').notNullable()
|
||||
table.timestamps(true, true)
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class Pictures extends BaseSchema {
|
||||
protected tableName = 'files'
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').primary()
|
||||
table.string('label').notNullable()
|
||||
table.string('file_name').notNullable()
|
||||
table.timestamps(true, true)
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class Posts extends BaseSchema {
|
||||
protected tableName = 'posts'
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').primary()
|
||||
table.string('slug').notNullable()
|
||||
table.integer('likes').notNullable()
|
||||
table.timestamps(true, true)
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class Locations extends BaseSchema {
|
||||
protected tableName = 'locations'
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').primary()
|
||||
table.string('place')
|
||||
table.string('left')
|
||||
table.date('since')
|
||||
table.timestamps(true, true)
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class Projects extends BaseSchema {
|
||||
protected tableName = 'projects'
|
||||
|
||||
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.timestamps(true, true)
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class Forms extends BaseSchema {
|
||||
protected tableName = 'forms'
|
||||
|
||||
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.timestamps(true, true)
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
import Hash from "@ioc:Adonis/Core/Hash";
|
||||
|
||||
export default class Users extends BaseSchema {
|
||||
protected tableName = 'users'
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').primary()
|
||||
table.string('username', 255).notNullable()
|
||||
table.string('email', 255).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()
|
||||
table.timestamps(true, true)
|
||||
})
|
||||
}
|
||||
|
||||
private randomPassword(): string {
|
||||
let password = ''
|
||||
const char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!.:=+-_$*^&@#%ù/àçè()é"'
|
||||
const size = 64
|
||||
for (let i = 0; i < size; i++) {
|
||||
password += char.charAt(Math.random() * char.length)
|
||||
}
|
||||
Hash.make(password).then((value => {
|
||||
password = value
|
||||
}))
|
||||
return password
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class ApiTokens extends BaseSchema {
|
||||
protected tableName = 'api_tokens'
|
||||
|
||||
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.string('name').notNullable()
|
||||
table.string('type').notNullable()
|
||||
table.string('token', 64).notNullable()
|
||||
table.timestamp('expires_at', { useTz: true }).nullable()
|
||||
table.timestamps(true, true)
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user