Projet

Général

Profil

Chiliproject » Historique » Version 6

« Précédent - Version 6/26 (diff) - Suivant » - Version actuelle
Mehdi Abaakouk, 15/04/2014 12:08


Chiliproject

La machine chiliproject contient:

- une base données postgres
- une application installé dans /srv/http/chiliproject-X.X.X
- le git de git.tetaneutral.net dans /srv/http/repositories

L'application:

Le vhost d'apache est /etc/apache2/sites-enabled/chiliproject.tetaneutral.net, il pointe vers le répertoire /srv/http/chiliproject qui est un lien symbolique vers /srv/http/chiliproject-X.X.X

La procédure de mise à jour est la suivante:

/etc/init.d/apache2 stop
# su - postgres
# pgdump chiliproject > chiliproject-3.X.X-20130108.sql
# exit
# cd /srv/http/chiliproject
# git fetch origin
# git branch ttnn-prod-3.6.0     # Création d'un nouvelle branche qui contient les modifications ttnn
# git checkout ttnn-prod-3.6.0   # Utilisation de cette branche
# git rebase v3.6.0              # rebase la branche ttnn avec la dernière version de chiliproject

Et continuer les étapes 4 à 10 du howto de chiliproject (cf: https://www.chiliproject.org/projects/chiliproject/wiki/Upgrade#Step-4-Library-installation)
Version rapide:

bundle update
gem cleanup
bundle update
bundle exec rake generate_session_store
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake db:migrate:plugins RAILS_ENV=production
bundle exec rake tmp:cache:clear
bundle exec rake tmp:sessions:clear

Restart de chili

/etc/init.d/apache2 start

La DB du postgres normal:

# su - postgres
# psql chiliproject
chiliproject=# \dt
 public | attachments                         | table | chiliproject
 public | auth_sources                        | table | chiliproject
 public | boards                              | table | chiliproject
 public | changes                             | table | chiliproject
 public | changesets                          | table | chiliproject
 public | changesets_issues                   | table | chiliproject
 public | comments                            | table | chiliproject
 public | custom_fields                       | table | chiliproject
 public | custom_fields_projects              | table | chiliproject
 public | custom_fields_trackers              | table | chiliproject
 public | custom_values                       | table | chiliproject
 public | documents                           | table | chiliproject
 public | enabled_modules                     | table | chiliproject
 public | enumerations                        | table | chiliproject
 public | groups_users                        | table | chiliproject
 public | issue_categories                    | table | chiliproject
 public | issue_relations                     | table | chiliproject
 public | issue_statuses                      | table | chiliproject
 public | issues                              | table | chiliproject
 public | journal_details                     | table | chiliproject
 public | journals                            | table | chiliproject
 public | member_roles                        | table | chiliproject
 public | members                             | table | chiliproject
 public | messages                            | table | chiliproject
 public | news                                | table | chiliproject
 public | open_id_authentication_associations | table | chiliproject
 public | open_id_authentication_nonces       | table | chiliproject
 public | projects                            | table | chiliproject
 public | projects_trackers                   | table | chiliproject
 public | queries                             | table | chiliproject
 public | repositories                        | table | chiliproject
 public | roles                               | table | chiliproject
 public | schema_migrations                   | table | chiliproject
 public | settings                            | table | chiliproject
 public | taggings                            | table | chiliproject
 public | tags                                | table | chiliproject
 public | time_entries                        | table | chiliproject
 public | tokens                              | table | chiliproject
 public | trackers                            | table | chiliproject
 public | user_preferences                    | table | chiliproject
 public | users                               | table | chiliproject
 public | versions                            | table | chiliproject
 public | watchers                            | table | chiliproject
 public | wiki_content_versions               | table | chiliproject
 public | wiki_contents                       | table | chiliproject
 public | wiki_pages                          | table | chiliproject
 public | wiki_redirects                      | table | chiliproject
 public | wikis                               | table | chiliproject
 public | workflows                           | table | chiliproject

Draft migration to redmine

# -*- coding: utf-8 -*-
# vim: ts=4: set ft=sh
#
# CC-BY Mehdi Abaakouk <sileht@sileht.net>
# Inpired from this ruby/mysql version: https://gist.github.com/pallan/6663018
#

# On postgres User

$ createuser -P redmine
$ createdb redmine  -O redmine 
$ pg_dump chiliproject > toredmine.sql
$ psql redmine < toredmine.sql

$ psql redmine <<EOF
ALTER DATABASE redmine OWNER TO redmine;
REASSIGN OWNED BY chiliproject TO redmine;

ALTER TABLE journals RENAME COLUMN created_at TO created_on;
ALTER TABLE journals RENAME COLUMN journaled_id TO journalized_id;
ALTER TABLE journals RENAME COLUMN activity_type TO journalized_type;
ALTER TABLE journals ALTER COLUMN journalized_type TYPE character varying(30);
ALTER TABLE journals ALTER COLUMN journalized_type SET NOT NULL;
ALTER TABLE journals ALTER COLUMN journalized_type SET DEFAULT ''::character varying ;
EOF

# On root:

$ cd /srv/http
$ tsocks git clone https://github.com/redmine/redmine.git -b 2.5-stable
$ cd redmine

$ cat > config/database.yml <<EOF
production:
    adapter: postgresql
    database: redmine
    host: localhost
    username: redmine
    password: redmine
EOF

$ tsocks bundle install --without development test rmagick
$ rake generate_secret_token
$ RAILS_ENV=production bundle exec rake db:migrate

# On postgres user:

$ psql redmine <<EOF
ALTER TABLE wiki_contents ADD comments VARCHAR(250) NULL;
ALTER TABLE wiki_contents RENAME COLUMN lock_version TO version;
ALTER TABLE wiki_contents ALTER COLUMN version TYPE INTEGER;
ALTER TABLE wiki_contents ALTER COLUMN version SET NOT NULL;

UPDATE journals SET journalized_type='Issue' WHERE  journalized_type='issues';

ALTER TABLE journals RENAME COLUMN changes TO changes_chili;
ALTER TABLE journals DROP COLUMN type;
EOF

$ python <<EOF
import yaml;
import psycopg2
conn = psycopg2.connect("dbname='redmine' user='redmine' host='localhost' password='redmine'")

cur = conn.cursor()
cur.execute("""SELECT id, journalized_id, changes_chili FROM journals WHERE id > 0 AND version > 1""")
rows = cur.fetchall()
data = []
hist = {}
for row in rows:
    for k, v in yaml.load(row[2]).iteritems():
        if k == "attachment":
            property = 'attachment'
            prop_key = re.sub("\d+", "", k)
        elif k == "custom_values":
            property = 'cf'
            prop_key = re.sub("\d+", "", k)
        else:
            property = 'attr'
            prop_key = k
        data.append({'id': row[0],
                     'property': property,
                     'prop_key': prop_key,
                     'old_value': v,
                     'new_value': v,
                    })
        if len(data) > 5000:
            cur.executemany("""INSERT INTO journal_details (journal_id, property, prop_key, old_value, value) VALUES (%(id)s,%(property)s,%(prop_key)s,%(old_value)s,%(new_value)s)""", data)
            data = []

cur.executemany("""INSERT INTO journal_details (journal_id, property, prop_key, old_value, value) VALUES (%(id)s,%(property)s,%(prop_key)s,%(old_value)s,%(new_value)s)""", data)
cur.close()
conn.close()
EOF

$ psql redmine <<EOF
DELETE FROM journals WHERE (notes IS NULL OR notes = '' ) AND changes_chili IS NOT NULL AND NOT EXISTS (SELECT 1 FROM journal_details x where x.journal_id=journals.id);
ALTER TABLE journals DROP COLUMN changes_chili;
ALTER TABLE journals DROP COLUMN version;
EOF

# On root in /srv/http/redmine:

$ RAILS_ENV=production REDMINE_LANG=fr bundle exec rake redmine:load_default_data