Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/zsh
export PG=postgresql:///indico_lcagenda
export ZODB=zeo://127.0.0.1:29675
export ARCHIVE_DIR=/afs/cern.ch/project/ILC/ilcagenda/archive/
export SYMLINK_DIR=/afs/cern.ch/project/ILC/ilcagenda/archive/legacy-symlinks/
export JANITOR_ID=11848
pyg() {
pygmentize -l $1 -f terminal256 -O style=native,bg=dark
}
dbdiff() {
local a=indico_lcagenda b=indico_dbdiff
createdb -T indico_template $b && \
INDICO_CONF_OVERRIDE='{"SQLAlchemyDatabaseURI": "postgresql:///'$b'"}' indico db prepare 2>/dev/null >/dev/null && \
pg_dump -s -f /tmp/indico_dbdiff_$a.sql $a && \
pg_dump -s -f /tmp/indico_dbdiff_$b.sql $b && \
dropdb $b && \
java -jar ~/apgdiff-2.4.jar /tmp/indico_dbdiff_$a.sql /tmp/indico_dbdiff_$b.sql | pyg sql && \
rm /tmp/indico_dbdiff_$a.sql /tmp/indico_dbdiff_$b.sql
}
setup() {
truncate -s 0 requirements.txt
python setup.py develop >/dev/null
truncate -s 0 indico.egg-info/requires.txt
}
pause() {
echo "$1 [press enter to continue]"
read
}
checkout() {
checkout_ns $1
setup
}
checkout_ns() {
git stash
git checkout --detach $1
cherry 3a95acc
}
cherry() {
git cherry-pick --keep-redundant-commits $1
}
set -ex
pause 'v1.9.1?'
checkout 6cbdffd
indico db upgrade
checkout v1.9.1
indico db upgrade
psql indico_lcagenda << EOF
DROP INDEX indico.ix_settings_module_key;
CREATE INDEX ix_settings_module_name ON indico.settings USING btree (module, name);
EOF
dbdiff
pause 'dbdiff empty?'
indico-zodbimport "$PG" "$ZODB" payment
pause 'v1.9.2?'
checkout v1.9.2
indico db upgrade
psql indico_lcagenda << EOF
ALTER TABLE events.settings DROP CONSTRAINT ck_settings_lowercase_module;
ALTER TABLE events.settings DROP CONSTRAINT ck_settings_lowercase_name;
ALTER TABLE events.settings_principals DROP CONSTRAINT ck_settings_principals_lowercase_module;
ALTER TABLE events.settings_principals DROP CONSTRAINT ck_settings_principals_lowercase_name;
ALTER TABLE events.settings_principals DROP CONSTRAINT ck_settings_principals_valid_local_group;
ALTER TABLE events.settings_principals DROP CONSTRAINT ck_settings_principals_valid_mp_group;
ALTER TABLE events.settings_principals DROP CONSTRAINT ck_settings_principals_valid_user;
ALTER TABLE events.settings_principals ADD CONSTRAINT ck_settings_principals_valid_local_group CHECK (((type <> 2) OR ((((user_id IS NULL) AND (mp_group_provider IS NULL)) AND (mp_group_name IS NULL)) AND (local_group_id IS NOT NULL))));
ALTER TABLE events.settings_principals ADD CONSTRAINT ck_settings_principals_valid_multipass_group CHECK (((type <> 3) OR ((((local_group_id IS NULL) AND (user_id IS NULL)) AND (mp_group_provider IS NOT NULL)) AND (mp_group_name IS NOT NULL))));
ALTER TABLE events.settings_principals ADD CONSTRAINT ck_settings_principals_valid_user CHECK (((type <> 1) OR ((((local_group_id IS NULL) AND (mp_group_provider IS NULL)) AND (mp_group_name IS NULL)) AND (user_id IS NOT NULL))));
ALTER TABLE indico.settings_principals DROP CONSTRAINT ck_settings_principals_lowercase_module;
ALTER TABLE indico.settings_principals DROP CONSTRAINT ck_settings_principals_lowercase_name;
ALTER TABLE indico.settings_principals DROP CONSTRAINT ck_settings_principals_valid_local_group;
ALTER TABLE indico.settings_principals DROP CONSTRAINT ck_settings_principals_valid_mp_group;
ALTER TABLE indico.settings_principals DROP CONSTRAINT ck_settings_principals_valid_user;
ALTER TABLE indico.settings_principals ADD CONSTRAINT ck_settings_principals_valid_local_group CHECK (((type <> 2) OR ((((user_id IS NULL) AND (mp_group_provider IS NULL)) AND (mp_group_name IS NULL)) AND (local_group_id IS NOT NULL))));
ALTER TABLE indico.settings_principals ADD CONSTRAINT ck_settings_principals_valid_multipass_group CHECK (((type <> 3) OR ((((local_group_id IS NULL) AND (user_id IS NULL)) AND (mp_group_provider IS NOT NULL)) AND (mp_group_name IS NOT NULL))));
ALTER TABLE indico.settings_principals ADD CONSTRAINT ck_settings_principals_valid_user CHECK (((type <> 1) OR ((((local_group_id IS NULL) AND (mp_group_provider IS NULL)) AND (mp_group_name IS NULL)) AND (user_id IS NOT NULL))));
ALTER TABLE roombooking.blocking_principals ADD CONSTRAINT fk_blocking_principals_local_group_id_groups FOREIGN KEY (local_group_id) REFERENCES users.groups(id);
ALTER TABLE roombooking.blocking_principals ADD CONSTRAINT fk_blocking_principals_user_id_users FOREIGN KEY (user_id) REFERENCES users.users(id);
EOF
dbdiff
pause 'dbdiff empty?'
indico-zodbimport "$PG" "$ZODB" api
indico-zodbimport "$PG" "$ZODB" users --ldap-provider-name cern-ldap
indico-zodbimport "$PG" "$ZODB" groups
pause 'v1.9.3?'
checkout v1.9.3
indico db upgrade
dbdiff
pause 'dbdiff empty?'
indico-zodbimport "$PG" "$ZODB" evaluation_alarms
indico-zodbimport "$PG" "$ZODB" event_alarms
indico-zodbimport "$PG" "$ZODB" static_sites
pause 'v1.9.4?'
pip uninstall -y flask-sqlalchemy
pip install 'flask-sqlalchemy==2.0'
checkout v1.9.4
indico db upgrade 1041cc03dbe6
indico-zodbimport "$PG" "$ZODB" legacy_events
indico-zodbimport "$PG" "$ZODB" legacy_categories
indico db upgrade
psql indico_lcagenda << EOF
ALTER TABLE events.settings ADD CONSTRAINT ck_settings_lowercase_module CHECK (((module)::text = lower((module)::text)));
ALTER TABLE events.settings ADD CONSTRAINT ck_settings_lowercase_name CHECK (((name)::text = lower((name)::text)));
ALTER TABLE events.settings_principals ADD CONSTRAINT ck_settings_principals_lowercase_module CHECK (((module)::text = lower((module)::text)));
ALTER TABLE events.settings_principals ADD CONSTRAINT ck_settings_principals_lowercase_name CHECK (((name)::text = lower((name)::text)));
ALTER TABLE indico.settings_principals ADD CONSTRAINT ck_settings_principals_lowercase_module CHECK (((module)::text = lower((module)::text)));
ALTER TABLE indico.settings_principals ADD CONSTRAINT ck_settings_principals_lowercase_name CHECK (((name)::text = lower((name)::text)));
EOF
dbdiff
pause 'dbdiff empty?'
indico-zodbimport "$PG" "$ZODB" event_logs -q
indico-zodbimport "$PG" "$ZODB" event_notes --archive-dir "$ARCHIVE_DIR" --janitor-user-id "$JANITOR_ID" -q
indico-zodbimport "$PG" "$ZODB" attachments --archive-dir "$ARCHIVE_DIR" --janitor-user-id "$JANITOR_ID" --storage-backend afs-legacy --symlink-backend afs-legacy-symlinks --symlink-target "$SYMLINK_DIR" -q
pause 'v1.9.5?'
checkout v1.9.5
indico db upgrade
dbdiff
pause 'dbdiff empty?'
indico-zodbimport "$PG" "$ZODB" event_stubs
indico-zodbimport "$PG" "$ZODB" event_images --archive-dir "$ARCHIVE_DIR" --storage-backend afs-legacy --symlink-backend afs-legacy-symlinks --symlink-target "$SYMLINK_DIR" -q
indico-zodbimport "$PG" "$ZODB" event_menus -q
indico-zodbimport "$PG" "$ZODB" event_layout --archive-dir "$ARCHIVE_DIR" -q
indico-zodbimport "$PG" "$ZODB" event_surveys -q
pause 'v1.9.6?'
checkout_ns e3e59f8
cherry 92453d7
cherry 9c3c91b
cherry e9d91a0
cherry 32bebd9
cherry c374492
setup
indico db upgrade eb582b7b0e1
indico-zodbimport "$PG" "$ZODB" event_managers --default-group-provider cern-ldap --janitor-user-id "$JANITOR_ID" -q
indico db upgrade 38641fb3afac
indico-zodbimport "$PG" "$ZODB" event_regforms --archive-dir "$ARCHIVE_DIR" --storage-backend afs-legacy --symlink-backend afs-legacy-symlinks --symlink-target "$SYMLINK_DIR" -q
indico-zodbimport "$PG" "$ZODB" event_participants -q
checkout v1.9.6
psql indico_lcagenda << EOF
INSERT INTO indico.settings (module, name, value) VALUES ('payment', 'currency', to_json('USD'::text));
EOF
indico db upgrade
dbdiff
pause 'dbdiff empty?'
pause 'v1.9.7?'
checkout master
indico db upgrade da0ddef1744
indico-zodbimport "$PG" "$ZODB" event_dates_titles -q
indico-zodbimport "$PG" "$ZODB" event_locations -q
indico-zodbimport "$PG" "$ZODB" event_categories -q
indico db upgrade 338772789e1f
indico-zodbimport "$PG" "$ZODB" event_timetable --default-group-provider cern-ldap -q
indico db upgrade
indico-zodbimport "$PG" "$ZODB" event_abstracts_zodb -q
indico-zodbimport "$PG" "$ZODB" event_paper_reviewing -q --archive-dir "$ARCHIVE_DIR" --storage-backend afs-legacy --symlink-backend afs-legacy-symlinks --symlink-target "$SYMLINK_DIR" -q
dbdiff
pause 'dbdiff empty?'
pip uninstall flask-sqlalchemy
pip install 'flask-sqlalchemy==2.1'
echo '*** ALL DONE ***'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.