SKAL is a rating client for alcoholic beverages, focused on the icelandic state managed alcohol store. Development is based on the basic structure of the recording client L.O.B.E. developed by Atli Þór Sigurgeirsson at the University of Reykjavik with minor assistance from Stefán Gunnlaugur Jónsson.
-
Other system requirements (installed via apt):
- postgresql
- python-psycopg2
- libpq-dev
- libffi-dev
-
Install Python requirements using
pip3 install -r requirements.txt
- ffmpeg (or avconv)
-
Create a Postgres database. Relevant parameters need to be supplied to the flask via the setting files at
settings/development.py
orsettings/production.py
. -
Spin up a simple development server using
./dev.sh
.- Use
SEMI_PROD=True
to useavconc
instead offfmpeg
- Use
Start by creating a databese and a user:
# Log in as postgres user
sudo -u postgres -i
# Create role for skal and select password
createuser skal --pwprompt
# Create skal database with the new user as owner
createdb skal --owner=skal
Remember to change settings/development.py accordingly. Replace all the values in <BRACKETS> with the postgres information you created just now.
SQLALCHEMY_DATABASE_URI = 'postgresql://<POSTGRES-USERNAME>:<POSTGRES-PWD>@localhost:5432/<DATABASENAME>'
Finally run python manage.py db upgrade
To add defaults to the database run:
python manage.py add_default_roles
Create a super user with python manage.py add_user
-
Create a new database.
- sudo su postgres
- psql
- CREATE DATABASE ;
- GRANT ALL PRIVILEGES ON DATABASE TO <db_user>;
-
Create a database dump of the previous database
- su <lobe_linux_user>
- pg_dump <old_db_name> > <old_db_name>.sql
-
Migrate the schema to the new database
- In settings.<env_name>.py add as the new database name
- run
python3 manage.py db upgrade
- sudo su postgres
- try to restore from the backup with psql < <old_db_name>.sql
-
If that didn't work the following is perhaps helpful
- Rename the migrations folder to e.g.
migrations_old
- Recreate the new database by e.g. DROP DATABASE and then create.
- Try to restore from the same backup as before
- Rename the migrations folder to e.g.
-
If that didn't work, try this
- Recreate a fresh database and run python3 manage.py db init and then run migrates to get schema updates on new database.
- Try creating a dump using
pg_dump -U <user> -Fc '<old_db_name>' > <old_db_name>.dump
- Restore one table at a time using only data :
pg_restore -U <user> --data-only -d <new_db_name> -t <table> <old_db_name>.dump
- Finally restore each sequence by first listing the sequences of the connected database with
\ds
- For each table do SELECT max(id) from ;
- Then alter each sequence with ALTER SEQUENCE <sequence_name> RESTART WITH value+1;