Closed jpaniagualaconich closed 1 year ago
Merging #610 (dc726e4) into master (fd07d82) will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## master #610 +/- ##
=======================================
Coverage 95.46% 95.46%
=======================================
Files 74 74
Lines 3198 3198
Branches 358 358
=======================================
Hits 3053 3053
Misses 116 116
Partials 29 29
Impacted Files | Coverage Δ | |
---|---|---|
two_factor/plugins/webauthn/models.py | 91.66% <100.00%> (ø) |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
OK, ready for another round.
Admittedly a not-super-elegant solution but I like its simplicity.
Been there, tried that. Tinkering with CreateModel
, state_forwards
and database_forwards
means too much wading through the entrails of the migration infrastructure.
Also, I didn't want to depend on an undocumented vendor
attribute.
Anyway, let me propose a somewhat different solution that leaves CreateModel
and AlterField
alone and instead modifies Migration.apply
and unapply
directly and is perhaps less hacky, at least in my opinion.
I'm afraid I don't fully understand your question. Avoid the second migration in which sense?
Applying 0002 for MySQL results in a no-op, so for practical purposes we are avoiding the second migration already.
My (maybe stupid) question was that if we fixed the MySQL issue, can we keep the unique index?
We want model state to be the same in all cases, MySQL or not, after 0002 is applied so a future 0003 migration won't need to do acrobatics like 0001 and 0002 are forced to do now.
When the executor builds the state of the model it uses Migration.mutate_state
which doesn't get schema_editor
, meaning that we can't change things for MySQL since we don't know the database.
As a result, the non-MySQL versions of 0001 and 0002 are used. The consequence of this is that the state of WebauthnDevice
is wrong for MySQL after mutate_state
for 0001, getting fixed only after mutate_state
for 0002.
In any case, having that pesky unique=True
was totally unneeded in the first place.
That makes a lot of sense. Can you please rebase your PR now? Tests should hopefully pass.
Current error: File "...two_factor/plugins/webauthn/migrations/0001_initial.py", line 60, in Migration operations = [create_webauthn_device_model(True)] TypeError: 'staticmethod' object is not callable
deprecated codecov gave up the ghost?
Looks so... I will not regret it.
Looks like #619 fix this failure.
Could you please rebase on master ? #619 was merged.
done. Looks ready for the merge.
Description
Drops the unique constraint on
Webauthn.public_key
.Modifies two_factor_webauthn migration 0001 so public_key doesn't start with a unique constraint, otherwise it'll fail if the db is MariaDB.
Adds 0002 to drop the unique constraint. It'll still run fine even if there is no unique constraint to drop, resulting in a no-op in that case.
Motivation and Context
Fixes #594 .
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: