Skip to content
Open

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions apps/labrinth/migrations/20260513120000_moderation_notes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE moderation_notes (
user_id BIGINT NULL REFERENCES users(id) ON DELETE CASCADE,
organization_id BIGINT NULL REFERENCES organizations(id) ON DELETE CASCADE,
last_modified TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_author BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
version INTEGER NOT NULL DEFAULT 1,
notes TEXT NOT NULL,
user_rating INTEGER NOT NULL DEFAULT 0
);

CREATE UNIQUE INDEX moderation_notes_user_id_unique
ON moderation_notes(user_id)
WHERE user_id IS NOT NULL;

CREATE UNIQUE INDEX moderation_notes_organization_id_unique
ON moderation_notes(organization_id)
WHERE organization_id IS NOT NULL;

CREATE INDEX moderation_notes_user_id_idx ON moderation_notes(user_id);
CREATE INDEX moderation_notes_organization_id_idx ON moderation_notes(organization_id);
2 changes: 2 additions & 0 deletions apps/labrinth/src/database/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub mod legacy_loader_fields;
pub mod loader_fields;
pub mod moderation_external_item;
pub mod moderation_lock_item;
pub mod moderation_note_item;
pub mod notification_item;
pub mod notifications_deliveries_item;
pub mod notifications_template_item;
Expand Down Expand Up @@ -56,6 +57,7 @@ pub use user_item::DBUser;
pub use version_item::DBVersion;

pub use moderation_lock_item::{DBModerationLock, ModerationLockWithUser};
pub use moderation_note_item::DBModerationNote;

#[derive(Error, Debug)]
pub enum DatabaseError {
Expand Down
Loading
Loading