python-slack-sdk icon indicating copy to clipboard operation
python-slack-sdk copied to clipboard

Disable historical_data_enabled in SQLAlchemyInstallationStore / SQLite3InstallationStore

Open alexabunny opened this issue 4 years ago • 2 comments

I'm migrating from FileInstallationStore to SQLAlchemyInstallationStore for storing credentials and don't want to store old installation records when the app is reinstalled.

With FileInstallationStore I used the flag for disabling historical records to do this. I'm trying to accomplish the same with SQLAlchemyInstallationStore and the SDK does check if a previous installation for the team exists and updates the existing record if so. However, in determining if a previous installation exists it requires an exact match on installed_at: https://github.com/slackapi/python-slack-sdk/blob/cf225995b722739f11bc530cc6a9263a44bd4b7a/slack_sdk/oauth/installation_store/sqlalchemy/init.py#L148

This guarantees that reinstalls always create a new record instead of updating the existing one since the install dates will always be different. I'm wondering if this is a bug or if its expected behaviour and there's some other way we're supposed to handle reinstalls.

alexabunny avatar Nov 14 '21 17:11 alexabunny

I did it by calling delete_all(enterprise_id, team_id) before storing the new installation. Still would be handy to have a flag instead though :wink:

alexabunny avatar Nov 14 '21 21:11 alexabunny

Hi @olestourko, thanks for taking the time to write in here!

Indeed, the historical_data_enabled flag option is not available in the relational database based Installation Store implementation (specifically, SQLAlchemyInstallationStore and SQLite3InstallationStore).

We're open to the idea of adding the feature in the future but it won't be a short-term priority. If you operate production-grade apps, we recommend having all the installation history data for safety and for easier troubleshooting.

To disable historical data management right now, please go with your workaround or implement your own InstallationStore for it.

seratch avatar Nov 14 '21 23:11 seratch