1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-17 13:46:47 +02:00
unleash.unleash/src/migrations/20250604110546-remove-default-env-from-new-installs.js
Gastón Fournier bdb763c9d5
chore!: remove deprecated default env from new installs (#10080)
**BREAKING CHANGE**: DEFAULT_ENV changed from `default` (should not be
used anymore) to `development`

## About the changes
- Only delete default env if the install is fresh new.
- Consider development the new default. The main consequence of this
change is that the default is no longer considered `type=production`
environment but also for frontend tokens due to this assumption:
724c4b78a2/src/lib/schema/api-token-schema.test.ts (L54-L59)
(I believe this is mostly due to the [support for admin
tokens](https://github.com/Unleash/unleash/pull/10080#discussion_r2126871567))
- `feature_toggle_update_total` metric reports `n/a` in environment and
environment type as it's not environment specific
2025-06-06 12:02:21 +02:00

24 lines
599 B
JavaScript

'use strict';
exports.up = function(db, cb) {
db.runSql(
`SELECT count(*) as count FROM events;`,
(err, results) => {
if (Number(results.rows[0].count) === 4) {
// If there are exactly 4 events, it means this is a new install
db.runSql(
`DELETE FROM environments WHERE name = 'default';`,
cb);
} else {
// If there are not exactly 4 events, do nothing
cb();
}
},
);
};
exports.down = function(db, cb) {
cb();
};