Commit 60051bac by Lee Jaebin

データベースのバージョンの初期化ver1.0.0、データベースマイグレーション処理の削除

parent 8c90a4cc
...@@ -19,7 +19,7 @@ import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase; ...@@ -19,7 +19,7 @@ import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
public class DBConnector { public class DBConnector {
private static volatile DBConnector dbConnector = null; private static volatile DBConnector dbConnector = null;
public static final String DatabaseName = "ABVJE"; public static final String DatabaseName = "ABVJE";
public static final int DatabaseVersion = DatabaseVersions.Plus_1_9_4_1; public static final int DatabaseVersion = DatabaseVersions.Ver1_0_0;
protected SQLiteDatabase db = null; protected SQLiteDatabase db = null;
......
...@@ -3,31 +3,5 @@ package jp.agentec.abook.abv.bl.data; ...@@ -3,31 +3,5 @@ package jp.agentec.abook.abv.bl.data;
// バージョンが上がるごとに+10すること // バージョンが上がるごとに+10すること
public class DatabaseVersions { public class DatabaseVersions {
public static final int Ver1_0_0 = 1; public static final int Ver1_0_0 = 1;
public static final int Ver1_5_0 = 2;
public static final int Ver1_5_1 = 3;
public static final int Ver1_5_2 = 4; // 2012/10/19 スマートカタログ対応
public static final int Ver1_5_2_01 = 5; // 2012/10/22 グループ全体件数追加
public static final int Ver1_5_2_02 = 6; // 2012/10/22 サーバ検索結果を保持
public static final int Ver1_5_2_03 = 7; // 2013/04/09 폴더 락 해제시, 기존 선택 폴더 유지
public static final int Ver1_5_4 = 8; // 2013/04/16 앙케이트 테이블 추가
public static final int Plus_1_1_0 = 9; // 2013/11/19 ABook+1.1
public static final int Plus_1_2_0 = 10; // 2014/01/27 ABook+1.2
public static final int Plus_1_3_0 = 11; // 2014/01/27 ABook+1.3
public static final int Plus_1_4_0_OLD = 12; // 2014/04/1 ABook+1.4旧
public static final int Plus_1_4_0 = 20; // 2014/05/21 ABook+1.4
public static final int Plus_1_4_3 = 30; // 2014/05/21 ABook+1.4.3
public static final int Plus_1_5_0 = 40; // 2014/07/25 ABook+1.5
public static final int Plus_1_5_2 = 50; // 2014/07/25 ABook+1.5.2
public static final int Plus_1_6_0 = 60; // 2014/12/01 ABook+1.6.0
public static final int Plus_1_6_3 = 70; // 2015/6/12 ABook+1.6.3
public static final int Plus_1_6_4 = 80; //2015/9/28 ABook+1.6.4
public static final int Plus_1_6_4_5 = 90; //2015/11/25 ABook+1.6.4.5
public static final int Plus_1_7_6_5 = 100; //2016/08/12 SmartLink1.7.6.5
public static final int Plus_1_8_1 = 110; //2017/3/31 ABook+1.8.1
public static final int Plus_1_8_5_7 = 120; //2018/1/10 SmartLink1.8.5.7
public static final int Plus_1_9_3 = 130; //2018/08/13 ABook+1.9.3
public static final int Plus_1_9_3_5 = 131; //2018/11/26 ABook+1.9.350
public static final int Plus_1_9_4 = 132; //2018/12/10 ABook+1.9.4
public static final int Plus_1_9_4_1 = 133; //2019/01/29 ABook+1.9.4.1
} }
...@@ -21,11 +21,7 @@ public class LContentCustomLog extends SQLiteTableScript { ...@@ -21,11 +21,7 @@ public class LContentCustomLog extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_6_4_5) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -17,7 +17,6 @@ public class LContentObjectLog extends SQLiteTableScript { ...@@ -17,7 +17,6 @@ public class LContentObjectLog extends SQLiteTableScript {
List<String> ddl = new ArrayList<String>(); List<String> ddl = new ArrayList<String>();
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
// since plus 1.0.0
sql.append(" CREATE TABLE l_content_object_log ( "); sql.append(" CREATE TABLE l_content_object_log ( ");
sql.append(" object_log_id INTEGER NOT NULL "); sql.append(" object_log_id INTEGER NOT NULL ");
sql.append(" , reading_log_id INTEGER NOT NULL "); sql.append(" , reading_log_id INTEGER NOT NULL ");
...@@ -47,16 +46,7 @@ public class LContentObjectLog extends SQLiteTableScript { ...@@ -47,16 +46,7 @@ public class LContentObjectLog extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_1_0) {
ddl.addAll(getCreateScript(newVersion));
}
if (oldVersion >= DatabaseVersions.Plus_1_1_0 && oldVersion < DatabaseVersions.Plus_1_4_0 && oldVersion != DatabaseVersions.Plus_1_4_0_OLD) {
ddl.add(" ALTER TABLE l_content_object_log ADD COLUMN event_type TEXT ");
}
return ddl;
} }
@Override @Override
......
...@@ -39,11 +39,7 @@ public class LContentPageReadingLog extends SQLiteTableScript { ...@@ -39,11 +39,7 @@ public class LContentPageReadingLog extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_1_0) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -39,16 +39,7 @@ public class LContentReadingLog extends SQLiteTableScript { ...@@ -39,16 +39,7 @@ public class LContentReadingLog extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_1_0) {
// 位置情報追加
ddl.add(" ALTER TABLE l_content_reading_log ADD COLUMN latitude REAL ");
ddl.add(" ALTER TABLE l_content_reading_log ADD COLUMN longitude REAL ");
}
if (oldVersion < DatabaseVersions.Plus_1_6_0) {
ddl.add(" ALTER TABLE l_content_reading_log ADD COLUMN mode INTEGER default 0 ");
}
return ddl;
} }
@Override @Override
......
...@@ -44,21 +44,7 @@ public class MAcms extends SQLiteTableScript { ...@@ -44,21 +44,7 @@ public class MAcms extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
Logger.d("DATA", "upgrade oldVersion : %s , newVersion : %s", oldVersion, newVersion);
if (oldVersion < DatabaseVersions.Ver1_5_0) {
ddl = getCreateScript(newVersion);
}
if (oldVersion < DatabaseVersions.Ver1_5_2) { // 既存アプリから汎用版へのマイグレーションはあり得ないので考慮しない
}
if (oldVersion < DatabaseVersions.Plus_1_7_6_5) { // カラムの追加
ddl.add(" ALTER TABLE m_acms ADD COLUMN schedulelist_last_fetch_date VARCHAR(256)");
ddl.add(" ALTER TABLE m_acms ADD COLUMN contentversion_last_fetch_date VARCHAR(256)");
}
return ddl;
} }
} }
...@@ -22,12 +22,7 @@ public class MAppConfig extends SQLiteTableScript { ...@@ -22,12 +22,7 @@ public class MAppConfig extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_1_0) { // 1.0まで入ってしまっているので削除
ddl.add(" DROP TABLE if exists m_app_config");
}
return ddl;
} }
@Override @Override
......
...@@ -65,19 +65,7 @@ public class MCategory extends SQLiteTableScript { ...@@ -65,19 +65,7 @@ public class MCategory extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Ver1_5_0) {
ddl.add(" DROP TABLE r_content_category ");
ddl.add(" DROP TABLE m_category ");
ddl.addAll(getCreateScript(newVersion));
}
if (oldVersion < DatabaseVersions.Plus_1_1_0) {
ddl.add(" DROP INDEX if exists udx_category_1 ");
ddl.add(" CREATE INDEX idx_category_order_name ON m_category (disp_order, category_name) ");
}
return ddl;
} }
@Override @Override
......
...@@ -66,28 +66,7 @@ public class MGroup extends SQLiteTableScript { ...@@ -66,28 +66,7 @@ public class MGroup extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Ver1_5_0) {
ddl.add(" ALTER TABLE m_group ADD COLUMN group_path TEXT NOT NULL DEFAULT '' ");
ddl.add(" UPDATE m_group SET group_path = group_id "); // とりあえず仮の値を設定しておく。ログインする際、この値が初期化されるため。
ddl.add(" CREATE UNIQUE INDEX udx_group_2 ON m_group ( group_path ) ");
}
if (oldVersion < DatabaseVersions.Ver1_5_2) {
ddl.add(" DROP INDEX IF EXISTS udx_group_1 ");
ddl.add(" ALTER TABLE m_group ADD COLUMN group_level INT ");
// 事実上、V1.5.0未満のバージョンからのアップグレードはサポートしない。(group_pathをもとにgroup_levelを計算しているため)
ddl.add(" UPDATE m_group SET group_level = LENGTH(group_path) - LENGTH(REPLACE(group_path, '/', '')) ");
ddl.add(" CREATE UNIQUE INDEX udx_group_1 ON m_group (group_id, parent_group_id, group_level) ");
}
if ((oldVersion < DatabaseVersions.Plus_1_1_0)) {
ddl.add(" ALTER TABLE m_group ADD COLUMN user_group_flg BOOLEAN NOT NULL DEFAULT 0 ");
ddl.add(" DROP INDEX IF EXISTS udx_group_1 ");
}
return ddl;
} }
@Override @Override
......
...@@ -44,17 +44,7 @@ public class MMemberInfo extends SQLiteTableScript { ...@@ -44,17 +44,7 @@ public class MMemberInfo extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_8_1) {
ddl.add(" ALTER TABLE m_member_info ADD COLUMN user_id INTEGER ");
ddl.add(" ALTER TABLE m_member_info ADD COLUMN last_update_infor VARCHAR(64)");
}
if (oldVersion < DatabaseVersions.Plus_1_9_3) {
ddl.add(" ALTER TABLE m_member_info ADD COLUMN project_auth_level INTEGER ");
ddl.add(" ALTER TABLE m_member_info ADD COLUMN worker_code TEXT ");
}
return ddl;
} }
@Override @Override
......
...@@ -32,13 +32,7 @@ public class MPasswordLockInfo extends SQLiteTableScript { ...@@ -32,13 +32,7 @@ public class MPasswordLockInfo extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = null; return null;
if (oldVersion < DatabaseVersions.Ver1_5_0) {
ddl = getCreateScript(newVersion);
}
return ddl;
} }
@Override @Override
......
...@@ -33,11 +33,7 @@ public class MWorkerGroup extends SQLiteTableScript { ...@@ -33,11 +33,7 @@ public class MWorkerGroup extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_9_3) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -33,12 +33,7 @@ public class RContentCategory extends SQLiteTableScript { ...@@ -33,12 +33,7 @@ public class RContentCategory extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Ver1_5_0) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -97,11 +97,6 @@ public class TContent extends SQLiteTableScript { ...@@ -97,11 +97,6 @@ public class TContent extends SQLiteTableScript {
ddl.add(sql.toString()); ddl.add(sql.toString());
StringUtil.clear(sql); StringUtil.clear(sql);
// sql.append(" CREATE INDEX idx_content_2 ON t_content ( "); // 不要
// sql.append(" content_detail ");
// sql.append(" ) ");
// ddl.add(sql.toString());
addIndex(ddl); addIndex(ddl);
return ddl; return ddl;
...@@ -117,170 +112,11 @@ public class TContent extends SQLiteTableScript { ...@@ -117,170 +112,11 @@ public class TContent extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_1_0) {
ddl.add(" ALTER TABLE t_content ADD COLUMN hide_flg BOOLEAN ");
}
if (oldVersion < DatabaseVersions.Plus_1_2_0) {
ddl.add(" ALTER TABLE t_content ADD COLUMN share_url TEXT ");
}
if (oldVersion < DatabaseVersions.Plus_1_3_0) {
ddl.add(" ALTER TABLE t_content ADD COLUMN reader_share_flg BOOLEAN ");
}
if (oldVersion < DatabaseVersions.Plus_1_4_0 && oldVersion != DatabaseVersions.Plus_1_4_0_OLD) {
ddl.add(" ALTER TABLE t_content ADD COLUMN disable_auto_dl BOOLEAN default 0 ");
}
if (oldVersion < DatabaseVersions.Plus_1_5_0) {
ddl.add(" ALTER TABLE t_content ADD COLUMN pay_flg BOOLEAN default 0 ");
ddl.add(" ALTER TABLE t_content ADD COLUMN purchase_state INTEGER default -1 ");
ddl.add(" ALTER TABLE t_content ADD COLUMN purchase_token TEXT ");
ddl.add(" ALTER TABLE t_content ADD COLUMN product_id TEXT ");
ddl.add(" ALTER TABLE t_content ADD COLUMN price TEXT ");
}
if (oldVersion < DatabaseVersions.Plus_1_5_2) {
ddl.add(" ALTER TABLE t_content ADD COLUMN delivery_type INTEGER default 0 ");
}
if (oldVersion < DatabaseVersions.Plus_1_6_0) {
ddl.add(" ALTER TABLE t_content ADD COLUMN signage INTEGER default 0 ");
ddl.add(" ALTER TABLE t_content ADD COLUMN disable_swipe BOOLEAN default 0 ");
}
if (oldVersion < DatabaseVersions.Plus_1_6_3) {
ddl.add(" ALTER TABLE t_content ADD COLUMN download_start_date DATETIME ");
ddl.add(" ALTER TABLE t_content ADD COLUMN download_progress INTEGER ");
ddl.add(" ALTER TABLE t_content ADD COLUMN downloaded_bytes BIGINT ");
ddl.add(" ALTER TABLE t_content ADD COLUMN download_end_date DATETIME ");
ddl.add(" ALTER TABLE t_content ADD COLUMN log_sended_flg BOOLEAN default 0 ");
ddl.add(" ALTER TABLE t_content ADD COLUMN status VARCHAR(2) ");
ddl.add(" ALTER TABLE t_content ADD COLUMN signage_disable_dl BOOLEAN default 0 ");
ddl.add(" CREATE INDEX idx_content_log_sended_flg ON t_content (log_sended_flg) ");
}
if (oldVersion < DatabaseVersions.Plus_1_8_1) {
ddl.add("ALTER TABLE t_content ADD COLUMN unauthorized_content_flg BOOLEAN default 0");
}
if (oldVersion < DatabaseVersions.Plus_1_1_0) {
ddl.add(" DROP INDEX if exists idx_content_2");
addIndex(ddl);
}
// if (oldVersion < DatabaseVersions.Ver1_5_0) {
// ddl.add(" ALTER TABLE t_content ADD COLUMN detail_page_num INTEGER ");
// ddl.add(" ALTER TABLE t_content ADD COLUMN content_groups TEXT ");
// ddl.add(" ALTER TABLE t_content ADD COLUMN new_flg BOOLEAN DEFAULT true ");
// }
//
// if (oldVersion < DatabaseVersions.Ver1_5_2_01) {
// ddl.add(" ALTER TABLE t_content ADD COLUMN orientation INTEGER ");
// ddl.add(" UPDATE t_content set orientation = -1 ");
// }
if (oldVersion < DatabaseVersions.Plus_1_9_3) {
ddl.add("ALTER TABLE t_content ADD COLUMN project_content_flg BOOLEAN default 0");
}
if (oldVersion < DatabaseVersions.Plus_1_9_4) {
ddl.add("ALTER TABLE t_content ADD COLUMN common_content_flg BOOLEAN default 0");
}
return ddl;
} }
@Override @Override
public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object[] params) { public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object[] params) {
List<String> ddl = new ArrayList<String>(); return null;
// if (oldVersion < DatabaseVersions.Ver1_5_0) {
// ddl.add(" UPDATE t_content SET detail_page_num = (CASE WHEN all_page_num > 6 THEN 6 ELSE all_page_num END) ");
// ddl.add(" UPDATE t_content SET new_flg = updated_flg ");
// }
//
// if (oldVersion < DatabaseVersions.Ver1_5_2_01) {
// SQLiteDatabase db = (SQLiteDatabase)databaseConnection;
// StringBuffer sql = new StringBuffer();
//
// sql.append(" SELECT LIKE('%\"vertical\":%', tcr.hashed_file_header) AS orientation ");
// sql.append(" , tc.content_id ");
// sql.append(" FROM t_content AS tc ");
// sql.append(" INNER JOIN t_content_resource AS tcr ");
// sql.append(" ON tc.content_id = tcr.content_id ");
// sql.append(" WHERE tc.downloaded_flg = 1 ");
// sql.append(" AND tcr.resource_file_name = tc.content_id || '.json' ");
//
// Cursor cursor = db.rawQuery(sql.toString(), null);
//
// if (cursor.moveToFirst()) {
// String updateSql = " UPDATE t_content SET orientation = ? WHERE content_id = ? ";
// Object[] args = new Object[2];
//
// do {
// args[0] = cursor.getInt(0);
// args[1] = cursor.getLong(1);
//
// db.execSQL(updateSql, args);
// } while (cursor.moveToNext());
// }
// }
if (oldVersion < DatabaseVersions.Plus_1_3_0) {
List<ContentDto> contentDtoList = rawQueryGetDtoList(databaseConnection, "select * from t_content ", null);
String sql = "update t_content set share_url=?, reader_share_flg=? where content_id=?";
for (ContentDto contentDto : contentDtoList) {
try {
DownloadedContentInfoJSON json = ContentFileUtil.getDownloadedContentInfoJSON(contentDto.contentId);
databaseConnection.execSQL(sql, new Object[] { json.shareUrl, json.readerContentFlg ? 1 : 0, contentDto.contentId });
} catch (Exception e) {
Logger.e("TContent", e);
}
}
}
if (oldVersion < DatabaseVersions.Plus_1_6_3) {
String sql = "update t_content set log_sended_flg=1, signage_disable_dl=1"; // log_sended_flgは一律送信済み、signage_disable_dlはDLしないことにする(t_content_download_queueからのマイグレーションはしない)
databaseConnection.execSQL(sql, new String[]{});
}
return ddl;
}
protected List<ContentDto> rawQueryGetDtoList(SQLiteDatabase db, String sql, String[] bindArgs) {
ContentDao contentDao = AbstractDao.getDao(ContentDao.class);
Cursor cursor = null;
try {
List<ContentDto> list = new ArrayList<ContentDto>();
if (Logger.isVerboseEnabled()) {
Logger.v("TContent", "%s [%s]", sql, join(bindArgs));
}
cursor = db.rawQuery(sql, bindArgs);
while (cursor.moveToNext()) {
list.add(contentDao.convert(cursor));
}
return list;
} finally {
if (cursor != null) {
cursor.close();
}
}
}
protected String join(Object[] bindArgs) {
if (bindArgs == null) {
return "";
}
StringBuffer sb = new StringBuffer();
for (Object object : bindArgs) {
sb.append(object);
sb.append(",");
}
return sb.toString();
} }
} }
...@@ -55,30 +55,11 @@ public class TContentDownloadQueue extends SQLiteTableScript { ...@@ -55,30 +55,11 @@ public class TContentDownloadQueue extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Ver1_5_0) {
ddl.add(" ALTER TABLE t_content_download_queue ADD COLUMN display_status VARCHAR(2) DEFAULT '' ");
ddl.add(" ALTER TABLE t_content_download_queue ADD COLUMN message_code TEXT ");
}
if (oldVersion < DatabaseVersions.Plus_1_1_0) {
ddl.add(" CREATE INDEX idx_content_download_queue_queued_date ON t_content_download_queue (queued_date) ");
ddl.add(" CREATE INDEX idx_content_download_queue_end_date ON t_content_download_queue (end_date) ");
}
return ddl;
} }
@Override @Override
public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object... params) { public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object... params) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Ver1_5_0) {
ddl.add(" UPDATE t_content_download_queue SET display_status = status ");
} }
return ddl;
}
} }
...@@ -36,13 +36,7 @@ public class TContentMarking extends SQLiteTableScript { ...@@ -36,13 +36,7 @@ public class TContentMarking extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_1_0) {
ddl.add(" CREATE INDEX idx_content_marking_page_num ON t_content_marking (page_num) ");
}
return ddl;
} }
@Override @Override
......
...@@ -39,19 +39,7 @@ public class TContentMemo extends SQLiteTableScript { ...@@ -39,19 +39,7 @@ public class TContentMemo extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Ver1_5_2_01) {
ddl.add(" ALTER TABLE t_content_memo ADD COLUMN copy_flg BOOLEAN DEFAULT 0 ");
ddl.add(" ALTER TABLE t_content_memo ADD COLUMN del_flg BOOLEAN DEFAULT 0 ");
ddl.add(" UPDATE t_content_memo SET copy_flg = 0, del_flg = 0 ");
}
if (oldVersion < DatabaseVersions.Plus_1_2_0) {
ddl.add(" CREATE UNIQUE INDEX udx_memo_1 ON t_content_memo (memo_id) ");
}
return ddl;
} }
@Override @Override
......
...@@ -35,13 +35,7 @@ public class TContentOldPdf extends SQLiteTableScript { ...@@ -35,13 +35,7 @@ public class TContentOldPdf extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = null; return null;
if (oldVersion < DatabaseVersions.Ver1_5_2_01) {
ddl = getCreateScript(newVersion);
}
return ddl;
} }
} }
...@@ -45,13 +45,7 @@ public class TContentPage extends SQLiteTableScript { ...@@ -45,13 +45,7 @@ public class TContentPage extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_1_0) {
ddl.add(" DROP INDEX if exists idx_content_page_1");
ddl.add(" CREATE INDEX idx_content_page_num ON t_content_page (page_num) ");
}
return ddl;
} }
@Override @Override
......
...@@ -34,13 +34,7 @@ public class TEnquete extends SQLiteTableScript { ...@@ -34,13 +34,7 @@ public class TEnquete extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = null; return null;
if (oldVersion < DatabaseVersions.Ver1_5_4) {
ddl = getCreateScript(newVersion);
}
return ddl;
} }
@Override @Override
......
...@@ -69,65 +69,11 @@ public class TFolder extends SQLiteTableScript { ...@@ -69,65 +69,11 @@ public class TFolder extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Ver1_5_2_01) {
ddl.add(" ALTER TABLE t_folder ADD COLUMN folder_path TEXT NOT NULL DEFAULT '' ");
ddl.add(" UPDATE t_folder SET folder_path = folder_id ");
// since DatabaseVersions.Ver1_5_2_01
ddl.add(" CREATE UNIQUE INDEX udx_folder_1 ON t_folder (folder_id, parent_folder_id)");
ddl.add(" CREATE UNIQUE INDEX udx_folder_2 ON t_folder (folder_path)");
}
if (oldVersion < DatabaseVersions.Plus_1_1_0) {
ddl.add(" DROP INDEX if exists udx_folder_1");
}
return ddl;
} }
@Override @Override
public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object... params) { public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object... params) {
if (oldVersion < DatabaseVersions.Ver1_5_2_01) {
SQLiteDatabase db = databaseConnection;
String strRootFolderId = StringUtil.toString(RootFolderId);
db.execSQL(" UPDATE t_folder SET parent_folder_id = -1, disp_order = 0 WHERE folder_id = ? ", new String[] {strRootFolderId});
db.execSQL(" UPDATE t_folder SET folder_path = folder_id ");
db.execSQL(" UPDATE t_folder SET folder_path = ? || '/' || folder_path WHERE parent_folder_id = ? ", new String[] {strRootFolderId, strRootFolderId});
String selectSql = " SELECT folder_path, folder_id FROM t_folder WHERE parent_folder_id = ? ";
String updateSql = " UPDATE t_folder SET folder_path = ? || '/' || folder_path WHERE parent_folder_id = ? ";
updateFolderPath(db, selectSql, updateSql, strRootFolderId);
}
return null; return null;
} }
private void updateFolderPath(SQLiteDatabase db, String selectSql, String updateSql, String parentFolderId) {
Cursor cursor = db.rawQuery(selectSql, new String[]{parentFolderId});
try {
if (cursor.moveToFirst()) {
String[] updateArgs = new String[2];
do {
updateArgs[0] = cursor.getString(0); // folder_path
updateArgs[1] = cursor.getString(1); // folder_id
db.execSQL(updateSql, updateArgs);
updateFolderPath(db, selectSql, updateSql, cursor.getString(1));
} while (cursor.moveToNext());
}
}
finally {
if (cursor != null) {
cursor.close();
}
}
}
} }
...@@ -41,11 +41,7 @@ public class TInspectTaskReport extends SQLiteTableScript { ...@@ -41,11 +41,7 @@ public class TInspectTaskReport extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_9_4_1) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -71,13 +71,7 @@ public class TMarkingSetting extends SQLiteTableScript { ...@@ -71,13 +71,7 @@ public class TMarkingSetting extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = null; return null;
if (oldVersion < DatabaseVersions.Ver1_5_0) {
ddl = getCreateScript(newVersion);
}
return ddl;
} }
@Override @Override
......
...@@ -46,22 +46,22 @@ public class TProject extends SQLiteTableScript { ...@@ -46,22 +46,22 @@ public class TProject extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); // List<String> ddl = new ArrayList<String>();
if (oldVersion < DatabaseVersions.Plus_1_9_3) { // if (oldVersion < DatabaseVersions.Plus_1_9_3) {
ddl.addAll(getCreateScript(newVersion)); // ddl.addAll(getCreateScript(newVersion));
} // }
//
if (oldVersion < DatabaseVersions.Plus_1_9_3_5) { // カラムの追加 // if (oldVersion < DatabaseVersions.Plus_1_9_3_5) { // カラムの追加
ddl.add(" ALTER TABLE t_project ADD COLUMN report_update_type INTEGER NOT NULL DEFAULT 0 "); // ddl.add(" ALTER TABLE t_project ADD COLUMN report_update_type INTEGER NOT NULL DEFAULT 0 ");
} // }
//
if (oldVersion < DatabaseVersions.Plus_1_9_4) { // カラムの追加 // if (oldVersion < DatabaseVersions.Plus_1_9_4) { // カラムの追加
ddl.add(" ALTER TABLE t_project ADD COLUMN project_report_type INTEGER NOT NULL DEFAULT 0 "); // ddl.add(" ALTER TABLE t_project ADD COLUMN project_report_type INTEGER NOT NULL DEFAULT 0 ");
ddl.add(" ALTER TABLE t_project ADD COLUMN report_cycle INTEGER NOT NULL DEFAULT 0 "); // ddl.add(" ALTER TABLE t_project ADD COLUMN report_cycle INTEGER NOT NULL DEFAULT 0 ");
ddl.add(" ALTER TABLE t_project ADD COLUMN enable_report_update INTEGER NOT NULL DEFAULT 0 "); // ddl.add(" ALTER TABLE t_project ADD COLUMN enable_report_update INTEGER NOT NULL DEFAULT 0 ");
} // }
// return ddl;
return ddl; return null;
} }
@Override @Override
......
...@@ -36,11 +36,7 @@ public class TPushMessage extends SQLiteTableScript { ...@@ -36,11 +36,7 @@ public class TPushMessage extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_9_3) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -53,13 +53,7 @@ public class TSubscriptionHistory extends SQLiteTableScript { ...@@ -53,13 +53,7 @@ public class TSubscriptionHistory extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = null; return null;
if (oldVersion < DatabaseVersions.Plus_1_5_0) {
ddl = getCreateScript(newVersion);
}
return ddl;
} }
} }
...@@ -39,12 +39,7 @@ public class TTask extends SQLiteTableScript { ...@@ -39,12 +39,7 @@ public class TTask extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_9_3) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -37,12 +37,7 @@ public class TTaskDirections extends SQLiteTableScript { ...@@ -37,12 +37,7 @@ public class TTaskDirections extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_9_3) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -34,12 +34,7 @@ public class TTaskDirectionsItems extends SQLiteTableScript { ...@@ -34,12 +34,7 @@ public class TTaskDirectionsItems extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_9_3) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -37,12 +37,7 @@ public class TTaskReport extends SQLiteTableScript { ...@@ -37,12 +37,7 @@ public class TTaskReport extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_9_3) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -34,12 +34,7 @@ public class TTaskReportItems extends SQLiteTableScript { ...@@ -34,12 +34,7 @@ public class TTaskReportItems extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_9_3) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
......
...@@ -44,87 +44,11 @@ public class TTaskReportSend extends SQLiteTableScript { ...@@ -44,87 +44,11 @@ public class TTaskReportSend extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_9_3_5) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
} }
@Override @Override
public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object[] params) { public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object[] params) {
List<String> ddl = new ArrayList<String>(); return null;
if (oldVersion < DatabaseVersions.Plus_1_9_3_5) {
Cursor csrTaskReport = databaseConnection.rawQuery("select tt.project_id, ttr.task_key, ttr.json_data from t_task_report ttr inner join t_task tt ON tt.task_key == ttr.task_key WHERE ttr.data_send_flg = 1", null);
Cursor csrNextTaskReportSendId;
String qryNextTaskReportSendId = "select cast(ifnull(max(task_report_send_id),0) + 1 as integer) task_report_send_id from t_task_report_send";
String qryInsertTaskReportSend = "insert into t_task_report_send (task_report_send_id, task_key, json_data, save_date, delete_flg) values (?,?,?,datetime(),0)";
long projectId;
int taskReportSendId;
String taskKey;
String jsonData;
try {
if (csrTaskReport.moveToFirst()) {
do {
projectId = csrTaskReport.getLong(0);
taskKey = csrTaskReport.getString(1);
jsonData = csrTaskReport.getString(2);
csrNextTaskReportSendId = databaseConnection.rawQuery(qryNextTaskReportSendId, null);
try {
if (csrNextTaskReportSendId.moveToFirst()) {
do {
try {
taskReportSendId = csrNextTaskReportSendId.getInt(0);
databaseConnection.execSQL(qryInsertTaskReportSend, new String[]{StringUtil.toString(taskReportSendId), taskKey, jsonData});
String taskAttachedPath = ABVEnvironment.getInstance().getProjectDirectionOrReportDirPath(projectId, taskKey, false);
File taskAttachedFiles = new File(taskAttachedPath);
if (taskAttachedFiles.exists()) {
String taskReportSendPath = ABVEnvironment.getInstance().getProjectTaskReportSendDirFilePath(projectId, taskKey, taskReportSendId);
FileUtil.delete(taskReportSendPath);
FileUtil.createNewDirectory(taskReportSendPath);
//noinspection ConstantConditions
for (String taskAttachedFile : taskAttachedFiles.list()) {
FileUtil.copy(taskAttachedPath + "/" + taskAttachedFile, taskReportSendPath + "/" + taskAttachedFile, true);
}
}
} catch (IOException ex) {
Logger.e(String.format("TTaskReportSend, failed migration of t_task_report_send, projectId=%d, taskKey=%s, IOException.", projectId, taskKey), ex);
} catch (NullPointerException ex) {
Logger.e(String.format("TTaskReportSend, failed migration of t_task_report_send, projectId=%d, taskKey=%s, NullPointerException.", projectId, taskKey), ex);
} catch (Exception ex) {
Logger.e(String.format("TTaskReportSend, failed migration of t_task_report_send, projectId=%d, taskKey=%s, Exception.", projectId, taskKey), ex);
}
} while (csrNextTaskReportSendId.moveToNext());
}
} finally {
if (csrNextTaskReportSendId != null) {
csrNextTaskReportSendId.close();
}
}
} while (csrTaskReport.moveToNext());
}
} finally {
if (csrTaskReport != null) {
csrTaskReport.close();
}
}
}
if (oldVersion < DatabaseVersions.Plus_1_9_4) { // カラムの追加
ddl.add(" ALTER TABLE t_task_report_send ADD COLUMN task_report_id INTEGER DEFAULT 0 ");
ddl.add(" ALTER TABLE t_task_report_send ADD COLUMN report_start_date DATETIME ");
}
return ddl;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment