summaryrefslogtreecommitdiff
path: root/docs/manual/smsd/pgsql.rst
blob: eb55b622534b37e05a813aae954c487e269da7a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
.. _gammu-smsd-pgsql:

PostgreSQL Backend
==================

Description
-----------

PGSQL backend stores all data in a `PostgreSQL`_ database server, which
parameters are defined by configuration (see :ref:`gammu-smsdrc` for description of
configuration options).

For tables description see :ref:`gammu-smsd-tables`.

This backend is based on :ref:`gammu-smsd-sql`.

.. _PostgreSQL: https://www.postgresql.org/

Configuration
-------------

Before running :ref:`gammu-smsd` you need to create necessary tables in the
database, which is described below.

The configuration file then can look like:

.. code-block:: ini

    [smsd]
    service = sql
    driver = native_pgsql
    host = localhost

.. seealso:: :ref:`gammu-smsdrc`

.. _pgsql-create:

Creating tables for PostgreSQL
------------------------------

SQL script for creating tables in PostgreSQL database:

.. literalinclude:: ../../sql/pgsql.sql
   :language: sql

.. note::

    You can find the script in :file:`docs/sql/pgsql.sql` as well.

Upgrading tables
----------------

The easiest way to upgrade database structure is to backup old one and start
with creating new one based on example above.

For upgrading existing database, you can use changes described in
:ref:`smsd-tables-history` and then manually update ``Version`` field in
``gammu`` table.