mirror of
https://github.com/ArthurDanjou/artdanj-shortener.git
synced 2026-01-14 15:54:08 +01:00
Add migrations
This commit is contained in:
10
database/migrations/1618757695309_links.ts → database/migrations/1634841204979_links.ts
Executable file → Normal file
10
database/migrations/1618757695309_links.ts → database/migrations/1634841204979_links.ts
Executable file → Normal file
@@ -5,10 +5,16 @@ export default class Links extends BaseSchema {
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.increments('id').primary()
|
||||
table.string('code').notNullable()
|
||||
table.string('target').notNullable()
|
||||
table.integer('visit_count').defaultTo(0)
|
||||
table.string('type').defaultTo('PERMANENT')
|
||||
table.timestamp('expire').defaultTo(this.now())
|
||||
table
|
||||
.integer('author_id')
|
||||
.unsigned()
|
||||
.references('users.id')
|
||||
.onDelete('CASCADE')
|
||||
table.timestamps(true)
|
||||
})
|
||||
}
|
||||
23
database/migrations/1634841251307_clicks.ts
Normal file
23
database/migrations/1634841251307_clicks.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class Clicks extends BaseSchema {
|
||||
protected tableName = 'clicks'
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').primary()
|
||||
table
|
||||
.integer('link_id')
|
||||
.unsigned()
|
||||
.references('links.id')
|
||||
.onDelete('CASCADE')
|
||||
table.string('country')
|
||||
table.string('ip')
|
||||
table.timestamp('date').defaultTo(this.now())
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user