Files
mattermost/store/sqlstore/store.go
Fernando Correa Neto 9abd4dd7dc [MM 12464] Include DM/GM Channels and Their Posts in the Bulk Export (#10421)
* transplant the existing PR into the working tree

* start addressing review comments

* move existing direct channel export code into this branch

* modify channel exporter to use squirell and populate members in two steps

* use squirrel to build sql queries for channel and dm/gm export methods

* remove debug helpers and use Username instead of UserId

* unit test for DM Channel exporter

* add more unit tests for channel export

* add test for DM/GM post export

* checkpoint with failing test for postgres

* use getQueryBuilder to make sure squirrel uses the correct formatting
for each database

* add a test for post export

* fix shadowed vars that broke the build

* address review comments and add tests to support it

* address review comments and add a mlog call

* s/Info/Debug/

* address review comments in post_store

* address review comments in channel_store

* address review comments in export

* address review comment in post_store: drop GroupBy

* address review comment on supplier: move getQueryBuilder to sqlstore

* address review comments: explicit TearDown

* address review comments: improve test coverage

* address review comments: make sure public and private channels are excluded

* address review comments: improve test coverage

* address review comments: make sure Channels table gets truncated after
each test

* more cleanups and better assertions

* wrap PostStore in a StoreTestWithSqlSupplier

* last minute changes: improve post export test coverage and check members

* address review comments: make sure all posts have their channel
members set

* address review comments: make sure all posts have their ChannelMembers
exported correctly

* gofmt fix

* sort channels so it's possible to assert on index
2019-03-15 16:28:43 +01:00

103 lines
3.6 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package sqlstore
import (
sq "github.com/Masterminds/squirrel"
_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
"github.com/mattermost/gorp"
"github.com/mattermost/mattermost-server/store"
)
/*type SqlStore struct {
master *gorp.DbMap
replicas []*gorp.DbMap
searchReplicas []*gorp.DbMap
team TeamStore
channel ChannelStore
post PostStore
user UserStore
audit AuditStore
compliance ComplianceStore
session SessionStore
oauth OAuthStore
system SystemStore
webhook WebhookStore
command CommandStore
preference PreferenceStore
license LicenseStore
token TokenStore
emoji EmojiStore
status StatusStore
fileInfo FileInfoStore
reaction ReactionStore
jobStatus JobStatusStore
SchemaVersion string
rrCounter int64
srCounter int64
}*/
type SqlStore interface {
DriverName() string
GetCurrentSchemaVersion() string
GetMaster() *gorp.DbMap
GetSearchReplica() *gorp.DbMap
GetReplica() *gorp.DbMap
TotalMasterDbConnections() int
TotalReadDbConnections() int
TotalSearchDbConnections() int
MarkSystemRanUnitTests()
DoesTableExist(tablename string) bool
DoesColumnExist(tableName string, columName string) bool
DoesTriggerExist(triggerName string) bool
CreateColumnIfNotExists(tableName string, columnName string, mySqlColType string, postgresColType string, defaultValue string) bool
CreateColumnIfNotExistsNoDefault(tableName string, columnName string, mySqlColType string, postgresColType string) bool
RemoveColumnIfExists(tableName string, columnName string) bool
RemoveTableIfExists(tableName string) bool
RenameColumnIfExists(tableName string, oldColumnName string, newColumnName string, colType string) bool
GetMaxLengthOfColumnIfExists(tableName string, columnName string) string
AlterColumnTypeIfExists(tableName string, columnName string, mySqlColType string, postgresColType string) bool
AlterColumnDefaultIfExists(tableName string, columnName string, mySqlColDefault *string, postgresColDefault *string) bool
CreateUniqueIndexIfNotExists(indexName string, tableName string, columnName string) bool
CreateIndexIfNotExists(indexName string, tableName string, columnName string) bool
CreateCompositeIndexIfNotExists(indexName string, tableName string, columnNames []string) bool
CreateFullTextIndexIfNotExists(indexName string, tableName string, columnName string) bool
RemoveIndexIfExists(indexName string, tableName string) bool
GetAllConns() []*gorp.DbMap
Close()
LockToMaster()
UnlockFromMaster()
Team() store.TeamStore
Channel() store.ChannelStore
Post() store.PostStore
User() store.UserStore
Bot() store.BotStore
Audit() store.AuditStore
ClusterDiscovery() store.ClusterDiscoveryStore
Compliance() store.ComplianceStore
Session() store.SessionStore
OAuth() store.OAuthStore
System() store.SystemStore
Webhook() store.WebhookStore
Command() store.CommandStore
CommandWebhook() store.CommandWebhookStore
Preference() store.PreferenceStore
License() store.LicenseStore
Token() store.TokenStore
Emoji() store.EmojiStore
Status() store.StatusStore
FileInfo() store.FileInfoStore
Reaction() store.ReactionStore
Job() store.JobStore
Plugin() store.PluginStore
UserAccessToken() store.UserAccessTokenStore
Role() store.RoleStore
Scheme() store.SchemeStore
TermsOfService() store.TermsOfServiceStore
UserTermsOfService() store.UserTermsOfServiceStore
LinkMetadata() store.LinkMetadataStore
getQueryBuilder() sq.StatementBuilderType
}