Files @ 46681ae86693
Branch filter:

Location: kallithea/MIT-Permissive-License.txt

Mads Kiilerich
db: introduce migration step after 93834966ae01 dropped non-nullable inherit_default_permissions

The database migration step was lazily and naively skipped ... but that turns
out to be a problem when new users are added.
In the database, the original column 'inherit_default_permissions' was
marked as non-nullable without default value. In the Kallithea code after
commit 93834966ae01, the column 'inherit_default_permissions' was no longer
known, and thus not given a value when new users are added. As a result, the
database complained:

IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "inherit_default_permissions" violates not-null constraint

Fix that now by adding an appropriate db migration step to actually remove
the columns.

Use meta reflection to check if columns exist before running the upgrade
step. The upgrade step only has to be run if it is an old database - not if
it has been created after the schema changes were introduced.

For the downgrade step, make sure to set a default value for non-nullable
columns.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.