3YOURMIND / django-add-default-value

This django Migration Operation can be used to transfer a Fields default value to the database scheme.
Apache License 2.0
138 stars 19 forks source link

Warn when being run against unsupported databases #28

Closed vanschelven closed 3 years ago

vanschelven commented 3 years ago

As per discussion in a sibbling project:

https://github.com/3YOURMIND/django-migration-linter/issues/138

Self-quoting:

I have to admit that I already noticed that AddDefaultValue doesn't support sqlite, but in my mind silently ignoring the migration was the desired behavior in that case. My implicit reasoning was: when using sqlite, you're in some testing/development environment, and actually have no need for the defaulting behavior, because multiple code-bases accessing the same database is simply not a scenario that comes up for such environments.

On second thought, however, I realise that there the mapping (development <=> sqlite) may often occur in practice but is by no means absolute. Given that there are still scenarios (such as mine) in which silent ignoring is in fact fine, so outright crashing is not desired, I will file an issue to raise a warning in that package also.

Which I hereby did :smile:

I suppose the following lines might be a place for the warning:

https://github.com/3YOURMIND/django-add-default-value/blob/9fef3afc04acea8cac3d4383cd93cb957ecc7116/django_add_default_value/add_default_value.py#L77

https://github.com/3YOURMIND/django-add-default-value/blob/9fef3afc04acea8cac3d4383cd93cb957ecc7116/django_add_default_value/add_default_value.py#L137

flixx commented 3 years ago

@vanschelven Sounds and looks reasonable! Thanks for that! I will test it during the next days. Do you know how hard it would be to actually support sqlite?

vanschelven commented 3 years ago

Do you know how hard it would be to actually support sqlite?

TBH I'm an expert on neither this package, nor on sqlite, so I wouldn't really be able to tell.

flixx commented 3 years ago

This is merged. Thanks @vanschelven for your contribution :)