Home | Stats | Downloads | Scripts | Wiki

How to fix graphite user creation in FreeBSD 10

2016-03-09 14:22:00 by Michael 0 Comments
Tags: freebsd graphite sysadmin sql

If you see an error like below when you try to create a graphite user you will need to update the graphite database in order for user create to work.

django.db.utils.IntegrityError: NOT NULL constraint failed: auth_user.last_login

Unfortunately sqlite doesn't support the drop constraint syntax so you will need to create a new temporary table, copy over the existing table, and then rename.

CREATE TABLE "auth_user2" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "password" varchar(128) NOT NULL, "last_login" datetime NULL, "is_superuser" bool NOT NULL, "username" varchar(30) NOT NULL UNIQUE, "first_name" varchar(30) NOT NULL, "last_name" varchar(30) NOT NULL, "email" varchar(75) NOT NULL, "is_staff" bool NOT NULL, "is_active" bool NOT NULL, "date_joined" datetime NOT NULL);
insert into auth_user2 select * from auth_user ;
drop table auth_user ;
alter table auth_user2 rename to auth_user ;

Now user creation should work.

root@graphite:/usr/local/lib/python2.7/site-packages/graphite # python manage.py createsuperuser
Username (leave blank to use 'root'): wattersm
Email address: wattersm@watters.ws
Password (again): 
Superuser created successfully.

Return to main page.