From 2459728aec2a008d624e3e57b1e113f60d45957a Mon Sep 17 00:00:00 2001 From: Adrian Moennich Date: Thu, 12 Jun 2014 16:28:09 +0200 Subject: [PATCH] Use an ARRAY for edit log entries Using a ```-separated string is *very* strange and would break when some change line contained that string. To convert an existing database without recreating it, use this query: ALTER TABLE reservation_edit_logs ALTER COLUMN info TYPE varchar[] USING string_to_array(info, '```'); --- DEVELOPMENT.md | 2 ++ bin/migration/migrate_to_sqlalchemy.py | 2 +- indico/MaKaC/webinterface/tpls/RoomBookingDetails.tpl | 7 +++---- indico/htdocs/js/indico/RoomBooking/validation.js | 2 +- indico/modules/rb/models/reservation_edit_logs.py | 4 +++- indico/modules/rb/models/reservations.py | 8 ++++---- indico/tests/db/data.py | 4 ++-- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 0c40fd028ff..420f61c4583 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -8,3 +8,5 @@ For the moment, we are focusing on _PostgreSQL_. These are some of the specific * `array_agg()`, since MySQL doesn't have ARRAY type. You can find occurrences of them within: - _indico/modules/rb/models/locations.py_ - _indico/modules/rb/models/rooms.py_ + +* ReservationEditLog uses a PostgreSQL ARRAY to store the changes for a single log entry diff --git a/bin/migration/migrate_to_sqlalchemy.py b/bin/migration/migrate_to_sqlalchemy.py index d2aa30e751a..ac352b71b88 100644 --- a/bin/migration/migrate_to_sqlalchemy.py +++ b/bin/migration/migrate_to_sqlalchemy.py @@ -406,7 +406,7 @@ def migrate_reservations(rb_root): el = ReservationEditLog( timestamp=ts, user_name=h._responsibleUser, - info=convert_to_unicode('```'.join(h._info)) # TODO: store this properly! + info=map(convert_to_unicode, h._info) ) r.edit_logs.append(el) diff --git a/indico/MaKaC/webinterface/tpls/RoomBookingDetails.tpl b/indico/MaKaC/webinterface/tpls/RoomBookingDetails.tpl index f7e0a67d3c1..80573cf4e1b 100644 --- a/indico/MaKaC/webinterface/tpls/RoomBookingDetails.tpl +++ b/indico/MaKaC/webinterface/tpls/RoomBookingDetails.tpl @@ -417,15 +417,14 @@