Commit 4fce734a authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Merge branch 'noc-last-login-nullable' into 'master'

Ensure User.last_login is nullable

See merge request !2503
parents a340c912 010e06d3
Pipeline #15397 passed with stages
in 38 minutes and 5 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