From 45b6199fed61c1414e1ce8d6cfeb4f8730893ed9 Mon Sep 17 00:00:00 2001 From: Michael Totschnig Date: Tue, 26 Sep 2023 15:13:10 +0200 Subject: [PATCH] fixes #1019 --- .../myexpenses/activity/BaseMyExpenses.kt | 5 +- .../myexpenses/db2/RepositoryAccount.kt | 10 --- .../provider/BaseTransactionDatabase.kt | 66 +++++++++++++++++-- .../provider/TransactionDatabase.java | 52 ++++++--------- 4 files changed, 82 insertions(+), 51 deletions(-) diff --git a/myExpenses/src/main/java/org/totschnig/myexpenses/activity/BaseMyExpenses.kt b/myExpenses/src/main/java/org/totschnig/myexpenses/activity/BaseMyExpenses.kt index 8f79ef6825..e26ccecfc7 100644 --- a/myExpenses/src/main/java/org/totschnig/myexpenses/activity/BaseMyExpenses.kt +++ b/myExpenses/src/main/java/org/totschnig/myexpenses/activity/BaseMyExpenses.kt @@ -771,16 +771,15 @@ abstract class BaseMyExpenses : LaunchActivity(), OcrHost, OnDialogResultListene if (account.sealed) finishActionMode() } - val showStatusHandle = if (account.type == AccountType.CASH) + val showStatusHandle = if (account.isAggregate || account.type == AccountType.CASH) false else viewModel.showStatusHandle().collectAsState(initial = true).value val onToggleCrStatus: ((Long) -> Unit)? = if (showStatusHandle) { { - checkSealed(listOf(it)) { + if (!account.sealed) viewModel.toggleCrStatus(it) - } } } else null diff --git a/myExpenses/src/main/java/org/totschnig/myexpenses/db2/RepositoryAccount.kt b/myExpenses/src/main/java/org/totschnig/myexpenses/db2/RepositoryAccount.kt index 9806d16060..3f67b0842d 100644 --- a/myExpenses/src/main/java/org/totschnig/myexpenses/db2/RepositoryAccount.kt +++ b/myExpenses/src/main/java/org/totschnig/myexpenses/db2/RepositoryAccount.kt @@ -211,11 +211,6 @@ fun Repository.markAsExported(accountId: Long, filter: WhereFilter?) { val ops = buildList { val accountUri = TransactionProvider.ACCOUNTS_URI val debtUri = TransactionProvider.DEBTS_URI - add( - ContentProviderOperation.newUpdate(accountUri) - .withValue(KEY_SEALED, -1) - .withSelection("$KEY_SEALED = 1", null).build() - ) add( ContentProviderOperation.newUpdate(debtUri).withValue(KEY_SEALED, -1) .withSelection("$KEY_SEALED = 1", null).build() @@ -234,11 +229,6 @@ fun Repository.markAsExported(accountId: Long, filter: WhereFilter?) { .withSelection(selection, selectionArgs) .build() ) - add( - ContentProviderOperation.newUpdate(accountUri) - .withValue(KEY_SEALED, 1) - .withSelection("$KEY_SEALED = -1", null).build() - ) add( ContentProviderOperation.newUpdate(debtUri).withValue(KEY_SEALED, 1) .withSelection("$KEY_SEALED = -1", null).build() diff --git a/myExpenses/src/main/java/org/totschnig/myexpenses/provider/BaseTransactionDatabase.kt b/myExpenses/src/main/java/org/totschnig/myexpenses/provider/BaseTransactionDatabase.kt index 875cc1e168..72bad82105 100644 --- a/myExpenses/src/main/java/org/totschnig/myexpenses/provider/BaseTransactionDatabase.kt +++ b/myExpenses/src/main/java/org/totschnig/myexpenses/provider/BaseTransactionDatabase.kt @@ -22,18 +22,27 @@ import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_BIC import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_BLZ import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_CATID import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_COLOR +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_COMMENT import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_CONTEXT +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_CRITERION +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_CR_STATUS import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_CURRENCY import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_DATE import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_DEBT_ID import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_DESCRIPTION +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_EQUIVALENT_AMOUNT import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_IBAN import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_LABEL import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_LAST_USED +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_METHODID +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_OPENING_BALANCE +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_ORIGINAL_AMOUNT +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_ORIGINAL_CURRENCY import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_PARENTID import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_PAYEEID import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_PAYEE_NAME import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_PAYEE_NAME_NORMALIZED +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_REFERENCE_NUMBER import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_ROWID import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_SEALED import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_SHORT_NAME @@ -41,11 +50,13 @@ import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_STATUS import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_TRANSACTIONID import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_TRANSFER_ACCOUNT import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_TRANSFER_PEER +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_TYPE import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_URI import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_USAGES import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_USER_ID import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_UUID import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_VALUE +import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_VALUE_DATE import org.totschnig.myexpenses.provider.DatabaseConstants.TABLE_ACCOUNTS import org.totschnig.myexpenses.provider.DatabaseConstants.TABLE_ACCOUNT_ATTRIBUTES import org.totschnig.myexpenses.provider.DatabaseConstants.TABLE_ATTACHMENTS @@ -64,8 +75,9 @@ import org.totschnig.myexpenses.provider.DatabaseConstants.VIEW_EXTENDED import org.totschnig.myexpenses.provider.DatabaseConstants.VIEW_UNCOMMITTED import org.totschnig.myexpenses.provider.DatabaseConstants.VIEW_WITH_ACCOUNT import timber.log.Timber +import java.util.Locale -const val DATABASE_VERSION = 148 +const val DATABASE_VERSION = 149 private const val RAISE_UPDATE_SEALED_DEBT = "SELECT RAISE (FAIL, 'attempt to update sealed debt');" private const val RAISE_INCONSISTENT_CATEGORY_HIERARCHY = @@ -155,6 +167,7 @@ CREATE TABLE $TABLE_PAYEES ( $KEY_PARENTID integer references $TABLE_PAYEES($KEY_ROWID) ON DELETE CASCADE, unique($KEY_PAYEE_NAME, $KEY_IBAN)); """ + //the unique index on ($KEY_PAYEE_NAME, $KEY_IBAN) does not prevent duplicate names when iban is null const val PAYEE_UNIQUE_INDEX = """ CREATE UNIQUE INDEX payee_name ON $TABLE_PAYEES($KEY_PAYEE_NAME) WHERE $KEY_IBAN IS NULL; @@ -209,7 +222,8 @@ private const val INCREASE_CATEGORY_USAGE_ACTION = private val INCREASE_CATEGORY_USAGE_INSERT_TRIGGER = "CREATE TRIGGER insert_increase_category_usage AFTER INSERT ON $TABLE_TRANSACTIONS WHEN new.$KEY_CATID IS NOT NULL AND new.$KEY_CATID != ${DatabaseConstants.SPLIT_CATID}$INCREASE_CATEGORY_USAGE_ACTION" -private const val INCREASE_CATEGORY_USAGE_UPDATE_TRIGGER = "CREATE TRIGGER update_increase_category_usage AFTER UPDATE ON $TABLE_TRANSACTIONS WHEN new.$KEY_CATID IS NOT NULL AND (old.$KEY_CATID IS NULL OR new.$KEY_CATID != old.$KEY_CATID)$INCREASE_CATEGORY_USAGE_ACTION" +private const val INCREASE_CATEGORY_USAGE_UPDATE_TRIGGER = + "CREATE TRIGGER update_increase_category_usage AFTER UPDATE ON $TABLE_TRANSACTIONS WHEN new.$KEY_CATID IS NOT NULL AND (old.$KEY_CATID IS NULL OR new.$KEY_CATID != old.$KEY_CATID)$INCREASE_CATEGORY_USAGE_ACTION" private const val INCREASE_ACCOUNT_USAGE_ACTION = " BEGIN UPDATE $TABLE_ACCOUNTS SET $KEY_USAGES = $KEY_USAGES + 1, $KEY_LAST_USED = strftime('%s', 'now') WHERE $KEY_ROWID = new.$KEY_ACCOUNTID; END;" @@ -229,6 +243,44 @@ const val TRANSACTIONS_CAT_ID_INDEX = const val TRANSACTIONS_PAYEE_ID_INDEX = "CREATE INDEX transactions_payee_id_index on $TABLE_TRANSACTIONS($KEY_PAYEEID)" +private const val RAISE_UPDATE_SEALED_ACCOUNT = + "SELECT RAISE (FAIL, 'attempt to update sealed account');" + +const val ACCOUNTS_SEALED_TRIGGER_CREATE = + """CREATE TRIGGER sealed_account_update + BEFORE UPDATE OF $KEY_LABEL,$KEY_OPENING_BALANCE,$KEY_DESCRIPTION,$KEY_CURRENCY,$KEY_TYPE,$KEY_UUID,$KEY_CRITERION ON $TABLE_ACCOUNTS + WHEN old.$KEY_SEALED = 1 + BEGIN $RAISE_UPDATE_SEALED_ACCOUNT END""" + +const val TRANSACTIONS_SEALED_INSERT_TRIGGER_CREATE = + """CREATE TRIGGER sealed_account_transaction_insert + BEFORE INSERT ON $TABLE_TRANSACTIONS + WHEN (SELECT $KEY_SEALED FROM $TABLE_ACCOUNTS WHERE $KEY_ROWID = new.$KEY_ACCOUNTID) = 1 + BEGIN $RAISE_UPDATE_SEALED_ACCOUNT END""" + +//we allow update of status +const val TRANSACTIONS_SEALED_UPDATE_TRIGGER_CREATE = + """CREATE TRIGGER sealed_account_transaction_update + BEFORE UPDATE OF $KEY_COMMENT, $KEY_DATE, $KEY_VALUE_DATE, $KEY_AMOUNT, $KEY_CATID, $KEY_ACCOUNTID, $KEY_PAYEEID, $KEY_TRANSFER_PEER, $KEY_TRANSFER_ACCOUNT, $KEY_METHODID, $KEY_PARENTID, $KEY_REFERENCE_NUMBER, $KEY_UUID, $KEY_ORIGINAL_AMOUNT, $KEY_ORIGINAL_CURRENCY, $KEY_EQUIVALENT_AMOUNT, $KEY_DEBT_ID, $KEY_CR_STATUS + ON $TABLE_TRANSACTIONS + WHEN (SELECT max($KEY_SEALED) FROM $TABLE_ACCOUNTS WHERE $KEY_ROWID IN (new.$KEY_ACCOUNTID,old.$KEY_ACCOUNTID)) = 1 + BEGIN $RAISE_UPDATE_SEALED_ACCOUNT END""" + +//we allow update of cr_status and status +const val TRANSFER_SEALED_UPDATE_TRIGGER_CREATE = + """CREATE TRIGGER sealed_account_tranfer_update + BEFORE UPDATE OF $KEY_COMMENT, $KEY_DATE, $KEY_VALUE_DATE, $KEY_AMOUNT, $KEY_CATID, $KEY_ACCOUNTID, $KEY_PAYEEID, $KEY_TRANSFER_PEER, $KEY_TRANSFER_ACCOUNT, $KEY_METHODID, $KEY_PARENTID, $KEY_REFERENCE_NUMBER, $KEY_UUID, $KEY_ORIGINAL_AMOUNT, $KEY_ORIGINAL_CURRENCY, $KEY_EQUIVALENT_AMOUNT, $KEY_DEBT_ID + ON $TABLE_TRANSACTIONS + WHEN (SELECT $KEY_SEALED FROM $TABLE_ACCOUNTS WHERE $KEY_ROWID = old.$KEY_TRANSFER_ACCOUNT) = 1 + BEGIN $RAISE_UPDATE_SEALED_ACCOUNT END""" + + +const val TRANSACTIONS_SEALED_DELETE_TRIGGER_CREATE = + """CREATE TRIGGER sealed_account_transaction_delete + BEFORE DELETE ON $TABLE_TRANSACTIONS + WHEN (SELECT $KEY_SEALED FROM $TABLE_ACCOUNTS WHERE $KEY_ROWID = old.$KEY_ACCOUNTID) = 1 + BEGIN $RAISE_UPDATE_SEALED_ACCOUNT END""" + abstract class BaseTransactionDatabase(val prefHandler: PrefHandler) : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) { @@ -473,7 +525,7 @@ abstract class BaseTransactionDatabase(val prefHandler: PrefHandler) : execSQL( "CREATE TABLE account_attributes (account_id integer references accounts(_id) ON DELETE CASCADE,attribute_id integer references attributes(_id) ON DELETE CASCADE,value text not null,primary key (account_id, attribute_id))" ) - } + } fun SupportSQLiteDatabase.upgradeTo148() { execSQL("CREATE TABLE attachments (_id integer primary key autoincrement, uri text not null unique, uuid text not null unique)") @@ -481,7 +533,11 @@ abstract class BaseTransactionDatabase(val prefHandler: PrefHandler) : execSQL("DROP TRIGGER IF EXISTS cache_stale_uri") //insert existing attachments from transaction table into attachments table //drop column picture_id - query("transactions", arrayOf("_id", "picture_id"), "picture_id is not null").use { cursor -> + query( + "transactions", + arrayOf("_id", "picture_id"), + "picture_id is not null" + ).use { cursor -> val attachmentValues = ContentValues(2) val joinValues = ContentValues(2) cursor.asSequence.forEach { @@ -505,7 +561,7 @@ abstract class BaseTransactionDatabase(val prefHandler: PrefHandler) : } } execSQL("DROP table stale_uris") - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE ) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { execSQL("ALTER TABLE transactions RENAME to transactions_old") execSQL( "CREATE TABLE transactions(" + diff --git a/myExpenses/src/main/java/org/totschnig/myexpenses/provider/TransactionDatabase.java b/myExpenses/src/main/java/org/totschnig/myexpenses/provider/TransactionDatabase.java index d8e98b2429..e949a36538 100644 --- a/myExpenses/src/main/java/org/totschnig/myexpenses/provider/TransactionDatabase.java +++ b/myExpenses/src/main/java/org/totschnig/myexpenses/provider/TransactionDatabase.java @@ -20,6 +20,7 @@ import static org.totschnig.myexpenses.model2.PaymentMethodKt.PAYMENT_METHOD_EXPENSE; import static org.totschnig.myexpenses.model2.PaymentMethodKt.PAYMENT_METHOD_INCOME; import static org.totschnig.myexpenses.model2.PaymentMethodKt.PAYMENT_METHOD_NEUTRAL; +import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.ACCOUNTS_SEALED_TRIGGER_CREATE; import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.ACCOUNT_ATTRIBUTES_CREATE; import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.ACCOUNT_REMAP_TRANSFER_TRIGGER_CREATE; import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.ATTACHMENTS_CREATE; @@ -31,8 +32,12 @@ import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.TRANSACTIONS_ATTACHMENTS_CREATE; import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.TRANSACTIONS_CAT_ID_INDEX; import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.TRANSACTIONS_PAYEE_ID_INDEX; +import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.TRANSACTIONS_SEALED_DELETE_TRIGGER_CREATE; +import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.TRANSACTIONS_SEALED_INSERT_TRIGGER_CREATE; +import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.TRANSACTIONS_SEALED_UPDATE_TRIGGER_CREATE; import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.TRANSACTIONS_UUID_INDEX_CREATE; import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.TRANSACTION_ATTRIBUTES_CREATE; +import static org.totschnig.myexpenses.provider.BaseTransactionDatabaseKt.TRANSFER_SEALED_UPDATE_TRIGGER_CREATE; import static org.totschnig.myexpenses.provider.DataBaseAccount.HOME_AGGREGATE_ID; import static org.totschnig.myexpenses.provider.DatabaseConstants.*; import static org.totschnig.myexpenses.provider.DbConstantsKt.TAG_LIST_EXPRESSION; @@ -345,32 +350,6 @@ private String buildViewDefinitionExtended(String tableName) { " = (SELECT coalesce(max(" + KEY_SORT_KEY + "),0) FROM " + TABLE_ACCOUNTS + ") + 1 WHERE " + KEY_ROWID + " = NEW." + KEY_ROWID + "; END"; - private static final String RAISE_UPDATE_SEALED_ACCOUNT = - "SELECT RAISE (FAIL, 'attempt to update sealed account');"; - - private static final String ACCOUNTS_SEALED_TRIGGER_CREATE = - String.format(Locale.ROOT, "CREATE TRIGGER sealed_account_update BEFORE UPDATE OF %1$s,%2$s,%3$s,%4$s,%5$s,%6$s,%7$s ON %8$s WHEN old.%9$s = 1 ", - KEY_LABEL, KEY_OPENING_BALANCE, KEY_DESCRIPTION, KEY_CURRENCY, KEY_TYPE, KEY_UUID, KEY_CRITERION, TABLE_ACCOUNTS, KEY_SEALED) + - String.format(Locale.ROOT, "BEGIN %s END", RAISE_UPDATE_SEALED_ACCOUNT); - - private static final String TRANSACTIONS_SEALED_INSERT_TRIGGER_CREATE = - "CREATE TRIGGER sealed_account_transaction_insert " + - "BEFORE INSERT ON " + TABLE_TRANSACTIONS + " " + - "WHEN (SELECT " + KEY_SEALED + " FROM " + TABLE_ACCOUNTS + " WHERE " + KEY_ROWID + " = new." + KEY_ACCOUNTID + ") = 1 " + - String.format(Locale.ROOT, "BEGIN %s END", RAISE_UPDATE_SEALED_ACCOUNT); - - private static final String TRANSACTIONS_SEALED_UPDATE_TRIGGER_CREATE = - "CREATE TRIGGER sealed_account_transaction_update " + - "BEFORE UPDATE ON " + TABLE_TRANSACTIONS + " " + - "WHEN (SELECT max(" + KEY_SEALED + ") FROM " + TABLE_ACCOUNTS + " WHERE " + KEY_ROWID + " IN (new." + KEY_ACCOUNTID + ",old." + KEY_ACCOUNTID + ",new." + KEY_TRANSFER_ACCOUNT + ",old." + KEY_TRANSFER_ACCOUNT +")) = 1 " + - String.format(Locale.ROOT, "BEGIN %s END", RAISE_UPDATE_SEALED_ACCOUNT); - - private static final String TRANSACTIONS_SEALED_DELETE_TRIGGER_CREATE = - "CREATE TRIGGER sealed_account_transaction_delete " + - "BEFORE DELETE ON " + TABLE_TRANSACTIONS + " " + - "WHEN (SELECT " + KEY_SEALED + " FROM " + TABLE_ACCOUNTS + " WHERE " + KEY_ROWID + " = old." + KEY_ACCOUNTID + ") = 1 " + - String.format(Locale.ROOT, "BEGIN %s END", RAISE_UPDATE_SEALED_ACCOUNT); - private static final String CHANGES_CREATE = "CREATE TABLE " + TABLE_CHANGES + " ( " + KEY_ACCOUNTID + " integer not null references " + TABLE_ACCOUNTS + "(" + KEY_ROWID + ") ON DELETE CASCADE," @@ -1891,13 +1870,15 @@ public void onUpgrade(@NonNull SupportSQLiteDatabase db, int oldVersion, int new db.execSQL("ALTER TABLE accounts add column hidden boolean default 0"); db.execSQL("ALTER TABLE accounts add column sealed boolean default 0"); createOrRefreshAccountSealedTrigger(db); - createOrRefreshTransactionSealedTriggers(db); + //createOrRefreshTransactionSealedTriggers(db); } +/* if (oldVersion < 86) { db.execSQL("DROP TRIGGER IF EXISTS sealed_account_transaction_update"); db.execSQL(TRANSACTIONS_SEALED_UPDATE_TRIGGER_CREATE); } +*/ //if (oldVersion < 87) { //createOrRefreshTemplateViews(db); @@ -1990,10 +1971,10 @@ public void onUpgrade(@NonNull SupportSQLiteDatabase db, int oldVersion, int new db.execSQL("DROP VIEW IF EXISTS " + VIEW_EXTENDED); db.execSQL("CREATE VIEW " + VIEW_EXTENDED + buildViewDefinitionExtended(TABLE_TRANSACTIONS) + " WHERE " + KEY_STATUS + " != " + STATUS_UNCOMMITTED + ";"); }*/ - if (oldVersion < 96) { +/* if (oldVersion < 96) { db.execSQL("DROP TRIGGER IF EXISTS sealed_account_transaction_update"); db.execSQL(TRANSACTIONS_SEALED_UPDATE_TRIGGER_CREATE); - } + }*/ if (oldVersion < 97) { //This index has been lost after a table rename db.execSQL("CREATE INDEX IF NOT EXISTS templates_cat_id_index on templates(cat_id)"); @@ -2048,8 +2029,8 @@ public void onUpgrade(@NonNull SupportSQLiteDatabase db, int oldVersion, int new createOrRefreshTransferTagsTriggers(db); } if (oldVersion < 104) { - db.execSQL("DROP TRIGGER IF EXISTS sealed_account_transaction_update"); - db.execSQL(TRANSACTIONS_SEALED_UPDATE_TRIGGER_CREATE); +/* db.execSQL("DROP TRIGGER IF EXISTS sealed_account_transaction_update"); + db.execSQL(TRANSACTIONS_SEALED_UPDATE_TRIGGER_CREATE);*/ //repair uuids that got lost by bug repairTransferUuids(db); } @@ -2141,10 +2122,10 @@ public void onUpgrade(@NonNull SupportSQLiteDatabase db, int oldVersion, int new if (oldVersion < 122) { upgradeTo122(db); } - if (oldVersion < 123) { +/* if (oldVersion < 123) { db.execSQL("DROP TRIGGER IF EXISTS sealed_account_transaction_update"); db.execSQL(TRANSACTIONS_SEALED_UPDATE_TRIGGER_CREATE); - } + }*/ if (oldVersion < 124) { upgradeTo124(db); } @@ -2229,6 +2210,9 @@ public void onUpgrade(@NonNull SupportSQLiteDatabase db, int oldVersion, int new createOrRefreshViews(db); createOrRefreshTransactionTriggers(db); } + if (oldVersion < 149) { + createOrRefreshTransactionSealedTriggers(db); + } TransactionProvider.resumeChangeTrigger(db); } catch (SQLException e) { @@ -2289,9 +2273,11 @@ private void createOrRefreshTransactionTriggers(SupportSQLiteDatabase db) { private void createOrRefreshTransactionSealedTriggers(SupportSQLiteDatabase db) { db.execSQL("DROP TRIGGER IF EXISTS sealed_account_transaction_insert"); db.execSQL("DROP TRIGGER IF EXISTS sealed_account_transaction_update"); + db.execSQL("DROP TRIGGER IF EXISTS sealed_account_tranfer_update"); db.execSQL("DROP TRIGGER IF EXISTS sealed_account_transaction_delete"); db.execSQL(TRANSACTIONS_SEALED_INSERT_TRIGGER_CREATE); db.execSQL(TRANSACTIONS_SEALED_UPDATE_TRIGGER_CREATE); + db.execSQL(TRANSFER_SEALED_UPDATE_TRIGGER_CREATE); db.execSQL(TRANSACTIONS_SEALED_DELETE_TRIGGER_CREATE); }