1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00

feat: enforce email null when deleted is set

This commit is contained in:
Gastón Fournier 2025-09-23 12:58:03 +02:00
parent c824b3e26b
commit 3160cd18f0
No known key found for this signature in database
GPG Key ID: AF45428626E17A8E

View File

@ -0,0 +1,25 @@
exports.up = (db, callback) => {
db.runSql(
`
UPDATE users
SET deleted_at = NULL
WHERE deleted_at IS NOT NULL and length(email) > 0;
ALTER TABLE users
ADD CONSTRAINT deleted_at_requires_email_null
CHECK (deleted_at IS NULL OR email IS NULL);
`,
callback,
);
};
exports.down = (db, callback) => {
db.runSql(
`
ALTER TABLE users
DROP CONSTRAINT deleted_at_requires_email_null;
`,
callback,
);
};