1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

chore: db migration for integration events (#7604)

https://linear.app/unleash/issue/2-2435/create-migration-for-a-new-integration-events-table

Adds a DB migration that creates the `integration_events` table:
 - `id`: Auto-incrementing primary key;
- `integration_id`: The id of the respective integration (i.e.
integration configuration);
 - `created_at`: Date of insertion;
- `state`: Integration event state, as text. Can be anything we'd like,
but I'm thinking this will be something like:
   - Success 
   - Failed 
   - SuccessWithErrors ⚠️
- `state_details`: Expands on the previous column with more details, as
text. Examples:
   - OK. Status code: 200
   - Status code: 429 - Rate limit reached
   - No access token provided
 - `event`: The whole event object, stored as a JSON blob;
- `details`: JSON blob with details about the integration execution.
Will depend on the integration itself, but for example:
   - Webhook: Request body
- Slack App: Message text and an array with all the channels we're
posting to

I think this gives us enough flexibility to cover all present and
(possibly) future integrations, but I'd like to hear your thoughts.

I'm also really torn on what to call this table:
- `integration_events`: Consistent with the feature name. Addons are now
called integrations, so this would be consistent with the new thing;
 - `addon_events`: Consistent with the existing `addons` table.
This commit is contained in:
Nuno Góis 2024-07-17 10:02:04 +01:00 committed by GitHub
parent 4fb5469cb5
commit 13d02685d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 2 deletions

View File

@ -0,0 +1,29 @@
exports.up = function (db, cb) {
db.runSql(
`
CREATE TABLE IF NOT EXISTS integration_events
(
id BIGSERIAL PRIMARY KEY NOT NULL,
integration_id INTEGER NOT NULL REFERENCES addons(id) ON DELETE CASCADE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
state TEXT NOT NULL,
state_details TEXT NOT NULL,
event JSONB NOT NULL,
details JSONB NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_integration_events_integration_id ON integration_events(integration_id);
`,
cb,
);
};
exports.down = function (db, cb) {
db.runSql(
`
DROP INDEX IF EXISTS idx_integration_events_integration_id;
DROP TABLE IF EXISTS integration_events;
`,
cb,
);
};

View File

@ -174,8 +174,8 @@ module.exports = {
{
type: 'doc',
label: 'Examples',
id: 'feature-flag-tutorials/rust/examples'
}
id: 'feature-flag-tutorials/rust/examples',
},
],
},
{