snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
This commit is contained in:
119
server/channels/store/sqlstore/schema_dump_test.go
Normal file
119
server/channels/store/sqlstore/schema_dump_test.go
Normal file
@@ -0,0 +1,119 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package sqlstore
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||
)
|
||||
|
||||
func TestGetSchemaDefinition(t *testing.T) {
|
||||
StoreTest(t, func(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
t.Run("PostgreSQL", func(t *testing.T) {
|
||||
if ss.(*SqlStore).DriverName() != model.DatabaseDriverPostgres {
|
||||
t.Skip("Skipping test as database is not PostgreSQL")
|
||||
}
|
||||
|
||||
schemaInfo, err := ss.GetSchemaDefinition()
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, schemaInfo)
|
||||
|
||||
// Verify database encoding is captured
|
||||
assert.Equal(t, "UTF8", schemaInfo.DatabaseEncoding, "Database encoding should be captured")
|
||||
|
||||
// Verify schema structure
|
||||
assert.NotEmpty(t, schemaInfo.Tables)
|
||||
|
||||
// Verify that columns are not duplicated
|
||||
for _, table := range schemaInfo.Tables {
|
||||
columnNames := make(map[string]bool)
|
||||
for _, column := range table.Columns {
|
||||
// Assert that this column name hasn't been seen before
|
||||
assert.False(t, columnNames[column.Name], "Column %s in table %s is duplicated", column.Name, table.Name)
|
||||
columnNames[column.Name] = true
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that common tables are present
|
||||
tableNames := make([]string, 0, len(schemaInfo.Tables))
|
||||
for _, table := range schemaInfo.Tables {
|
||||
tableNames = append(tableNames, table.Name)
|
||||
}
|
||||
|
||||
// Verify some core tables
|
||||
expectedTables := []string{"users", "channels", "teams", "posts"}
|
||||
assert.Subset(t, tableNames, expectedTables)
|
||||
|
||||
// Verify table structure
|
||||
for _, table := range schemaInfo.Tables {
|
||||
if table.Name == "users" {
|
||||
// Check user table has key columns
|
||||
columnNames := make([]string, 0, len(table.Columns))
|
||||
for _, column := range table.Columns {
|
||||
columnNames = append(columnNames, column.Name)
|
||||
}
|
||||
|
||||
expectedColumns := []string{"id", "username", "email"}
|
||||
assert.Subset(t, columnNames, expectedColumns)
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Verify indexes are present for tables
|
||||
for _, table := range schemaInfo.Tables {
|
||||
if table.Name == "channels" {
|
||||
// Check that indexes are present
|
||||
assert.NotEmpty(t, table.Indexes, "channels table should have indexes")
|
||||
assert.Equal(t, 14, len(table.Indexes), "channels table should have 14 indexes")
|
||||
|
||||
// Expected index definitions
|
||||
expectedIndexDefs := map[string]string{
|
||||
"idx_channels_delete_at": "CREATE INDEX idx_channels_delete_at ON public.channels USING btree (deleteat)",
|
||||
"idx_channels_create_at": "CREATE INDEX idx_channels_create_at ON public.channels USING btree (createat)",
|
||||
"channels_pkey": "CREATE UNIQUE INDEX channels_pkey ON public.channels USING btree (id)",
|
||||
"channels_name_teamid_key": "CREATE UNIQUE INDEX channels_name_teamid_key ON public.channels USING btree (name, teamid)",
|
||||
"idx_channels_displayname_lower": "CREATE INDEX idx_channels_displayname_lower ON public.channels USING btree (lower((displayname)::text))",
|
||||
"idx_channels_name_lower": "CREATE INDEX idx_channels_name_lower ON public.channels USING btree (lower((name)::text))",
|
||||
"idx_channels_update_at": "CREATE INDEX idx_channels_update_at ON public.channels USING btree (updateat)",
|
||||
"idx_channel_search_txt": "CREATE INDEX idx_channel_search_txt ON public.channels USING gin (to_tsvector('english'::regconfig, (((((name)::text || ' '::text) || (displayname)::text) || ' '::text) || (purpose)::text)))",
|
||||
"idx_channels_scheme_id": "CREATE INDEX idx_channels_scheme_id ON public.channels USING btree (schemeid)",
|
||||
"idx_channels_team_id_display_name": "CREATE INDEX idx_channels_team_id_display_name ON public.channels USING btree (teamid, displayname)",
|
||||
"idx_channels_team_id_type": "CREATE INDEX idx_channels_team_id_type ON public.channels USING btree (teamid, type)",
|
||||
"idx_channels_autotranslation_enabled": "CREATE INDEX idx_channels_autotranslation_enabled ON public.channels USING btree (id) WHERE (autotranslation = true)",
|
||||
"idx_channels_discoverable_team": "CREATE INDEX idx_channels_discoverable_team ON public.channels USING btree (teamid) WHERE ((discoverable = true) AND (type = 'P'::channel_type) AND (deleteat = 0))",
|
||||
"idx_channels_create_at_id": "CREATE INDEX idx_channels_create_at_id ON public.channels USING btree (createat, id)",
|
||||
}
|
||||
|
||||
// Verify all expected indexes are present with correct definitions
|
||||
foundIndexes := make(map[string]bool)
|
||||
for _, index := range table.Indexes {
|
||||
foundIndexes[index.Name] = true
|
||||
|
||||
// Verify definition is not empty
|
||||
assert.NotEmpty(t, index.Definition, "Index %s should have a definition", index.Name)
|
||||
|
||||
// Check if this is an expected index and verify definition
|
||||
expectedDef, ok := expectedIndexDefs[index.Name]
|
||||
require.Truef(t, ok, "Unexpected definition found: %s", index.Name)
|
||||
assert.Equal(t, expectedDef, index.Definition, "Index %s has incorrect definition", index.Name)
|
||||
}
|
||||
|
||||
// Verify all expected indexes were found
|
||||
for expectedName := range expectedIndexDefs {
|
||||
assert.True(t, foundIndexes[expectedName], "Expected index %s not found", expectedName)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user