diff --git a/src/main/java/ai/elimu/dao/DeviceDao.java b/src/main/java/ai/elimu/dao/DeviceDao.java index 482c2543c..a5934039b 100644 --- a/src/main/java/ai/elimu/dao/DeviceDao.java +++ b/src/main/java/ai/elimu/dao/DeviceDao.java @@ -6,5 +6,5 @@ public interface DeviceDao extends GenericDao { - Device read(String deviceId) throws DataAccessException; + Device read(String androidId) throws DataAccessException; } diff --git a/src/main/java/ai/elimu/dao/jpa/DeviceDaoJpa.java b/src/main/java/ai/elimu/dao/jpa/DeviceDaoJpa.java index 7a22d872e..24974ec5d 100644 --- a/src/main/java/ai/elimu/dao/jpa/DeviceDaoJpa.java +++ b/src/main/java/ai/elimu/dao/jpa/DeviceDaoJpa.java @@ -10,13 +10,13 @@ public class DeviceDaoJpa extends GenericDaoJpa implements DeviceDao { @Override - public Device read(String deviceId) throws DataAccessException { + public Device read(String androidId) throws DataAccessException { try { return (Device) em.createQuery( "SELECT d " + "FROM Device d " + - "WHERE d.deviceId = :deviceId") - .setParameter("deviceId", deviceId) + "WHERE d.androidId = :androidId") + .setParameter("androidId", androidId) .getSingleResult(); } catch (NoResultException e) { return null; diff --git a/src/main/java/ai/elimu/model/Device.java b/src/main/java/ai/elimu/model/Device.java index 90a526fe4..30450cb38 100644 --- a/src/main/java/ai/elimu/model/Device.java +++ b/src/main/java/ai/elimu/model/Device.java @@ -12,7 +12,7 @@ public class Device extends BaseEntity { @NotNull @Column(unique=true) - private String deviceId; + private String androidId; @NotNull private String deviceManufacturer; @@ -33,12 +33,12 @@ public class Device extends BaseEntity { @NotNull private Integer osVersion; - public String getDeviceId() { - return deviceId; + public String getAndroidId() { + return androidId; } - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; + public void setAndroidId(String androidId) { + this.androidId = androidId; } public String getDeviceManufacturer() { diff --git a/src/main/resources/META-INF/jpa-schema-export.sql b/src/main/resources/META-INF/jpa-schema-export.sql index eea1e2c73..a2572f367 100644 --- a/src/main/resources/META-INF/jpa-schema-export.sql +++ b/src/main/resources/META-INF/jpa-schema-export.sql @@ -255,7 +255,7 @@ create table Device ( id bigint not null auto_increment, - deviceId varchar(255), + androidId varchar(255), deviceManufacturer varchar(255), deviceModel varchar(255), deviceSerial varchar(255), @@ -695,7 +695,7 @@ add constraint UK_gdl53lyf9qvi56fmbrk9nfrg9 unique (version); alter table Device - add constraint UK_ktkbd0xm3q2nddw1xxtdaxjy7 unique (deviceId); + add constraint UK_c2646199whiqrkjbht7hwyr3v unique (androidId); alter table Application add constraint FKn1pft600om9qs7dn754chjk67 diff --git a/src/main/resources/db/migration/2004020.sql b/src/main/resources/db/migration/2004020.sql new file mode 100644 index 000000000..3d3f89463 --- /dev/null +++ b/src/main/resources/db/migration/2004020.sql @@ -0,0 +1,3 @@ +# 2.4.20 +ALTER TABLE `Device` DROP COLUMN `deviceId`; +ALTER TABLE `Device` CHANGE `deviceId` `androidId` VARCHAR(255); \ No newline at end of file diff --git a/src/test/java/ai/elimu/dao/DeviceDaoTest.java b/src/test/java/ai/elimu/dao/DeviceDaoTest.java index 8cf59eecf..20d11969d 100644 --- a/src/test/java/ai/elimu/dao/DeviceDaoTest.java +++ b/src/test/java/ai/elimu/dao/DeviceDaoTest.java @@ -22,14 +22,14 @@ public void testRead() { deviceDao.create(getDevice("22")); deviceDao.create(getDevice("44")); - assertEquals("22", deviceDao.read("22").getDeviceId()); - assertEquals("44", deviceDao.read("44").getDeviceId()); + assertEquals("22", deviceDao.read("22").getAndroidId()); + assertEquals("44", deviceDao.read("44").getAndroidId()); assertNull(deviceDao.read("33")); } - private Device getDevice(String deviceId) { + private Device getDevice(String androidId) { Device device = new Device(); - device.setDeviceId(deviceId); + device.setAndroidId(androidId); return device; } }