api/database/migrations/1755685548096_create_subscriptions_table.ts
2025-08-20 16:10:48 +02:00

27 lines
745 B
TypeScript

import { BaseSchema } from '@adonisjs/lucid/schema'
export default class extends BaseSchema {
protected tableName = 'subscriptions'
async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table
.integer('user_id')
.notNullable()
.unsigned()
.references('id')
.inTable('users')
.onDelete('CASCADE')
table.string('device').notNullable()
table.integer('events').defaultTo(0).notNullable()
table.jsonb('data').notNullable()
table.integer('failed_attempts').defaultTo(0).notNullable()
table.boolean('enabled').defaultTo(true).notNullable()
})
}
async down() {
this.schema.dropTable(this.tableName)
}
}