Skip to content

Feat/audit#658

Merged
nanaf6203-bit merged 6 commits into
MettaChain:mainfrom
nafiuishaaq:feat/audit
Jun 25, 2026
Merged

Feat/audit#658
nanaf6203-bit merged 6 commits into
MettaChain:mainfrom
nafiuishaaq:feat/audit

Conversation

@nafiuishaaq

Copy link
Copy Markdown
Contributor

Here is a summary of the implementations I've completed based on your requests:

  1. Audit Log Pruning Strategy
    I have implemented a daily pruning service for audit logs to enhance performance and manage data retention.

closes #620

Pruning Service: A new AuditPruningService was created at src/audit/audit-pruning.service.ts. This service contains the logic to handle the pruning of TransactionHistory and LoginHistory records.
Retention and Archiving: The service is configured to prune records older than 365 days. Before deletion, it archives the old logs into a JSON file within an archives directory.
Scheduled Execution: The pruning process is scheduled to run automatically every day using a cron job.
Integration: The new service has been integrated into the application via a new AuditModule (src/audit/audit.module.ts), which is now imported into the main app.module.ts.
2. Default User Role Seeding
I've adjusted the database seeding process to ensure new users are correctly assigned the default USER role.

closes #623

Schema Update: The role enum field was removed from the User model in prisma/schema.prisma. The system now exclusively uses the roleId relationship to associate users with their roles, making the link more robust.
Seed Script Update: The seeding script at prisma/seed.ts was modified to create users by assigning the appropriate roleId, removing the direct assignment of the role enum.
3. Database Constraint for Transaction Status
To ensure data integrity at the database level, I added a constraint for transaction statuses.

closes #622

Migration: I created a new database migration (prisma/migrations/20260625000000_add_transaction_status_constraint/migration.sql).
Check Constraint: This migration adds a CHECK constraint to the transactions table. This forces the status column to only accept one of the predefined valid values: 'PENDING', 'COMPLETED', or 'CANCELLED'.
4. Tracking for Export and Backup Jobs
I've added a new database table to track the metadata of export and backup jobs.

closes #621

Schema Extension: I updated the prisma/schema.prisma file to include a new ExportJob model. This model will store job metadata, including its type (export or backup), status (pending, running, completed, failed), file reference, and timestamps.
New Enums: I also added JobStatus and JobType enums to support the new model.
Database Migration: A new migration file (prisma/migrations/20260625000001_add_export_jobs/migration.sql) was created to apply these changes, adding the export_jobs table to the database.

@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@nafiuishaaq Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nanaf6203-bit nanaf6203-bit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nanaf6203-bit nanaf6203-bit merged commit e8aea57 into MettaChain:main Jun 25, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants