WIP: Audit Logs #45
3 changed files with 41 additions and 0 deletions
2
migrations/2025-08-04-195527_add_audit_log/down.sql
Normal file
2
migrations/2025-08-04-195527_add_audit_log/down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE audit_logs;
|
14
migrations/2025-08-04-195527_add_audit_log/up.sql
Normal file
14
migrations/2025-08-04-195527_add_audit_log/up.sql
Normal file
|
@ -0,0 +1,14 @@
|
|||
-- Your SQL goes here
|
||||
CREATE TABLE audit_logs (
|
||||
uuid UUID PRIMARY KEY NOT NULL,
|
||||
guild_uuid UUID NOT NULL,
|
||||
action_id INT2 NOT NULL,
|
||||
by_uuid UUID NOT NULL REFERENCES guild_members(uuid),
|
||||
channel_uuid UUID REFERENCES channels(uuid) DEFAULT NULL,
|
||||
user_uuid UUID REFERENCES users(uuid) DEFAULT NULL,
|
||||
message_uuid UUID REFERENCES messages(uuid) DEFAULT NULL,
|
||||
role_uuid UUID REFERENCES roles(uuid) DEFAULT NULL,
|
||||
audit_message VARCHAR(200) DEFAULT NULL,
|
||||
changed_from VARCHAR(200) DEFAULT NULL,
|
||||
changed_to VARCHAR(200) DEFAULT NULL
|
||||
);
|
|
@ -11,6 +11,25 @@ diesel::table! {
|
|||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
audit_logs (uuid) {
|
||||
uuid -> Uuid,
|
||||
guild_uuid -> Uuid,
|
||||
action_id -> Int2,
|
||||
by_uuid -> Uuid,
|
||||
channel_uuid -> Nullable<Uuid>,
|
||||
user_uuid -> Nullable<Uuid>,
|
||||
message_uuid -> Nullable<Uuid>,
|
||||
role_uuid -> Nullable<Uuid>,
|
||||
#[max_length = 200]
|
||||
audit_message -> Nullable<Varchar>,
|
||||
#[max_length = 200]
|
||||
changed_from -> Nullable<Varchar>,
|
||||
#[max_length = 200]
|
||||
changed_to -> Nullable<Varchar>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
channel_permissions (channel_uuid, role_uuid) {
|
||||
channel_uuid -> Uuid,
|
||||
|
@ -163,6 +182,11 @@ diesel::table! {
|
|||
|
||||
diesel::joinable!(access_tokens -> refresh_tokens (refresh_token));
|
||||
diesel::joinable!(access_tokens -> users (uuid));
|
||||
diesel::joinable!(audit_logs -> channels (channel_uuid));
|
||||
diesel::joinable!(audit_logs -> guild_members (by_uuid));
|
||||
diesel::joinable!(audit_logs -> messages (message_uuid));
|
||||
diesel::joinable!(audit_logs -> roles (role_uuid));
|
||||
diesel::joinable!(audit_logs -> users (user_uuid));
|
||||
diesel::joinable!(channel_permissions -> channels (channel_uuid));
|
||||
diesel::joinable!(channel_permissions -> roles (role_uuid));
|
||||
diesel::joinable!(channels -> guilds (guild_uuid));
|
||||
|
@ -182,6 +206,7 @@ diesel::joinable!(roles -> guilds (guild_uuid));
|
|||
|
||||
diesel::allow_tables_to_appear_in_same_query!(
|
||||
access_tokens,
|
||||
audit_logs,
|
||||
channel_permissions,
|
||||
channels,
|
||||
friend_requests,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue