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:
parent
c824b3e26b
commit
3160cd18f0
25
src/migrations/20250922151744-amend-deleted-at.js
Normal file
25
src/migrations/20250922151744-amend-deleted-at.js
Normal 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,
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user