1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/src/migrations/20221121133546-soft-delete-user.js
sjaanus b071de6742
Add possibility to soft delete users (#2497)
Previously we hard deleted the users, but due to change requests and
possibly other features in future, we really want to hard-link user
table and have meaningful relationships.

But this means, when user is deleted, all linked data is also deleted.
**Workaround is to soft delete users and just clear users data and keep
the relationships alive for audit logs.**

This PR implements this feature.
2022-11-23 09:30:54 +02:00

20 lines
380 B
JavaScript

'use strict';
exports.up = function (db, callback) {
db.runSql(
`
ALTER TABLE users ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMP WITH TIME ZONE;
`,
callback,
);
};
exports.down = function (db, callback) {
db.runSql(
`
ALTER TABLE users DROP COLUMN IF EXISTS deleted_at;
`,
callback,
);
};