* **Python 3.5+** and ``pip`` for Python 3. You can use ``python -V`` and ``pip3 -V`` to check.
* An SMTP server to send out mails
* An HTTP reverse proxy, e.g. `nginx`_ or Apache to allow HTTPS connections
-* A `PostgreSQL`_ (9.4 or higher) database server.
+* A database server: `MySQL`_ 5.7+ or MariaDB 10.2+ or `PostgreSQL`_ 9.6+.
+ You can use SQLite, but we strongly recommend not to run SQLite in
+ production. Given the choice, we'd recommend to use PostgreSQL.
We also recommend that you use a firewall, although this is not a byro-specific recommendation.
If you're new to Linux and firewalls, we recommend that you start with `ufw`_.
----------------------
Having the database server installed, we still need a database and a database
-user. As the ``postgres`` user, execute::
+user. We recommend using PostgreSQL. byro also works (and runs tests
+against) MariaDB and SQLite. If you do not use PostgreSQL, please refer to the
+appropriate documentation on how to set up a database. For PostgreSQL, run
+these commands::
postgres $ createuser byro -P
- Enter password for new role:
- Enter it again:
- postgres $ createdb byro
- postgres $ psql
- postgres=# GRANT ALL PRIVILEGES ON DATABASE byro to byro;
+ postgres $ createdb -O byro byro
-Replace the asterisks with a password of your own.
+When using MySQL, make sure you set the character set of the database to ``utf8mb4``, e.g. like this::
+ mysql > CREATE DATABASE pretalx DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci
Step 3: Package dependencies
----------------------------
If you want to install byro on a server for actual usage, go to the :ref:`administrator documentation <administrator-setup>` instead.
-* git
-* Python 3.x
-* A recent version of pip (Ubuntu package: ``python3-pip``)
-* gettext (Debian package: ``gettext``)
-* libjpeg or any other library supported in pillow_ (for qrcode_)
-* libmagic
-* A PostgreSQL server
+Please make sure you have the following dependencies installed:
+
++----------------------------------+------------------+
+| Tool | Debian package |
++==================================+==================+
+| Python 3.6(!) or newer | |
++----------------------------------+------------------+
+| pip for Python 3 | ``python3-pip`` |
++----------------------------------+------------------+
+| ``python-dev`` for Python 3 | ``python3-dev`` |
++----------------------------------+------------------+
+| ``python-venv``, if not included | ``python3-venv`` |
++----------------------------------+------------------+
+| libffi | ``libffi-dev`` |
++----------------------------------+------------------+
+| gettext | ``gettext`` |
++----------------------------------+------------------+
+| git | ``git`` |
++----------------------------------+------------------+
+| libmagic | |
++----------------------------------+------------------+
+| libjpgeg | |
++----------------------------------+------------------+
+
+libjpgeg can be replaced by any other library supported in pillow_ (for qrcode_).
Some Python dependencies might also need a compiler during installation, the Debian package
``build-essential`` or something similar should suffice.
cd byro/
-Database setup
---------------
-
-Having the database server installed, we still need a database and a database user::
-
- sudo -u postgres -i
- postgres $ createuser <yourusername>
- postgres $ createdb byro -O <yourusername>
-
-Substitute your system username for ``<yourusername>``.
-
-
Your local python environment
-----------------------------
.. note:: Under Windows, if you get the error message ``failed to find libmagic. Check your installation`` error, do ``pip install python-magic-bin`` in the virtual environment to install the necessary magic library for Windows.
-Next, if you have custom database settings or other settings you need, make a new
-file ``byro.cfg`` with contents like these::
+Create a file called ``byro.cfg`` with this content::
+
+ [database]
+ engine = sqlite3
+
+If you have custom database settings or other settings you need, you can provide them like
+this instead::
[database]
name = byro
host = localhost
port = 5432
-The default -- and recommended -- installation uses PostgreSQL "Peer Authentication", in which the
-Unix user is mapped to the PostgreSQL database user. This works only for local connections, and only
-on Linux, most BSDs, OS X, and Solaris, but provides the highest level of security and the least
-amount of configuration. In this mode the keys ``user``, ``password``, and ``host`` MUST be omitted.
+The default -- and recommended -- production installation uses PostgreSQL, but for local development, you
+can use SQLite instead.
Then, create the local database::
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
-import django_db_constraints.operations
class Migration(migrations.Migration):
related_name="accounts", to="bookkeeping.AccountTag"
),
),
- django_db_constraints.operations.AlterConstraints(
- name="Booking",
- db_constraints={
- "exactly_either_debit_or_credit": "CHECK (NOT ((debit_account_id IS NULL) = (credit_account_id IS NULL)))"
- },
- ),
]
class Migration(migrations.Migration):
- dependencies = [("bookkeeping", "0012_auto_20180617_1926")]
+ dependencies = [
+ ("bookkeeping", "0012_auto_20180617_1926"),
+ ("common", "0013_logentry_logchain"),
+ ]
operations = [
migrations.RunPython(migrate_bookkeeping_model, migrations.RunPython.noop)
memo=self.memo,
)
- class Meta:
- # This is defense in depth, per django-db-constraints module.
- # FUTURE: Should also add a signal or save handler for the same
- # constraint in pure python
- db_constraints = {
- "exactly_either_debit_or_credit": "CHECK (NOT ((debit_account_id IS NULL) = (credit_account_id IS NULL)))"
- }
+ def save(self, *args, **kwargs):
+ if self.debit_account_id and self.credit_account_id:
+ raise Exception("Must be either credit or debit transaction, not both!")
+ if not self.debit_account_id and not self.credit_account_id:
+ raise Exception("Must be either credit or debit transaction, not neither!")
+ return super().save(*args, **kwargs)
def find_memo(self):
if self.memo:
operations = [
# https://stackoverflow.com/questions/28429933/django-migrations-using-runpython-to-commit-changes/39541048#39541048
- migrations.RunSQL(
- "SET CONSTRAINTS ALL IMMEDIATE", reverse_sql=migrations.RunSQL.noop
- ),
+ # UNCOMMENT this section if you are running a large byro upgrade that fails on migration
+ # ALSO uncomment the section at the end of the list of operations
+ # As an alternative, consider upgrading in smaller steps.
+ # migrations.RunSQL(
+ # "SET CONSTRAINTS ALL IMMEDIATE", reverse_sql=migrations.RunSQL.noop
+ # ),
migrations.AlterField(
model_name="logentry",
name="datetime",
fields=["action_type"], name="common_loge_action__1810d9_idx"
),
),
- migrations.RunSQL(
- migrations.RunSQL.noop, reverse_sql="SET CONSTRAINTS ALL IMMEDIATE"
- ),
+ # migrations.RunSQL(
+ # migrations.RunSQL.noop, reverse_sql="SET CONSTRAINTS ALL IMMEDIATE"
+ # ),
]
db_name = config.get("database", "name", fallback=os.path.join(DATA_DIR, "db.sqlite3"))
DATABASES = {
"default": {
- "ENGINE": "django.db.backends.postgresql",
+ "ENGINE": "django.db.backends."
+ + config.get("database", "engine", fallback="postgresql"),
"NAME": db_name,
"USER": config.get("database", "user"),
"PASSWORD": config.get("database", "password"),
"django-annoying~=0.10", # https://github.com/skorokithakis/django-annoying/releases
"django-bootstrap4~=2.0.0", # http://django-bootstrap4.readthedocs.io/en/latest/history.html
"django-compressor~=2.4", # https://django-compressor.readthedocs.io/en/latest/changelog/
- "django-db-constraints~=0.3",
"django-extensions~=2.2", # https://github.com/django-extensions/django-extensions/blob/master/CHANGELOG.md
"django-formset-js-improved==0.5.0.2", # no changelog, https://github.com/pretix/django-formset-js
"django-i18nfield~=1.7", # 2017-11, no changelog, https://github.com/raphaelm/django-i18nfield/