Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.2 KB

README-changedb.md

File metadata and controls

52 lines (38 loc) · 1.2 KB

Switching ncharts database from sqlite to postgres

  1. Setup postgres server See README-devel.md. Note that the postresql-server package must be installed.

  2. Check django database configuration

To dump the existing sqlite database, the database in datavis/settings/default.py should be sqlite:

DATABASES = {
  'default': {
      'ENGINE': 'django.db.backends.sqlite3',
      'NAME': os.path.join(VAR_LIB_DIR, 'db.sqlite3'),
      'OPTIONS': {'timeout': 60,},
  }
}
  1. Save clientstate fields from existing sqlite database
python3 manage.py dumpdata --indent 2 sessions.session ncharts.variabletimes \
    ncharts.clientstate_data_times ncharts.clientstate > /tmp/datadump.json
  1. Switch django database configuration

In datavis/settings/default.py set DATABASES to postgresql:

DATABASES = {
  'default': {
      'ENGINE': 'django.db.backends.postgresql',
      'NAME': 'ncharts',
      'CONN_MAX_AGE': 10,
  }
}
  1. Create and initialize the postgres database

    Follow instructions in README-devel.md or README-prod.md.

  2. Restore clientstate fields

python3 manage.py loaddata /tmp/datadump.json
  1. Restart ncharts