Flagsmith / Flagsmith/flagsmith

Rolling back from >2.154.0 to an earlier version causes logins to fail

Open
#5,257 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.6k
Forks
567
Avg merge
1d 13h
Merged PRs (30d)
121

Description

### How are you running Flagsmith

- [x] Self Hosted with Docker
- [x] Self Hosted with Kubernetes
- [ ] SaaS at flagsmith.com
- [ ] Some other way (add details in description below)

### Describe the bug

In API 2.154.0, we changed the `users_ffadminuser.uuid` column to be not null: https://github.com/Flagsmith/flagsmith/pull/4832

Applying this migration adds a database-level not null constraint, but it does not set the default value at the database.

If this migration is applied and then rolled back, the not null constraint is never removed, so a user trying to log in can fail with an error like this:

```
django.db.utils.IntegrityError: null value in column "uuid" of relation "users_ffadminuser" violates not-null constraint
```

This happens because Django does not set database-level defaults, and only does this at the application level.

To prevent this from happening, we should add a migration that removes this not null constraint. That way, if a user needs to upgrade and roll back, they won't be affected by this issue.

Suppose we release this new migration in version X. If the user upgrades to some other version Y

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.