Project

General

Profile

PostgreSQL » History » Version 12

al, 05/24/2011 12:06 AM

1 1 sph
h1. PostgreSQL
2 1 sph
3 1 sph
This article describes how you can use Quassel with the PostgreSQL database. It is written from a FreeBSD point of view, but the process should be very similar for any other system out there. 
4 1 sph
5 6 sph
For now, this is only supported in git builds.
6 6 sph
7 8 pennywise
8 8 pennywise
h2. Requirements
9 8 pennywise
10 9 m4yer
 * postgresql server version 8.3 or greater (version 8.4 or greater recommended)
11 8 pennywise
 * postgresql client libraries (qt4-psql)
12 1 sph
13 1 sph
h2. Preparing the database
14 1 sph
15 1 sph
We will assume you installed PostgreSQL and properly ran the initdb script.
16 1 sph
17 1 sph
Login using the database account (in my case pgsql)
18 1 sph
> <pre># su pgsql</pre>
19 1 sph
20 1 sph
Now let's create the quassel database and assign an account.
21 2 EgS
> <pre>$ psql
22 2 EgS
postgres=# CREATE USER quassel ENCRYPTED PASSWORD 'somepassword';
23 2 EgS
CREATE ROLE
24 2 EgS
postgres=# CREATE DATABASE quassel WITH OWNER quassel ENCODING 'UTF8';
25 2 EgS
CREATE DATABASE
26 1 sph
</pre>
27 1 sph
28 7 pennywise
h3. Gentoo specific
29 7 pennywise
30 7 pennywise
Read http://www.gentoo.org/doc/en/postgres-howto.xml if no postgresql-server is installed.
31 7 pennywise
To create an user and a database, just use the following:
32 7 pennywise
<pre>createuser -A -D -P -E -U postgres -W quassel
33 7 pennywise
createdb -U postgres -O quassel -E UTF8 quassel</pre>
34 7 pennywise
35 1 sph
h2. Setting up the Quassel Core
36 1 sph
37 1 sph
Now that the database is running properly, we are going to tell Quassel to use the correct backend.
38 1 sph
Use one of the two steps below and you're done!
39 1 sph
40 1 sph
h3. For a new core
41 1 sph
42 2 EgS
Just connect to the core using a Quassel Client to launch the first run wizard. Select the PostgreSQL backend in the dropdown list and fill in the needed credentials to connect to the Postgres DB you just created.
43 1 sph
44 1 sph
h3. To migrate an existing core
45 1 sph
46 5 sph
Make sure the core is not running and then execute the following:
47 4 sph
48 3 EgS
> <pre>$ quasselcore --select-backend=PostgreSQL</pre>
49 1 sph
50 1 sph
An interactive script will request the necessary information to migrate successfully.
51 10 smithbone
52 10 smithbone
If your existing database and config file are in a different location than the default then you need to specify the --configdir= parameter as well as the --select-backend= .
53 10 smithbone
For example Ubuntu puts the config dir in /var/cache/quassel so the command for a proper migration would be:
54 10 smithbone
55 10 smithbone
> <pre>$ quasselcore --configdir=/var/cache/quassel --select-backend=PostgreSQL</pre>
56 10 smithbone
57 10 smithbone
If your migration stops with the following message then you probably forgot the --configdir= parameter
58 10 smithbone
59 10 smithbone
<pre> 2010-02-23 18:01:36 Info: PostgreSQL Storage Backend is ready. Quassel Schema Version: 14                                                                                       
60 10 smithbone
Switched backend to: PostgreSQL                                                         
61 10 smithbone
No currently active backend. Skipping migration.                                        
62 10 smithbone
New backend does not support migration: PostgreSQL                                      
63 10 smithbone
Add a new user:                                                                         
64 10 smithbone
Username:</pre>
65 11 al
66 11 al
h2. Troubleshooting
67 11 al
68 12 al
If your migration fails with a message like this
69 11 al
<pre>
70 11 al
  Error Number: -1
71 11 al
  Error Message: "ERROR:  insert or update on table "backlog" violates foreign key constraint "backlog_bufferid_fkey"
72 11 al
DETAIL:  Key (bufferid)=(855) is not present in table "buffer".
73 11 al
QPSQL: Unable to create query"
74 11 al
</pre>
75 11 al
76 11 al
your SQLite DB probably contains leftovers from e.g. a deleted network. Make sure you have a backup and try to clean the invalid data sets from the database by issuing
77 11 al
<pre>
78 11 al
$ sqlite3 quassel-storage.sqlite 
79 11 al
sqlite> delete from buffer where bufferid in (select b.bufferid from buffer b left join network n using (networkid) where n.networkid is null);
80 11 al
sqlite> delete from backlog where messageid in (select bl.messageid from backlog bl left join buffer b using (bufferid) where b.bufferid is null);
81 11 al
</pre>