Closed cribello closed 10 years ago
renamed old db to dao_indivo and created a fresh indivo db from psql console
postgres=# ALTER DATABASE indivo RENAME TO dao_indivo;
ALTER DATABASE
postgres=# CREATE DATABASE indivo OWNER indivo;
CREATE DATABASE
postgres=# \list
Now trying to reset db again ...
postgres@curatehealth:/indivo/indivo_server$ python utils/reset.py
Traceback (most recent call last):
File "utils/reset.py", line 17, in
@ddang0105 What is the postgres sudo password?
login to the server with root. go to the root folder and python utils/reset.py..
python utils/reset.py does not work with existing db..
root@curatehealth:/indivo/indivo_server# python utils/reset.py
You have requested a reset of the database.
This will IRREVERSIBLY DESTROY all data currently in the 'indivo' database,
and return each table to its initial state.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
RESETTING DATABASE...
Flushing the Database of existing data...
Error: Database indivo couldn't be flushed. Possible reasons:
* The database isn't running or isn't configured correctly.
* At least one of the expected database tables doesn't exist.
* The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
The full error: cannot truncate a table referenced in a foreign key constraint
DETAIL: Table "indivo_problem_encounters" references "indivo_encounter".
HINT: Truncate table "indivo_problem_encounters" at the same time, or use TRUNCATE ... CASCADE.
So i renamed old db..
root@curatehealth:/indivo/indivo_server# sudo su postgres
postgres@curatehealth:/indivo/indivo_server$ psql
psql (9.1.13)
Type "help" for help.
postgres=# \list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
------------+----------+----------+-------------+-------------+-----------------------
dao_indivo | indivo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
indivo | indivo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(5 rows)
postgres=# ALTER DATABASE indivo RENAME TO old_indivo_3rd_july;
ALTER DATABASE
^Z
[2]+ Stopped psql
I created a new db..
postgres@curatehealth:/indivo/indivo_server$ createdb -U indivo -O indivo indivo
python utils/reset.py does not work if you are not logged as root..
postgres@curatehealth:/indivo/indivo_server$ python utils/reset.py
Traceback (most recent call last):
File "utils/reset.py", line 17, in <module>
from django.db import connection, DatabaseError, IntegrityError
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 14, in <module>
if not settings.DATABASES:
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 90, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/indivo/indivo_server/settings.py", line 114, in <module>
filename = APP_HOME + '/indivo.log', filemode = 'a')
File "/usr/lib/python2.7/logging/__init__.py", line 1519, in basicConfig
hdlr = FileHandler(filename, mode)
File "/usr/lib/python2.7/logging/__init__.py", line 897, in __init__
StreamHandler.__init__(self, self._open())
File "/usr/lib/python2.7/logging/__init__.py", line 916, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: '/indivo/indivo_server/indivo.log'
postgres@curatehealth:/indivo/indivo_server$
logged in back as root..
login as: root
root@128.199.200.18's password:
Now after closing all the existing db connection, running the reset script again..
Last login: Mon Aug 4 03:22:08 2014 from 112.79.39.47
root@curatehealth:~# cd /indivo/indivo_server/
root@curatehealth:/indivo/indivo_server# python utils/reset.py
You have requested a reset of the database.
This will IRREVERSIBLY DESTROY all data currently in the 'indivo' database,
and return each table to its initial state.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
RESETTING DATABASE...
Flushing the Database of existing data...
Database nonexistent or corrupted, or Database drop requeseted. Attempting to drop database...
Password:
Creating the Database...
Password:
Syncing and Migrating the database...
Database Synced.
LOADING INITIAL INDIVO DATA...
Adding authsystem: auth_system_example
Adding account: johnsmith@indivo.org
Loading data profile patient_967332 for record John S. Smith
Processing Machine App sample_ui...
New app. Registering...
Processing Machine App sample_admin...
New app. Registering...
Processing User App smart_problems...
New app. Registering...
Processing User App problems...
New app. Registering...
Processing User App smart_api_playground...
New app. Registering...
Processing User App smart_api_verifier...
New app. Registering...
Processing User App bp_centiles...
New app. Registering...
Processing User App allergies...
New app. Registering...
Processing User App smart_med_list...
New app. Registering...
Processing User App labs...
New app. Registering...
Processing User App medications...
New app. Registering...
Processing User App smart_med_calendar...
New app. Registering...
Processing User App smart_med_adherence...
New app. Registering...
LOADED.
root@curatehealth:/indivo/indivo_server# nano /etc/apache2/sites-available/default
root@curatehealth:/indivo/indivo_server# python manage.py cleanup_old_tokens
Now running the unit test to check server..
root@curatehealth:/indivo/indivo_server# python manage.py test indivo
Creating test database for alias 'default'...
..............................................................................................................
==========================
RUNNING INTEGRATION TESTS:
==========================
=============================================================================
Report:
.......... pass : Document Handling Test
.......... pass : Sharing
.......... pass : PHA Document Handling
.......... pass : PHAing record_app delete
.......... pass : PHAing app delete
.......... pass : AppSpecific
.......... pass : Document Metadata Test
.......... pass : OAuthing
.......... pass : Binary Document Test
.......... pass : Accounting
.......... pass : Record Shares
.......... pass : Messaging
.......... pass : Special Document Handling
.......... pass : Auditing
.......... pass : Document Processing Test
.......... pass : Security
=============================================================================
................................................................................................................................................................
----------------------------------------------------------------------
Ran 270 tests in 108.673s
OK
Destroying test database for alias 'default'...
root@curatehealth:/indivo/indivo_server#
root@curatehealth:/indivo/indivo_server# python utils/reset.py RESETTING DATABASE... Flushing the Database of existing data... Error: Database indivo couldn't be flushed. Possible reasons:
when i manually checked the db entries there are many duplicate entries due to multiple installation attempt.. So i am planning to create the db again..