Project

General

Profile

PostgreSQL » History » Version 11

Version 10 (smithbone, 02/24/2010 01:19 AM) → Version 11/27 (al, 05/24/2011 12:06 AM)

h1. PostgreSQL

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.

For now, this is only supported in git builds.

h2. Requirements

* postgresql server version 8.3 or greater (version 8.4 or greater recommended)
* postgresql client libraries (qt4-psql)

h2. Preparing the database

We will assume you installed PostgreSQL and properly ran the initdb script.

Login using the database account (in my case pgsql)
> <pre># su pgsql</pre>

Now let's create the quassel database and assign an account.
> <pre>$ psql
postgres=# CREATE USER quassel ENCRYPTED PASSWORD 'somepassword';
CREATE ROLE
postgres=# CREATE DATABASE quassel WITH OWNER quassel ENCODING 'UTF8';
CREATE DATABASE
</pre>

h3. Gentoo specific

Read http://www.gentoo.org/doc/en/postgres-howto.xml if no postgresql-server is installed.
To create an user and a database, just use the following:
<pre>createuser -A -D -P -E -U postgres -W quassel
createdb -U postgres -O quassel -E UTF8 quassel</pre>

h2. Setting up the Quassel Core

Now that the database is running properly, we are going to tell Quassel to use the correct backend.
Use one of the two steps below and you're done!

h3. For a new core

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.

h3. To migrate an existing core

Make sure the core is not running and then execute the following:

> <pre>$ quasselcore --select-backend=PostgreSQL</pre>

An interactive script will request the necessary information to migrate successfully.

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= .
For example Ubuntu puts the config dir in /var/cache/quassel so the command for a proper migration would be:

> <pre>$ quasselcore --configdir=/var/cache/quassel --select-backend=PostgreSQL</pre>

If your migration stops with the following message then you probably forgot the --configdir= parameter

<pre> 2010-02-23 18:01:36 Info: PostgreSQL Storage Backend is ready. Quassel Schema Version: 14
Switched backend to: PostgreSQL
No currently active backend. Skipping migration.
New backend does not support migration: PostgreSQL
Add a new user:
Username:</pre>

h2. Troubleshooting

If your migrartion fails with a message like this

<pre>
Error Number: -1
Error Message: "ERROR: insert or update on table "backlog" violates foreign key constraint "backlog_bufferid_fkey"
DETAIL: Key (bufferid)=(855) is not present in table "buffer".
QPSQL: Unable to create query"
</pre>

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
<pre>
$ sqlite3 quassel-storage.sqlite
sqlite> delete from buffer where bufferid in (select b.bufferid from buffer b left join network n using (networkid) where n.networkid is null);
sqlite> delete from backlog where messageid in (select bl.messageid from backlog bl left join buffer b using (bufferid) where b.bufferid is null);
</pre>