History and Logbook not showing any data after upgrade to 0.26.1

I am running Home Assistant on Ubuntu 16.04 LTS before upgrade of Home Assistant to 0.26.1 I was running version 0.24.1. And command I was using to run Home Assistant was “hass --open-ui”. When I tried to upgrade Home Assistant to latest version 0.26.1 today using command “pip3 --upgrade homeassistant” after doing few things it gave me error saying permission denied. So I used same command with sudo like this “sudo pip3 --upgrade homeassistant” and all went smooth. Then I restarted Home Assistant and it failed so tried again using the same command “hass --open-ui” and got permission denied error so I tried with sudo like this “sudo hass --open-ui” and all worked as expected and it got upgraded to 0.26.1 but my one of the python script which pull history using command “https://my_ha_url/api/history/period/2016-08-14?filter_entity_id=my_sensor_id” fails and gives error “404: not found”. Also from Home Assistant UI also doesn’t show me any history or logbook.
Please help me, is that due to I had to upgrade using root user (sudo) or something is broken in 0.26.1?
Thanks a lot

You’ll need to migrate your existing data to the new DB format as per here:

$ pip3 install SQLAlchemy
$ hass --script db_migrator --append

I had the same issue and the above sorted out my history.

Thanks for the reply @Vertikar
As I mentioned earlier my previous version was 0.24.1 so my database was already migrated to newer version (v2) and the name of DB file is home-assistant_v2.db. And the link you provided also talks about migrating from older than 0.24 version. Still tried that script and it gave me an error saying “Fatal Error: Old format database ‘/home/home/.homeassistant/home-assistant.db’ does not exist”

I am stuck now and not sure what to try next as it was working just before upgrade to 0.26.1 and I keep getting ‘404: Not Found’ error. Below is the pyton script if someone figure out something wrong please let me know.
By the way I am running https using Letsencript certificate and my url is also secured one in below script, not sure how I can use local ip without secured one though as it gives certificate error.

#!/user/bin/env python
# -*- coding: utf-8 -*-

import datetime
import json
from requests import get
from requests import post

base_url_get = 'https://_my_ha_url_/api/history/period/'
headers = {'x-ha-access': 'my_pwd_xxxx', 'content-type': 'application/json'}


url = base_url_get+requested_date+'?filter_entity_id='+entity_name

response = get(url, headers=headers)

Ahh, yup, I get you. I think I upgraded from a version prior to 0.24, hence why I ran into issues.
Is your .db file still of a decent size?

Yes, my db size is about 316mb (purge every 7 days) as I have lot of things going on.