Add unique id for the accepted table.
Add a little more logs.
This commit is contained in:
@@ -47,6 +47,8 @@ import io.kamax.mxisd.storage.ormlite.dao.ThreePidInviteIO;
|
|||||||
import io.kamax.mxisd.storage.ormlite.dao.ThreePidSessionDao;
|
import io.kamax.mxisd.storage.ormlite.dao.ThreePidSessionDao;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -61,6 +63,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class OrmLiteSqlStorage implements IStorage {
|
public class OrmLiteSqlStorage implements IStorage {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(OrmLiteSqlStorage.class);
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
private interface Getter<T> {
|
private interface Getter<T> {
|
||||||
|
|
||||||
@@ -124,11 +128,13 @@ public class OrmLiteSqlStorage implements IStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fixAcceptedDao(ConnectionSource connPool) throws SQLException {
|
private void fixAcceptedDao(ConnectionSource connPool) throws SQLException {
|
||||||
|
LOGGER.info("Migration: {}", Migrations.FIX_ACCEPTED_DAO);
|
||||||
TableUtils.dropTable(acceptedDao, true);
|
TableUtils.dropTable(acceptedDao, true);
|
||||||
TableUtils.createTableIfNotExists(connPool, AcceptedDao.class);
|
TableUtils.createTableIfNotExists(connPool, AcceptedDao.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <V, K> Dao<V, K> createDaoAndTable(ConnectionSource connPool, Class<V> c) throws SQLException {
|
private <V, K> Dao<V, K> createDaoAndTable(ConnectionSource connPool, Class<V> c) throws SQLException {
|
||||||
|
LOGGER.info("Create the dao: {}", c.getSimpleName());
|
||||||
Dao<V, K> dao = DaoManager.createDao(connPool, c);
|
Dao<V, K> dao = DaoManager.createDao(connPool, c);
|
||||||
TableUtils.createTableIfNotExists(connPool, c);
|
TableUtils.createTableIfNotExists(connPool, c);
|
||||||
return dao;
|
return dao;
|
||||||
|
@@ -26,6 +26,9 @@ import com.j256.ormlite.table.DatabaseTable;
|
|||||||
@DatabaseTable(tableName = "accepted")
|
@DatabaseTable(tableName = "accepted")
|
||||||
public class AcceptedDao {
|
public class AcceptedDao {
|
||||||
|
|
||||||
|
@DatabaseField(generatedId = true)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
@DatabaseField(canBeNull = false)
|
@DatabaseField(canBeNull = false)
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@@ -45,6 +48,14 @@ public class AcceptedDao {
|
|||||||
this.acceptedAt = acceptedAt;
|
this.acceptedAt = acceptedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user