WJ-1139: add forum schema, prune references, and seed sequences#2613
WJ-1139: add forum schema, prune references, and seed sequences#2613
Conversation
| layout TEXT, | ||
|
|
||
| UNIQUE (forum_group_id, sort_index), | ||
| UNIQUE (forum_category_id, site_id), |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
| -- 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, |
There was a problem hiding this comment.
| 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), |
|
|
||
| CHECK ((updated_by IS NULL) = (updated_at IS NULL)), | ||
| CHECK ((deleted_by IS NULL) = (deleted_at IS NULL)), | ||
| UNIQUE (forum_thread_id, site_id), |
| 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, |
There was a problem hiding this comment.
| 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); |
| 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?; | ||
|
|
There was a problem hiding this comment.
Note, the doc describing these is https://github.com/scpwiki/wikijump/blob/develop/docs/compatibility-ids.md
| 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?; |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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.
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.