Removing unnecesary unnused old layered store (#12999)

Этот коммит содержится в:
Jesús Espino
2019-11-06 12:43:41 +01:00
коммит произвёл GitHub
родитель a85c653f87
Коммит 8febdcf2b8
13 изменённых файлов: 138 добавлений и 1130 удалений

Просмотреть файл

@@ -362,7 +362,7 @@ func TestCheckIntegrity(t *testing.T) {
func TestCheckParentChildIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
t.Run("should receive an error", func(t *testing.T) {
config := relationalCheckConfig{
parentName: "NotValid",
@@ -379,7 +379,7 @@ func TestCheckParentChildIntegrity(t *testing.T) {
func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -407,7 +407,7 @@ func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -437,7 +437,7 @@ func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -465,7 +465,7 @@ func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -493,7 +493,7 @@ func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -523,7 +523,7 @@ func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
func TestCheckChannelsPostsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -550,7 +550,7 @@ func TestCheckChannelsPostsIntegrity(t *testing.T) {
func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -578,7 +578,7 @@ func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
func TestCheckPostsFileInfoIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -605,7 +605,7 @@ func TestCheckPostsFileInfoIntegrity(t *testing.T) {
func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -637,7 +637,7 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -667,7 +667,7 @@ func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
func TestCheckPostsReactionsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -694,7 +694,7 @@ func TestCheckPostsReactionsIntegrity(t *testing.T) {
func TestCheckSchemesChannelsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -725,7 +725,7 @@ func TestCheckSchemesChannelsIntegrity(t *testing.T) {
func TestCheckSchemesTeamsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -756,7 +756,7 @@ func TestCheckSchemesTeamsIntegrity(t *testing.T) {
func TestCheckSessionsAuditsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -787,7 +787,7 @@ func TestCheckSessionsAuditsIntegrity(t *testing.T) {
func TestCheckTeamsChannelsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -814,7 +814,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
func TestCheckTeamsCommandsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -842,7 +842,7 @@ func TestCheckTeamsCommandsIntegrity(t *testing.T) {
func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -870,7 +870,7 @@ func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -898,7 +898,7 @@ func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -926,7 +926,7 @@ func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
func TestCheckUsersAuditsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -956,7 +956,7 @@ func TestCheckUsersAuditsIntegrity(t *testing.T) {
func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -984,7 +984,7 @@ func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
func TestCheckUsersChannelsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1011,7 +1011,7 @@ func TestCheckUsersChannelsIntegrity(t *testing.T) {
func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1041,7 +1041,7 @@ func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1071,7 +1071,7 @@ func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
func TestCheckUsersCommandsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1099,7 +1099,7 @@ func TestCheckUsersCommandsIntegrity(t *testing.T) {
func TestCheckUsersCompliancesIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1129,7 +1129,7 @@ func TestCheckUsersCompliancesIntegrity(t *testing.T) {
func TestCheckUsersEmojiIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1159,7 +1159,7 @@ func TestCheckUsersEmojiIntegrity(t *testing.T) {
func TestCheckUsersFileInfoIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1188,7 +1188,7 @@ func TestCheckUsersFileInfoIntegrity(t *testing.T) {
func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1216,7 +1216,7 @@ func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1246,7 +1246,7 @@ func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1276,7 +1276,7 @@ func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1306,7 +1306,7 @@ func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1334,7 +1334,7 @@ func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
func TestCheckUsersPostsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1361,7 +1361,7 @@ func TestCheckUsersPostsIntegrity(t *testing.T) {
func TestCheckUsersPreferencesIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1390,7 +1390,7 @@ func TestCheckUsersPreferencesIntegrity(t *testing.T) {
func TestCheckUsersReactionsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1419,7 +1419,7 @@ func TestCheckUsersReactionsIntegrity(t *testing.T) {
func TestCheckUsersSessionsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1447,7 +1447,7 @@ func TestCheckUsersSessionsIntegrity(t *testing.T) {
func TestCheckUsersStatusIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1476,7 +1476,7 @@ func TestCheckUsersStatusIntegrity(t *testing.T) {
func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1506,7 +1506,7 @@ func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
func TestCheckUsersUserAccessTokensIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {

Просмотреть файл

@@ -70,7 +70,7 @@ func initStores() {
go func() {
defer wg.Done()
st.SqlSupplier = NewSqlSupplier(*st.SqlSettings, nil)
st.Store = store.NewLayeredStore(st.SqlSupplier, nil, nil)
st.Store = st.SqlSupplier
st.Store.DropAllTables()
st.Store.MarkSystemRanUnitTests()
}()

Просмотреть файл

@@ -67,7 +67,7 @@ const (
EXIT_DOES_COLUMN_EXISTS_SQLITE = 138
)
type SqlSupplierOldStores struct {
type SqlSupplierStores struct {
team store.TeamStore
channel store.ChannelStore
post store.PostStore
@@ -106,11 +106,10 @@ type SqlSupplier struct {
// See https://github.com/mattermost/mattermost-server/pull/7281
rrCounter int64
srCounter int64
next store.LayeredStoreSupplier
master *gorp.DbMap
replicas []*gorp.DbMap
searchReplicas []*gorp.DbMap
oldStores SqlSupplierOldStores
stores SqlSupplierStores
settings *model.SqlSettings
lockedToMaster bool
}
@@ -124,37 +123,37 @@ func NewSqlSupplier(settings model.SqlSettings, metrics einterfaces.MetricsInter
supplier.initConnection()
supplier.oldStores.team = NewSqlTeamStore(supplier, metrics)
supplier.oldStores.channel = NewSqlChannelStore(supplier, metrics)
supplier.oldStores.post = NewSqlPostStore(supplier, metrics)
supplier.oldStores.user = NewSqlUserStore(supplier, metrics)
supplier.oldStores.bot = NewSqlBotStore(supplier, metrics)
supplier.oldStores.audit = NewSqlAuditStore(supplier)
supplier.oldStores.cluster = NewSqlClusterDiscoveryStore(supplier)
supplier.oldStores.compliance = NewSqlComplianceStore(supplier)
supplier.oldStores.session = NewSqlSessionStore(supplier)
supplier.oldStores.oauth = NewSqlOAuthStore(supplier)
supplier.oldStores.system = NewSqlSystemStore(supplier)
supplier.oldStores.webhook = NewSqlWebhookStore(supplier, metrics)
supplier.oldStores.command = NewSqlCommandStore(supplier)
supplier.oldStores.commandWebhook = NewSqlCommandWebhookStore(supplier)
supplier.oldStores.preference = NewSqlPreferenceStore(supplier)
supplier.oldStores.license = NewSqlLicenseStore(supplier)
supplier.oldStores.token = NewSqlTokenStore(supplier)
supplier.oldStores.emoji = NewSqlEmojiStore(supplier, metrics)
supplier.oldStores.status = NewSqlStatusStore(supplier)
supplier.oldStores.fileInfo = NewSqlFileInfoStore(supplier, metrics)
supplier.oldStores.job = NewSqlJobStore(supplier)
supplier.oldStores.userAccessToken = NewSqlUserAccessTokenStore(supplier)
supplier.oldStores.channelMemberHistory = NewSqlChannelMemberHistoryStore(supplier)
supplier.oldStores.plugin = NewSqlPluginStore(supplier)
supplier.oldStores.TermsOfService = NewSqlTermsOfServiceStore(supplier, metrics)
supplier.oldStores.UserTermsOfService = NewSqlUserTermsOfServiceStore(supplier)
supplier.oldStores.linkMetadata = NewSqlLinkMetadataStore(supplier)
supplier.oldStores.reaction = NewSqlReactionStore(supplier)
supplier.oldStores.role = NewSqlRoleStore(supplier)
supplier.oldStores.scheme = NewSqlSchemeStore(supplier)
supplier.oldStores.group = NewSqlGroupStore(supplier)
supplier.stores.team = NewSqlTeamStore(supplier, metrics)
supplier.stores.channel = NewSqlChannelStore(supplier, metrics)
supplier.stores.post = NewSqlPostStore(supplier, metrics)
supplier.stores.user = NewSqlUserStore(supplier, metrics)
supplier.stores.bot = NewSqlBotStore(supplier, metrics)
supplier.stores.audit = NewSqlAuditStore(supplier)
supplier.stores.cluster = NewSqlClusterDiscoveryStore(supplier)
supplier.stores.compliance = NewSqlComplianceStore(supplier)
supplier.stores.session = NewSqlSessionStore(supplier)
supplier.stores.oauth = NewSqlOAuthStore(supplier)
supplier.stores.system = NewSqlSystemStore(supplier)
supplier.stores.webhook = NewSqlWebhookStore(supplier, metrics)
supplier.stores.command = NewSqlCommandStore(supplier)
supplier.stores.commandWebhook = NewSqlCommandWebhookStore(supplier)
supplier.stores.preference = NewSqlPreferenceStore(supplier)
supplier.stores.license = NewSqlLicenseStore(supplier)
supplier.stores.token = NewSqlTokenStore(supplier)
supplier.stores.emoji = NewSqlEmojiStore(supplier, metrics)
supplier.stores.status = NewSqlStatusStore(supplier)
supplier.stores.fileInfo = NewSqlFileInfoStore(supplier, metrics)
supplier.stores.job = NewSqlJobStore(supplier)
supplier.stores.userAccessToken = NewSqlUserAccessTokenStore(supplier)
supplier.stores.channelMemberHistory = NewSqlChannelMemberHistoryStore(supplier)
supplier.stores.plugin = NewSqlPluginStore(supplier)
supplier.stores.TermsOfService = NewSqlTermsOfServiceStore(supplier, metrics)
supplier.stores.UserTermsOfService = NewSqlUserTermsOfServiceStore(supplier)
supplier.stores.linkMetadata = NewSqlLinkMetadataStore(supplier)
supplier.stores.reaction = NewSqlReactionStore(supplier)
supplier.stores.role = NewSqlRoleStore(supplier)
supplier.stores.scheme = NewSqlSchemeStore(supplier)
supplier.stores.group = NewSqlGroupStore(supplier)
err := supplier.GetMaster().CreateTablesIfNotExists()
if err != nil {
@@ -170,46 +169,37 @@ func NewSqlSupplier(settings model.SqlSettings, metrics einterfaces.MetricsInter
os.Exit(EXIT_GENERIC_FAILURE)
}
supplier.oldStores.team.(*SqlTeamStore).CreateIndexesIfNotExists()
supplier.oldStores.channel.(*SqlChannelStore).CreateIndexesIfNotExists()
supplier.oldStores.post.(*SqlPostStore).CreateIndexesIfNotExists()
supplier.oldStores.user.(*SqlUserStore).CreateIndexesIfNotExists()
supplier.oldStores.bot.(*SqlBotStore).CreateIndexesIfNotExists()
supplier.oldStores.audit.(*SqlAuditStore).CreateIndexesIfNotExists()
supplier.oldStores.compliance.(*SqlComplianceStore).CreateIndexesIfNotExists()
supplier.oldStores.session.(*SqlSessionStore).CreateIndexesIfNotExists()
supplier.oldStores.oauth.(*SqlOAuthStore).CreateIndexesIfNotExists()
supplier.oldStores.system.(*SqlSystemStore).CreateIndexesIfNotExists()
supplier.oldStores.webhook.(*SqlWebhookStore).CreateIndexesIfNotExists()
supplier.oldStores.command.(*SqlCommandStore).CreateIndexesIfNotExists()
supplier.oldStores.commandWebhook.(*SqlCommandWebhookStore).CreateIndexesIfNotExists()
supplier.oldStores.preference.(*SqlPreferenceStore).CreateIndexesIfNotExists()
supplier.oldStores.license.(*SqlLicenseStore).CreateIndexesIfNotExists()
supplier.oldStores.token.(*SqlTokenStore).CreateIndexesIfNotExists()
supplier.oldStores.emoji.(*SqlEmojiStore).CreateIndexesIfNotExists()
supplier.oldStores.status.(*SqlStatusStore).CreateIndexesIfNotExists()
supplier.oldStores.fileInfo.(*SqlFileInfoStore).CreateIndexesIfNotExists()
supplier.oldStores.job.(*SqlJobStore).CreateIndexesIfNotExists()
supplier.oldStores.userAccessToken.(*SqlUserAccessTokenStore).CreateIndexesIfNotExists()
supplier.oldStores.plugin.(*SqlPluginStore).CreateIndexesIfNotExists()
supplier.oldStores.TermsOfService.(SqlTermsOfServiceStore).CreateIndexesIfNotExists()
supplier.oldStores.UserTermsOfService.(SqlUserTermsOfServiceStore).CreateIndexesIfNotExists()
supplier.oldStores.linkMetadata.(*SqlLinkMetadataStore).CreateIndexesIfNotExists()
supplier.oldStores.group.(*SqlGroupStore).CreateIndexesIfNotExists()
supplier.oldStores.preference.(*SqlPreferenceStore).DeleteUnusedFeatures()
supplier.stores.team.(*SqlTeamStore).CreateIndexesIfNotExists()
supplier.stores.channel.(*SqlChannelStore).CreateIndexesIfNotExists()
supplier.stores.post.(*SqlPostStore).CreateIndexesIfNotExists()
supplier.stores.user.(*SqlUserStore).CreateIndexesIfNotExists()
supplier.stores.bot.(*SqlBotStore).CreateIndexesIfNotExists()
supplier.stores.audit.(*SqlAuditStore).CreateIndexesIfNotExists()
supplier.stores.compliance.(*SqlComplianceStore).CreateIndexesIfNotExists()
supplier.stores.session.(*SqlSessionStore).CreateIndexesIfNotExists()
supplier.stores.oauth.(*SqlOAuthStore).CreateIndexesIfNotExists()
supplier.stores.system.(*SqlSystemStore).CreateIndexesIfNotExists()
supplier.stores.webhook.(*SqlWebhookStore).CreateIndexesIfNotExists()
supplier.stores.command.(*SqlCommandStore).CreateIndexesIfNotExists()
supplier.stores.commandWebhook.(*SqlCommandWebhookStore).CreateIndexesIfNotExists()
supplier.stores.preference.(*SqlPreferenceStore).CreateIndexesIfNotExists()
supplier.stores.license.(*SqlLicenseStore).CreateIndexesIfNotExists()
supplier.stores.token.(*SqlTokenStore).CreateIndexesIfNotExists()
supplier.stores.emoji.(*SqlEmojiStore).CreateIndexesIfNotExists()
supplier.stores.status.(*SqlStatusStore).CreateIndexesIfNotExists()
supplier.stores.fileInfo.(*SqlFileInfoStore).CreateIndexesIfNotExists()
supplier.stores.job.(*SqlJobStore).CreateIndexesIfNotExists()
supplier.stores.userAccessToken.(*SqlUserAccessTokenStore).CreateIndexesIfNotExists()
supplier.stores.plugin.(*SqlPluginStore).CreateIndexesIfNotExists()
supplier.stores.TermsOfService.(SqlTermsOfServiceStore).CreateIndexesIfNotExists()
supplier.stores.UserTermsOfService.(SqlUserTermsOfServiceStore).CreateIndexesIfNotExists()
supplier.stores.linkMetadata.(*SqlLinkMetadataStore).CreateIndexesIfNotExists()
supplier.stores.group.(*SqlGroupStore).CreateIndexesIfNotExists()
supplier.stores.preference.(*SqlPreferenceStore).DeleteUnusedFeatures()
return supplier
}
func (s *SqlSupplier) SetChainNext(next store.LayeredStoreSupplier) {
s.next = next
}
func (s *SqlSupplier) Next() store.LayeredStoreSupplier {
return s.next
}
func setupConnection(con_type string, dataSource string, settings *model.SqlSettings) *gorp.DbMap {
db, err := dbsql.Open(*settings.DriverName, dataSource)
if err != nil {
@@ -930,127 +920,127 @@ func (ss *SqlSupplier) UnlockFromMaster() {
}
func (ss *SqlSupplier) Team() store.TeamStore {
return ss.oldStores.team
return ss.stores.team
}
func (ss *SqlSupplier) Channel() store.ChannelStore {
return ss.oldStores.channel
return ss.stores.channel
}
func (ss *SqlSupplier) Post() store.PostStore {
return ss.oldStores.post
return ss.stores.post
}
func (ss *SqlSupplier) User() store.UserStore {
return ss.oldStores.user
return ss.stores.user
}
func (ss *SqlSupplier) Bot() store.BotStore {
return ss.oldStores.bot
return ss.stores.bot
}
func (ss *SqlSupplier) Session() store.SessionStore {
return ss.oldStores.session
return ss.stores.session
}
func (ss *SqlSupplier) Audit() store.AuditStore {
return ss.oldStores.audit
return ss.stores.audit
}
func (ss *SqlSupplier) ClusterDiscovery() store.ClusterDiscoveryStore {
return ss.oldStores.cluster
return ss.stores.cluster
}
func (ss *SqlSupplier) Compliance() store.ComplianceStore {
return ss.oldStores.compliance
return ss.stores.compliance
}
func (ss *SqlSupplier) OAuth() store.OAuthStore {
return ss.oldStores.oauth
return ss.stores.oauth
}
func (ss *SqlSupplier) System() store.SystemStore {
return ss.oldStores.system
return ss.stores.system
}
func (ss *SqlSupplier) Webhook() store.WebhookStore {
return ss.oldStores.webhook
return ss.stores.webhook
}
func (ss *SqlSupplier) Command() store.CommandStore {
return ss.oldStores.command
return ss.stores.command
}
func (ss *SqlSupplier) CommandWebhook() store.CommandWebhookStore {
return ss.oldStores.commandWebhook
return ss.stores.commandWebhook
}
func (ss *SqlSupplier) Preference() store.PreferenceStore {
return ss.oldStores.preference
return ss.stores.preference
}
func (ss *SqlSupplier) License() store.LicenseStore {
return ss.oldStores.license
return ss.stores.license
}
func (ss *SqlSupplier) Token() store.TokenStore {
return ss.oldStores.token
return ss.stores.token
}
func (ss *SqlSupplier) Emoji() store.EmojiStore {
return ss.oldStores.emoji
return ss.stores.emoji
}
func (ss *SqlSupplier) Status() store.StatusStore {
return ss.oldStores.status
return ss.stores.status
}
func (ss *SqlSupplier) FileInfo() store.FileInfoStore {
return ss.oldStores.fileInfo
return ss.stores.fileInfo
}
func (ss *SqlSupplier) Reaction() store.ReactionStore {
return ss.oldStores.reaction
return ss.stores.reaction
}
func (ss *SqlSupplier) Job() store.JobStore {
return ss.oldStores.job
return ss.stores.job
}
func (ss *SqlSupplier) UserAccessToken() store.UserAccessTokenStore {
return ss.oldStores.userAccessToken
return ss.stores.userAccessToken
}
func (ss *SqlSupplier) ChannelMemberHistory() store.ChannelMemberHistoryStore {
return ss.oldStores.channelMemberHistory
return ss.stores.channelMemberHistory
}
func (ss *SqlSupplier) Plugin() store.PluginStore {
return ss.oldStores.plugin
return ss.stores.plugin
}
func (ss *SqlSupplier) Role() store.RoleStore {
return ss.oldStores.role
return ss.stores.role
}
func (ss *SqlSupplier) TermsOfService() store.TermsOfServiceStore {
return ss.oldStores.TermsOfService
return ss.stores.TermsOfService
}
func (ss *SqlSupplier) UserTermsOfService() store.UserTermsOfServiceStore {
return ss.oldStores.UserTermsOfService
return ss.stores.UserTermsOfService
}
func (ss *SqlSupplier) Scheme() store.SchemeStore {
return ss.oldStores.scheme
return ss.stores.scheme
}
func (ss *SqlSupplier) Group() store.GroupStore {
return ss.oldStores.group
return ss.stores.group
}
func (ss *SqlSupplier) LinkMetadata() store.LinkMetadataStore {
return ss.oldStores.linkMetadata
return ss.stores.linkMetadata
}
func (ss *SqlSupplier) DropAllTables() {

Просмотреть файл

@@ -12,7 +12,7 @@ import (
func TestStoreUpgrade(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
sqlStore := ss.(*store.LayeredStore).DatabaseLayer.(SqlStore)
sqlStore := ss.(SqlStore)
t.Run("invalid currentModelVersion", func(t *testing.T) {
err := UpgradeDatabase(sqlStore, "notaversion")
@@ -81,7 +81,7 @@ func TestStoreUpgrade(t *testing.T) {
func TestSaveSchemaVersion(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
sqlStore := ss.(*store.LayeredStore).DatabaseLayer.(SqlStore)
sqlStore := ss.(SqlStore)
t.Run("set earliest version", func(t *testing.T) {
saveSchemaVersion(sqlStore, VERSION_3_0_0)