-
Notifications
You must be signed in to change notification settings - Fork 25
WJ-1139: add forum schema, prune references, and seed sequences #2613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| layout TEXT, | ||
|
|
||
| UNIQUE (forum_group_id, sort_index), | ||
| UNIQUE (forum_category_id, site_id), |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| -- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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), |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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); |
There was a problem hiding this comment.
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?; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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"), |
There was a problem hiding this comment.
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.
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.