mirror of
https://github.com/Unleash/unleash.git
synced 2025-11-24 20:06:55 +01:00
Adds environment support This PR adds environments as a first-class concept in Unleash. It necessitated a full rewrite on how we connect feature <-> strategy, as well as a rethink on which levels environments makes sense. This enables PUTs on strategy configurations for a feature, since all strategies now have ids. This also updates export/import format. The importer handles both formats, but export is no longer possible in version 1 of the export format, only in version 2, with strategy configurations for a feature as a separate object. Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai> Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com> Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
const { v4: uuid } = require('uuid');
|
|
|
|
exports.up = function(db, cb) {
|
|
db.runSql(
|
|
`SELECT *
|
|
FROM features`,
|
|
(err, results) => {
|
|
results.rows.forEach(feature => {
|
|
db.runSql(
|
|
`INSERT INTO feature_environments(feature_name, enabled) VALUES (?, ?)`,
|
|
[feature.name, feature.enabled],
|
|
);
|
|
feature.strategies.forEach(strategy => {
|
|
db.runSql(
|
|
`INSERT INTO feature_strategies(id, feature_name, project_name, strategy_name, parameters, constraints)
|
|
VALUES (?, ?, ?, ?, ?, ?)`,
|
|
[
|
|
uuid(),
|
|
feature.name,
|
|
feature.project,
|
|
strategy.name,
|
|
JSON.stringify(strategy.parameters),
|
|
JSON.stringify(strategy.constraints),
|
|
],
|
|
);
|
|
});
|
|
});
|
|
cb();
|
|
},
|
|
);
|
|
};
|
|
|
|
exports.down = function(db, cb) {
|
|
db.runSql(
|
|
`DELETE FROM feature_strategies; DELETE FROM feature_environments;`,
|
|
cb,
|
|
);
|
|
};
|