forked from coracle/caravel
Add tenant to activity table, include resource type
This commit is contained in:
@@ -8,6 +8,7 @@ This file describes the domain model. This description should be translated into
|
||||
Activity is an audit log of all actions performed by a user or a worker process. This allows us to trace history to create invoices, synchronize actions to external services, and debug system behavior.
|
||||
|
||||
- `id` - a random activity ID
|
||||
- `tenant` - a tenant ID
|
||||
- `created_at` - unix timestamp when the activity was created
|
||||
- `activity_type` is one of:
|
||||
- `create_tenant`
|
||||
@@ -23,7 +24,8 @@ Activity is an audit log of all actions performed by a user or a worker process.
|
||||
- `mark_invoice_attempted`
|
||||
- `mark_invoice_sent`
|
||||
- `mark_invoice_closed`
|
||||
- `identifier` is a string identifying the resource being modified. This id in interpreted depending on what the `activity_type` is.
|
||||
- `resource_type` is a string identifying the resource type being modified.
|
||||
- `resource_id` is a string identifying the resource id being modified.
|
||||
|
||||
# Tenant
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Members:
|
||||
Notes:
|
||||
|
||||
- All public write methods should be run in a transaction so they're atomic
|
||||
- All writes should be accompanied by an activity log entry of `(activity_type, identifier)`
|
||||
- All writes should be accompanied by an activity log entry of `(tenant, activity_type, resource_type, resource_id)`
|
||||
- Database table names are singular: `activity`, `tenant`, `relay`, `invoice`, `invoice_item`
|
||||
|
||||
## `pub fn new() -> Self`
|
||||
@@ -19,9 +19,10 @@ Notes:
|
||||
- Initializes its sqlx `pool`
|
||||
- Runs migrations found in the `migrations` directory.
|
||||
|
||||
## `fn insert_activity(activity_type, identifier) -> Result<()>`
|
||||
## `fn insert_activity(activity_type, resource_type, resource_id) -> Result<()>`
|
||||
|
||||
- Private helper that inserts one row into `activity`
|
||||
- Infers `tenant` from `resource_type` and `resource_id`
|
||||
- Used by write methods to avoid repeating audit-log SQL
|
||||
|
||||
## `pub fn list_tenants(&self) -> Result<Vec<Tenant>>`
|
||||
|
||||
Reference in New Issue
Block a user