Skip to content

Commit

Permalink
Fix Tigase upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Ricci <[email protected]>
  • Loading branch information
daniele-athome committed Jan 7, 2015
1 parent 3dbf5f6 commit 5c6ea8e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/src/main/java/org/kontalk/provider/MessagesProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import java.util.List;

import org.kontalk.BuildConfig;
import org.kontalk.Kontalk;
import org.kontalk.client.EndpointServer;
import org.kontalk.client.ServerList;
import org.kontalk.crypto.Coder;
import org.kontalk.message.CompositeMessage;
import org.kontalk.provider.MyMessages.CommonColumns;
import org.kontalk.provider.MyMessages.Messages;
import org.kontalk.provider.MyMessages.Threads;
Expand Down Expand Up @@ -901,18 +901,22 @@ public synchronized int delete(Uri uri, String selection, String[] selectionArgs
// special case: Tigase upgrade
boolean tigase = Boolean.parseBoolean(uri.getQueryParameter("tigase"));
if (tigase) {
final String SCHEMA_UPGRADE_PRE = "DROP trigger update_thread_on_update";
final String[] SCHEMA_UPGRADE = {
"UPDATE " + TABLE_THREADS + " SET peer = REPLACE(peer, '@kontalk.net', ?)",
"UPDATE " + TABLE_MESSAGES + " SET peer = REPLACE(peer, '@kontalk.net', ?)",
"UPDATE " + TABLE_THREADS + " SET peer = SUBSTR(peer, 1, ?) || ?",
"UPDATE " + TABLE_MESSAGES + " SET peer = SUBSTR(peer, 1, ?) || ?",
};
final String SCHEMA_UPGRADE_POST = DatabaseHelper.TRIGGER_THREADS_UPDATE_COUNT;
// temporary change from network domain to server domain
// this is actually only for beta testers coming from beta3
ServerList list = ServerListUpdater.getCurrentList(getContext());
EndpointServer server = list.get(0);
String host = server.getNetwork();

db.execSQL(SCHEMA_UPGRADE_PRE);
for (String sql : SCHEMA_UPGRADE)
db.execSQL(sql, new Object[] { "@" + host });
db.execSQL(sql, new Object[]{CompositeMessage.USERID_LENGTH, "@" + host});
db.execSQL(SCHEMA_UPGRADE_POST);

return 0;
}
Expand Down

0 comments on commit 5c6ea8e

Please sign in to comment.