1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00
unleash.unleash/src/migrations/20230818124614-update-client-applications-usage-table.js
andreas-unleash d19d97cf18
feat: persist client application usage (#4534)
Closes #
[1-1256](https://linear.app/unleash/issue/1-1256/backend-to-save-application-usage)

Adds client application usage persisting on upsert and bulkUpsert
functions

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-08-21 14:36:31 +03:00

33 lines
1.0 KiB
JavaScript

'use strict';
exports.up = function (db, callback) {
db.runSql(
`
DROP TABLE IF EXISTS client_applications_usage;
CREATE TABLE IF NOT EXISTS client_applications_usage (
app_name VARCHAR(255) REFERENCES client_applications(app_name) ON DELETE CASCADE,
project VARCHAR(255) NOT NULL ,
environment VARCHAR(100) NOT NULL ,
PRIMARY KEY(app_name, project, environment)
) ;
`,
callback,
);
};
exports.down = function (db, callback) {
db.runSql(
`
DROP TABLE IF EXISTS client_applications_usage;
CREATE TABLE IF NOT EXISTS client_applications_usage (
app_name VARCHAR(255) REFERENCES client_applications(app_name) ON DELETE CASCADE,
project VARCHAR(255) REFERENCES projects(id) ON DELETE CASCADE,
environment VARCHAR(100) REFERENCES environments(name) ON DELETE CASCADE,
PRIMARY KEY(app_name, project, environment)
) ;
`,
callback,
);
};