Skip to content
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

[MM-33077] Add migrations for OAuthApps schema #17209

Merged

Conversation

mgdelacroix
Copy link
Member

Summary

implements: https://mattermost.atlassian.net/browse/MM-33077

Ticket Link

https://mattermost.atlassian.net/browse/MM-33077

Release Note

* Moves OAuthApps gorp driven migrations to schema-based migrations

@mgdelacroix mgdelacroix added the 2: Dev Review Requires review by a developer label Mar 23, 2021
@mgdelacroix mgdelacroix requested a review from nronas March 23, 2021 16:00
@mm-cloud-bot mm-cloud-bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Mar 23, 2021
@mgdelacroix mgdelacroix force-pushed the mm-33077-add-migrations-for-oauthapps branch from ce3aa9f to 19ccc86 Compare March 23, 2021 16:42
Comment on lines 15 to 16
ALTER TABLE oauthapps ADD COLUMN IF NOT EXISTS istrusted boolean DEFAULT false;
ALTER TABLE oauthapps ADD COLUMN IF NOT EXISTS iconurl VARCHAR(512) DEFAULT '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current system we don't set defaults on creation and usually we prefer to avoid them. I am wondering if we should change these as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, makes sense 👍

Comment on lines 1 to 11
CREATE TABLE IF NOT EXISTS oauthapps (
id VARCHAR(26) PRIMARY KEY,
creatorid VARCHAR(26),
createat bigint,
updateat bigint,
clientsecret VARCHAR(128),
name VARCHAR(64),
description VARCHAR(512),
callbackurls VARCHAR(1024),
homepage VARCHAR(256)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another general question: I am wondering if it would be simpler for the table creation code to have the most recent version of the table. I am thinking it would be the same logic wise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in that case we would lose the history right? And if we are going to include the down scripts with the reverse steps it wouldn't be consistent. cc @mgdelacroix

Copy link
Member

@isacikgoz isacikgoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 😛

sqlStore.CreateColumnIfNotExists("OAuthApps", "IsTrusted", "tinyint(1)", "boolean", "0")
sqlStore.CreateColumnIfNotExists("OAuthApps", "IconURL", "varchar(512)", "varchar(512)", "")

sqlStore.CreateColumnIfNotExists("OutgoingWebhooks", "TriggerWhen", "tinyint", "integer", "0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related?

Copy link
Member

@isacikgoz isacikgoz Sep 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -58 to -59
as.CreateIndexIfNotExists("idx_oauthaccessdata_user_id", "OAuthAccessData", "UserId")
as.CreateIndexIfNotExists("idx_oauthaccessdata_refresh_token", "OAuthAccessData", "RefreshToken")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are removing stuff for OAuthAccessData but the PR merely focuses on OAuthApps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -259,7 +259,6 @@ func New(settings model.SqlSettings, metrics einterfaces.MetricsInterface) *SqlS

store.stores.channel.(*SqlChannelStore).createIndexesIfNotExists()
store.stores.retentionPolicy.(*SqlRetentionPolicyStore).createIndexesIfNotExists()
store.stores.oauth.(*SqlOAuthStore).createIndexesIfNotExists()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also affects other tables that are not covered in here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related with above.

Copy link
Contributor

@streamer45 streamer45 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed internally. Approving 👍

@isacikgoz isacikgoz merged commit 831cdab into MM-31622/schema-migrations Sep 10, 2021
@isacikgoz isacikgoz deleted the mm-33077-add-migrations-for-oauthapps branch September 10, 2021 16:51
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a developer Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants