mirror of
https://github.com/ArthurDanjou/artdanj-shortener.git
synced 2026-01-14 15:54:08 +01:00
26 lines
676 B
TypeScript
26 lines
676 B
TypeScript
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|
|
|
export default class Links extends BaseSchema {
|
|
protected tableName = 'links'
|
|
|
|
public async up () {
|
|
this.schema.createTable(this.tableName, (table) => {
|
|
table.increments('id').primary()
|
|
table.string('code').notNullable()
|
|
table.string('target').notNullable()
|
|
table.string('type').defaultTo('PERMANENT')
|
|
table.timestamp('expire').defaultTo(this.now())
|
|
table
|
|
.integer('author_id')
|
|
.unsigned()
|
|
.references('users.id')
|
|
.onDelete('CASCADE')
|
|
table.timestamps(true)
|
|
})
|
|
}
|
|
|
|
public async down () {
|
|
this.schema.dropTable(this.tableName)
|
|
}
|
|
}
|