Verified Commit 6ce8bf0b authored by Dmitry Volodin's avatar Dmitry Volodin
Browse files

Ensure User.last_login is nullable

parent 983eef3d
Pipeline #15366 failed with stages
in 1 minute and 4 seconds
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------
# Set auth_user.last_login to NULLable
# ----------------------------------------------------------------------
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
# NOC modules
from noc.core.migration.base import BaseMigration
class Migration(BaseMigration):
def migrate(self):
is_nullable = self.db.execute(
"""
SELECT is_nullable = 'YES'
FROM information_schema.columns
WHERE
table_name = 'auth_user'
AND column_name = 'last_login'
"""
)[0][0]
if is_nullable:
return
self.db.execute(
"""
ALTER TABLE auth_user
ALTER last_login
DROP NOT NULL
"""
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment