mattermost-community-enterp.../channels/db/migrations/postgres/000054_create_crt_channelmembership_count.up.sql
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
Full Mattermost server source with integrated Community Enterprise features.
Includes vendor directory for offline/air-gapped builds.

Structure:
- enterprise-impl/: Enterprise feature implementations
- enterprise-community/: Init files that register implementations
- enterprise/: Bridge imports (community_imports.go)
- vendor/: All dependencies for offline builds

Build (online):
  go build ./cmd/mattermost

Build (offline/air-gapped):
  go build -mod=vendor ./cmd/mattermost

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:59:07 +09:00

33 lines
930 B
SQL

/* fixCRTChannelMembershipCounts fixes the channel counts, i.e. the total message count,
total root message count, mention count, and mention count in root messages for users
who have viewed the channel after the last post in the channel */
DO $$
<< migrate_crt_channelmembership_counts >>
BEGIN
IF((
SELECT
COUNT(*)
FROM systems
WHERE
Name = 'CRTChannelMembershipCountsMigrationComplete') = 0) THEN
UPDATE
ChannelMembers
SET
MentionCount = 0,
MentionCountRoot = 0,
MsgCount = Channels.TotalMsgCount,
MsgCountRoot = Channels.TotalMsgCountRoot,
LastUpdateAt = (
SELECT
(extract(epoch FROM now()) * 1000)::bigint)
FROM
Channels
WHERE
ChannelMembers.Channelid = Channels.Id
AND ChannelMembers.LastViewedAt >= Channels.LastPostAt;
INSERT INTO Systems
VALUES('CRTChannelMembershipCountsMigrationComplete', 'true');
END IF;
END migrate_crt_channelmembership_counts
$$;