mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Log migration times.
This commit is contained in:
@@ -447,10 +447,12 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Migrating from schema " + start + " to " + end);
|
LOG.info("Migrating from schema " + start + " to " + end);
|
||||||
if (listener != null) listener.onDatabaseMigration();
|
if (listener != null) listener.onDatabaseMigration();
|
||||||
|
long startTime = now();
|
||||||
// Apply the migration
|
// Apply the migration
|
||||||
m.migrate(txn);
|
m.migrate(txn);
|
||||||
// Store the new schema version
|
// Store the new schema version
|
||||||
storeSchemaVersion(txn, end);
|
storeSchemaVersion(txn, end);
|
||||||
|
logDuration(LOG, "Migration", startTime);
|
||||||
dataSchemaVersion = end;
|
dataSchemaVersion = end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,12 +46,9 @@ class Migration47_48 implements Migration<Connection> {
|
|||||||
s = txn.createStatement();
|
s = txn.createStatement();
|
||||||
s.execute("ALTER TABLE messages"
|
s.execute("ALTER TABLE messages"
|
||||||
+ " ADD COLUMN deleted BOOLEAN DEFAULT FALSE NOT NULL");
|
+ " ADD COLUMN deleted BOOLEAN DEFAULT FALSE NOT NULL");
|
||||||
LOG.info("Created column messages.deleted");
|
|
||||||
s.execute("UPDATE messages SET deleted = TRUE WHERE raw IS NULL");
|
s.execute("UPDATE messages SET deleted = TRUE WHERE raw IS NULL");
|
||||||
LOG.info("Populated column messages.deleted");
|
|
||||||
s.execute("ALTER TABLE messages"
|
s.execute("ALTER TABLE messages"
|
||||||
+ " ADD COLUMN blockCount INT DEFAULT 1 NOT NULL");
|
+ " ADD COLUMN blockCount INT DEFAULT 1 NOT NULL");
|
||||||
LOG.info("Created column messages.blockCount");
|
|
||||||
s.execute(dbTypes.replaceTypes("CREATE TABLE blocks"
|
s.execute(dbTypes.replaceTypes("CREATE TABLE blocks"
|
||||||
+ " (messageId _HASH NOT NULL,"
|
+ " (messageId _HASH NOT NULL,"
|
||||||
+ " blockNumber INT NOT NULL,"
|
+ " blockNumber INT NOT NULL,"
|
||||||
@@ -61,7 +58,6 @@ class Migration47_48 implements Migration<Connection> {
|
|||||||
+ " FOREIGN KEY (messageId)"
|
+ " FOREIGN KEY (messageId)"
|
||||||
+ " REFERENCES messages (messageId)"
|
+ " REFERENCES messages (messageId)"
|
||||||
+ " ON DELETE CASCADE)"));
|
+ " ON DELETE CASCADE)"));
|
||||||
LOG.info("Created table blocks");
|
|
||||||
rs = s.executeQuery("SELECT messageId, length, raw FROM messages");
|
rs = s.executeQuery("SELECT messageId, length, raw FROM messages");
|
||||||
ps = txn.prepareStatement("INSERT INTO blocks"
|
ps = txn.prepareStatement("INSERT INTO blocks"
|
||||||
+ " (messageId, blockNumber, blockLength, data)"
|
+ " (messageId, blockNumber, blockLength, data)"
|
||||||
@@ -85,11 +81,10 @@ class Migration47_48 implements Migration<Connection> {
|
|||||||
}
|
}
|
||||||
ps.close();
|
ps.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
|
s.execute("ALTER TABLE messages DROP COLUMN raw");
|
||||||
|
s.close();
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Migrated " + migrated + " messages");
|
LOG.info("Migrated " + migrated + " messages");
|
||||||
s.execute("ALTER TABLE messages DROP COLUMN raw");
|
|
||||||
LOG.info("Dropped column messages.raw");
|
|
||||||
s.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
tryToClose(ps, LOG, WARNING);
|
tryToClose(ps, LOG, WARNING);
|
||||||
tryToClose(rs, LOG, WARNING);
|
tryToClose(rs, LOG, WARNING);
|
||||||
|
|||||||
Reference in New Issue
Block a user