26 lines
891 B
Python
26 lines
891 B
Python
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
class TenantProvisioningLog(models.Model):
|
|
"""Audit log for tenant creation via API."""
|
|
tenant_name = models.CharField(max_length=255, db_index=True)
|
|
external_key = models.CharField(max_length=255)
|
|
created_by = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
status = models.CharField(max_length=50, choices=[
|
|
('success', 'Success'),
|
|
('failed', 'Failed'),
|
|
])
|
|
error_message = models.TextField(blank=True)
|
|
tenant_config_id = models.IntegerField(null=True, blank=True)
|
|
|
|
class Meta:
|
|
ordering = ['-created_at']
|
|
indexes = [
|
|
models.Index(fields=['tenant_name', 'created_at']),
|
|
]
|
|
|
|
def __str__(self):
|
|
return f"{self.tenant_name} - {self.status} - {self.created_at}"
|