feat: implement activity logging for user actions and create activities table
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 44s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 44s
This commit is contained in:
parent
6c75efbc28
commit
7e2f320b4f
12 changed files with 420 additions and 160 deletions
25
database/migrations/1782294801884_create_activities_table.ts
Normal file
25
database/migrations/1782294801884_create_activities_table.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { BaseSchema } from '@adonisjs/lucid/schema';
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'activities';
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id');
|
||||
table.string('type').notNullable().index(); // 'dataset.uploaded', 'auth.login'
|
||||
table.integer('user_id').unsigned().nullable().references('id').inTable('accounts').onDelete('SET NULL');
|
||||
table.string('subject_type').nullable(); // manual morph: model name
|
||||
table.bigInteger('subject_id').unsigned().nullable();
|
||||
table.string('description').notNullable();
|
||||
table.json('properties').nullable();
|
||||
table.timestamp('created_at');
|
||||
table.timestamp('updated_at');
|
||||
table.index(['subject_type', 'subject_id'])
|
||||
table.index('created_at')
|
||||
});
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue