Upgrading from 0.2.x to 0.3.x
From Pentabarf
WARNING WARNING This page is incomplete.
Upgrading from Pentabarf 0.2.x to 0.3.x requires additional steps. Major changes to the code structure mean that some directories have been replaced with new directories.
As always, have a backup of both your installed Pentabarf software and the database.
This documentation is based upon the upgrades performed and documented by Dan Langille. The following documents the upgrades for http://papers.pgcon.org/ and later confirmed on http://papers.bsdcan.org/.
Contents |
Outline
The following will be performed:
- Upgrade to PostgreSQL 8.2
- Upgrade the Pentabarf source code
- Copy the configuration files
- Upgrade your Pentabarf database
- Installing new dependencies
- Final touches
The Strategy
My approach involved taking a copy of the existing installation and altering it, leaving the working copy untouched. The installed version of Pentabarf was in the directory pentabarf.0.2.8.
After upgrading the source code to 0.3.7, I will then upgrade the database, which will involve several upgrade scripts.
Upgrade to PostgreSQL 8.2
Pentabarf 0.3.x requires PostgreSQL >= 8.2. The upgrade process is outside the scope of this document. However, I did outline what I did during my upgrade process
You will also need the contrib/pgcrypto module supplied with PostgreSQL. In a later step, you will add the pgcrypto functions to the Pentabarf database.
You must add this to postgresql.conf and restart PostgreSQL:
custom_variable_classes = 'pentabarf'
If you see errors similar to this, you forgot that setting:
activate_logging ------------------ (1 row) ERROR: unrecognized configuration parameter "pentabarf.transaction_id" CONTEXT: PL/pgSQL function "conference_day_log_function" line 2 at if
Upgrade the Pentabarf source code
In this sequence of steps, I upgraded Pentabarf from 0.2.8 to 0.3.7. This should help you understand the steps you need to do for your particular situation. I am sure I have not covered all possible scenarios.
I start by copying the working installation to a new location. All further operations will be performed from within the newly created directory.
cp -rp pentabarf.0.2.8 pentabarf.0.3.7 cd pentabarf.0.3.7
The next step was to switch to the new trunk, 0.3.7:
$ svn switch svn://svn.cccv.de/pentabarf/tags/0.3.7 svn: Won't delete locally modified directory '.' svn: File 'pentabarf/app/views/submission/event.rhtml' has local modifications
That local modification is not relevant and will probably not appear during your switch. I had made a local change. Regardless, the pentabarf directory goes away with version 0.3.x so we do not need to concern ourselves with any conflicts in that directory.
I checked the status of my source code to see what was going on. I saw this:
$ svn info Path: . URL: svn://svn.cccv.de/pentabarf/tags/0.3.7 Repository Root: svn://svn.cccv.de/pentabarf Repository UUID: e4c8fbed-4be0-0310-bdf9-e622a6330c8b Revision: 5458 Node Kind: directory Schedule: normal Last Changed Author: sven Last Changed Rev: 4299 Last Changed Date: 2007-04-05 15:58:02 +0100 (Thu, 05 Apr 2007)
This confirms that I'm on the right URL for my upgrade target, namely 0.3.7.
Next, I check my status:
$ svn status
! .
S sql
! S pentabarf
! pentabarf/app
! pentabarf/app/views
! pentabarf/app/views/submission
M pentabarf/app/views/submission/event.rhtml
M pentabarf/app/views/user/account_done.rhtml
S LICENSE
S multiboy
S xslfo
The S means switched relative to parent. I don't need those directories. I will remove each of them manually. You have a backup, so removing anything should not lose you anything valuable.
rm -rf sql pentabarf LICENSE multiboy xslfo
Next, I ran an update to get the missing files that I needed. Specifically, the rails and sql directory.
svn update
I will not show the output as it is too long. Another status command confirms all is well:
$ svn status
S LICENSE
All is well. Your status output should look similar.
Copy over the configuration files
I copied over the configuration files that I knew I had changed. At a minimum, you'll need database.yml.
cp ../pentabarf.0.2.8/pentabarf/config/mail.yml rails/config cp ../pentabarf.0.2.8/pentabarf/config/database.yml rails/config
Again, you may not have a mail.yml file, and you may have other .yml files that you need to copy over. Adjust to your situation.
Upgrading the database
I need to upgrade the database. This will involve several steps. I must hit all the steps along the way. First, I must upgrade my version of 0.2.x to the latest version on the 0.2 branch. A complete list appears at http://trac.pentabarf.org/pentabarf/browser/tags/0.2.13/sql/maintenance
I am starting at 0.2.9, so I need to run four scripts. Here is an easy way to get all the scripts I need:
$ svn export svn://svn.pentabarf.org/pentabarf/branches/0.2/sql/maintenance sql_maint_02 A sql_maint_02 A sql_maint_02/upgrade_0.2.0_to_0.2.1.sql A sql_maint_02/upgrade_0.2.8_to_0.2.9.sql A sql_maint_02/upgrade_0.2.10_to_0.2.11.sql A sql_maint_02/upgrade_0.2.11_to_0.2.12.sql A sql_maint_02/upgrade_0.2.2_to_0.2.3.sql A sql_maint_02/upgrade_0.2.12_to_0.2.13.sql A sql_maint_02/upgrade_0.2.3_to_0.2.4.sql A sql_maint_02/grant.sql A sql_maint_02/foreign_key_constraint_upgrade.sql A sql_maint_02/upgrade_0.2.9_to_0.2.10.sql A sql_maint_02/foreign_key_constraint_upgrade_numeric.sql A sql_maint_02/upgrade_0.2.6_to_0.2.7.sql Exported revision 5458.
The scripts will be placed in a new directory, sql_maint_02.
Now it's time to run the scripts. I will start at the upgrade relative to my current version of Pentabarf: 0.2.9.
Specify the database and database user
In the next steps you have to replace the values for PGDATABASE and PGUSER with the values used during your installation. If you followed the steps on this page both must be set to pentabarf (or whatever user and database name applies to your situation).
* export PGDATABASE=pentabarf * export PGUSER=pentabarf
If you don't set the above variables, you must specify them when you invoke psql during the next steps.
Running the scripts
There are several steps to perform. Frequent backups may be prudent.
Upgrade to 0.2.13
First, I ran the scripts to upgrade to the end of the 0.2.x line:
psql < sql_maint_02/upgrade_0.2.9_to_0.2.10.sql psql < sql_maint_02/upgrade_0.2.10_to_0.2.11.sql psql < sql_maint_02/upgrade_0.2.11_to_0.2.12.sql psql < sql_maint_02/upgrade_0.2.12_to_0.2.13.sql
Upgrade to 0.3.1
Next, I upgraded the database to 0.3.1 using these commands, one of which fetches the functions for 0.3.1
psql < sql/maintenance/upgrade_0.3.0_to_0.3.1.sql svn export svn://svn.pentabarf.org/pentabarf/tags/0.3.1/sql sql_0.3.1 cd sql_0.3.1 psql < functions.sql psql < data/auth.domain.sql psql < data/auth.object_domain.sql cd ..
Upgrade to 0.3.2
Now we repeat the process to get ourselves to 0.3.2
psql < sql/maintenance/upgrade_0.3.1_to_0.3.2.sql svn export svn://svn.pentabarf.org/pentabarf/tags/0.3.2/sql sql_0.3.2 cd sql_0.3.2 psql < functions.sql cd ..
Upgrade to 0.3.3
And again for 0.3.3
psql < sql/maintenance/upgrade_0.3.2_to_0.3.3.sql
With this command, I encountered an error:
ERROR: insert or update on table "event_person" violates foreign key constraint "event_person_event_role_state_fkey" DETAIL: Key (event_role,event_role_state)=(coordinator,idea) is not present in table "event_role_state".
There was a bug in 0.2 which allowed setting improper event role states. The fix is easy. Issue these commands:
echo 'UPDATE event_person SET event_role_state_id = NULL WHERE event_role_id NOT IN (SELECT event_role_id FROM event_role_state);' | psql
Then start again:
psql < sql/maintenance/upgrade_0.3.2_to_0.3.3.sql svn export svn://svn.pentabarf.org/pentabarf/tags/0.3.3/sql sql_0.3.3 cd sql_0.3.3
This time, you need to run types.sql as well. You should see something like this, but do not be concerned by the already exists errors.
psql < types.sql ERROR: relation "conflict_person" already exists ERROR: relation "conflict_person_conflict" already exists ERROR: relation "conflict_event_person" already exists ERROR: relation "conflict_event_person_conflict" already exists ERROR: relation "conflict_event_person_event" already exists ERROR: relation "conflict_event_person_event_conflict" already exists ERROR: relation "conflict_event" already exists ERROR: relation "conflict_event_conflict" already exists ERROR: relation "conflict_event_event" already exists ERROR: relation "conflict_event_event_conflict" already exists CREATE TYPE CREATE TYPE CREATE TYPE CREATE TYPE CREATE TYPE
Now back to the regular processes:
psql < views.sql
If on the above step, you see this error:
psql:views/find/find_person.sql:22: ERROR: cannot change number of columns in view
then execute this command:
echo 'DROP VIEW view_find_person' | psql
In fact, you can do the DROP VIEW regardless. The next command will create the view. In all cases, proceed with the following:
psql < functions.sql cd ..
Upgrade to 0.3.4
Issue these commands:
psql < sql/maintenance/upgrade_0.3.3_to_0.3.4.sql svn export svn://svn.pentabarf.org/pentabarf/tags/0.3.4/sql sql_0.3.4 cd sql_0.3.4 psql < views.sql psql < functions.sql cd ..
Upgrade to 0.3.5
And to 0.3.5
psql < sql/maintenance/upgrade_0.3.4_to_0.3.5.sql svn export svn://svn.pentabarf.org/pentabarf/tags/0.3.5/sql sql_0.3.5 cd sql_0.3.5 psql < functions.sql cd ..
Then you can issue a commit or rollback depending on how it went.
Upgrade to 0.3.6
Now to 0.3.6
psql < sql/maintenance/upgrade_0.3.5_to_0.3.6.sql svn export svn://svn.pentabarf.org/pentabarf/tags/0.3.6/sql sql_0.3.6 cd sql_0.3.6 psql < views.sql psql < functions.sql cd ..
Upgrade to 0.3.7
Ouch, I saw this error:
psql < sql/maintenance/upgrade_0.3.6_to_0.3.7.sql ERROR: constraint "event_conference_id_fkey" does not exist
In my database, this was named event_conference_id_fkey1. This information can be obtained via \d event. I altered the SQL to suit, and ran the script again. See line 10. It looks like this now:
ALTER TABLE event DROP CONSTRAINT event_conference_id_fkey1;
Finally, we get to run the scripts:
psql < sql/maintenance/upgrade_0.3.6_to_0.3.7.sql svn export svn://svn.pentabarf.org/pentabarf/tags/0.3.7/sql sql_0.3.7 cd sql_0.3.7 echo 'DROP VIEW view_find_person' | psql psql < views.sql psql < functions.sql svn cat svn://svn.pentabarf.org/pentabarf/trunk/sql/functions/log/activate_logging.sql | psql echo 'SELECT log.activate_logging();' | psql cd ..
The Pentabarf datababase is now on 0.3.7
Installing new dependencies
There are several new dependencies required for Pentabarf 0.3.x:
- momomoto
- BlueCloth
- shared-mime-info
- iCalendar
- pgcrypto (the PostgreSQL contrib/pgcrypto module)
momomoto
In Pentabarf 0.2, momomoto was part of Pentabarf. In 0.3, it has been separated. If you are upgrading to 0.3.x from 0.2.x, you need to install momomoto:
# gem install momomoto Bulk updating Gem source index for: http://gems.rubyforge.org Successfully installed momomoto-0.1.14 Installing ri documentation for momomoto-0.1.14... Installing RDoc documentation for momomoto-0.1.14...
You also need to run the install.sql script that was installed with momomoto. The path given in the following example is for FreeBSD. On Debian, it is under /var/lib/gems
# cd /usr/local/lib/ruby/gems/1.8/gems/momomoto-0.1.14/sql # psql < install.sql BEGIN CREATE SCHEMA CREATE TYPE CREATE TYPE CREATE FUNCTION CREATE FUNCTION COMMIT
Bluecloth
If you do not have bluecloth installed, you will need it. This has been a dependency since around 0.2.12
# gem install bluecloth Need to update 6 gems from http://gems.rubyforge.org ...... complete Successfully installed BlueCloth-1.0.0
shared-mime-info
And finally, shared-mime-info:
# gem install shared-mime-info Successfully installed shared-mime-info-0.1 Installing ri documentation for shared-mime-info-0.1... Installing RDoc documentation for shared-mime-info-0.1...
You also need the package. On FreeBSD, this is misc/shared-mime-info and is installed this way:
# cd /usr/ports/misc/shared-mime-info # make install clean
Without the shared-mime-info package, uploads will not properly detect the mime type.
iCalendar
To install iCalendar:
# gem install icalendar Need to update 15 gems from http://gems.rubyforge.org ............... complete Successfully installed icalendar-1.0.2 Installing ri documentation for icalendar-1.0.2... Installing RDoc documentation for icalendar-1.0.2...
pgcrypto
The PostgreSQL pgcrypo module is required for Pentabarf 0.3.x. After installation of pgcrypto, you will find pgcrypto.sql. That script must be added to the Pentabarf database. You may need to do this as a superuser, and not as the regular pentabarf user. In this case, pgsql is the superuser. Yours may be postgres, or something else.
# psql -U pgsql< /usr/local/share/postgresql/contrib/pgcrypto.sql SET CREATE FUNCTION CREATE FUNCTION [content removed to reduce space consumed] CREATE FUNCTION CREATE FUNCTION
Final Touches
The final steps are:
- upgrading CSS
- updating ui_messages
- .htaccess
CSS
To update the CSS.
# cd rails/public/stylesheets # make cat main.template | sed -e 's!.*"\(.*\)".*!\1!' | xargs cat > main.css # cd ../../..
On BSD systems, you will probably want gmake, not make.
ui_messages
If you have not done any modification to the ui_messages, you are free to run the DELETE command. If you have done modifications, omit the DELETE and ignore the duplicate key errors you will see during the import.
To upgrade ui_messages:
# cd sql # psql -- only if If no localized messages: DELETE FROM ui_message; -- if you omit the DELETE above ignore any -- duplicate key errors during the next commands \i data/ui_message.sql \i data/ui_message_localized.sql
.htaccess
The rails/public directory needs a .htaccess file for handle incoming web requests. I took mine from the backup and copied it in. Look at rails/public/htaccess.template for a starting point.
More configuration
With this new install, you will need to setup the files in rails/public.
In my case, this was dispatch.fcgi and I added #!/usr/local/bin/ruby to the top of the file.
I also did:
chown www:www rails/log
rails/public will need a .htaccess file. I copied the one from my old installation in pentabarf/public.
You need to set the current conference if you happen to not have a conference with id = 1. This is because the way in which the current conference is stored in 0.3.x has changed. This sets the current conference for all acccounts.
echo 'UPDATE auth.account SET current_conference_id = 1' | psql
Or any other conference id that you have.
Drop old functions
echo ' DROP FUNCTION user_permissions(int); DROP FUNCTION create_account(character varying, character varying, character, character); DROP FUNCTION create_account(character varying, character varying, character, character, integer);' | psql
The last step
The last step is to restart Apache.

