Skip to content

Conversation

@Syxless
Copy link
Contributor

@Syxless Syxless commented Dec 12, 2025

Implements the forum schema (groups, categories, threads, locks, posts, post revisions) with site-level composite FKs, actor fields, soft-deletes, discussion-thread uniqueness, and indexes for ordering/activity/lookups.
Adds forum compatibility ID bumps in the seeder.
Updates TextService::prune() to keep forum post revision text hashes.

Tests: ran.

@Syxless Syxless requested a review from emmiegit as a code owner December 12, 2025 19:20
layout TEXT,

UNIQUE (forum_group_id, sort_index),
UNIQUE (forum_category_id, site_id),
Copy link
Member

Choose a reason for hiding this comment

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

Is this for an index? I'm not sure what structural constraint this represents, given forum_category_id is unique by itself.

FOREIGN KEY (forum_group_id, site_id) REFERENCES forum_group(forum_group_id, site_id)
);

-- Threads live under a category.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
-- Threads live under a category.
-- Threads live in a category (but can be moved between them).

forum_category_id BIGINT NOT NULL REFERENCES forum_category(forum_category_id),
forum_group_id BIGINT NOT NULL REFERENCES forum_group(forum_group_id),
site_id BIGINT NOT NULL REFERENCES site(site_id),
page_id BIGINT REFERENCES page(page_id) UNIQUE,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
page_id BIGINT REFERENCES page(page_id) UNIQUE,
page_id BIGINT REFERENCES page(page_id) UNIQUE, -- For page discussion threads (NULL = regular thread)

latest_revision_id BIGINT,

CHECK ((deleted_by IS NULL) = (deleted_at IS NULL)),
UNIQUE (forum_post_id, site_id),
Copy link
Member

Choose a reason for hiding this comment

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

Same here.


CHECK ((updated_by IS NULL) = (updated_at IS NULL)),
CHECK ((deleted_by IS NULL) = (deleted_at IS NULL)),
UNIQUE (forum_thread_id, site_id),
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

user_id BIGINT NOT NULL REFERENCES "user"(user_id),
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
updated_at TIMESTAMP WITH TIME ZONE,
revision_number INT NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
revision_number INT NOT NULL,
revision_number INTEGER NOT NULL CHECK (revision_number >= 0),

-- Latest revision FK on posts, now that the revision table exists.
ALTER TABLE forum_post
ADD CONSTRAINT forum_post_latest_revision_fk
FOREIGN KEY (latest_revision_id) REFERENCES forum_post_revision(forum_post_revision_id);
Copy link
Member

Choose a reason for hiding this comment

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

👍

restart_sequence_with(&txn, "page_page_id_seq", 3000000000).await?;
restart_sequence_with(&txn, "page_revision_revision_id_seq", 3000000000).await?;
restart_sequence_with(&txn, "page_category_category_id_seq", 100000000).await?;

Copy link
Member

Choose a reason for hiding this comment

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

restart_sequence_with(&txn, "forum_post_revision_forum_post_revision_id_seq", 3000000000)
.await?;
restart_sequence_with(&txn, "forum_thread_lock_forum_thread_lock_id_seq", 20000000).await?;
restart_sequence_with(&txn, "forum_post_lock_forum_post_lock_id_seq", 20000000).await?;
Copy link
Member

Choose a reason for hiding this comment

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

Wikidot doesn't expose IDs for forum groups and forum post revisions publicly, so we don't have compatibility IDs for those. Forum thread and post lock history is a Wikijump concept so compatibility IDs don't apply.

))
.add(not_in_column!(
Alias::new("forum_post_revision"),
Alias::new("compiled_html_hash"),
Copy link
Member

Choose a reason for hiding this comment

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

Ah I see, temporary measure until new src/models files are generated. I'll do that in a separate PR because the autogen tool needs some manual correction unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants