]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/res/raw/db_59.sql
more fall-outs after transition to surrogate IDs
[mobile-ledger.git] / app / src / main / res / raw / db_59.sql
index 115f3ce9b4f5bb9a48feb2138b2e5964aa109b8e..5ba11afffaf9281705dc969abc16fed7e96fe8de 100644 (file)
@@ -94,6 +94,16 @@ select o.name, p.id, o.value
 from options o
 join profiles p on p.deprecated_uuid = o.profile;
 
+insert into options_new(name, profile_id, value)
+select o.name, 0, o.value
+from options o
+where o.profile='-';
+
+update options_new
+set name='profile_id'
+  , value=(select p.id from profiles p where p.deprecated_uuid=value)
+where name='profile_uuid';
+
 drop table options;
 alter table options_new rename to options;
 
@@ -155,8 +165,8 @@ insert into transaction_accounts_new(transaction_id, order_no, account_name,
     currency, amount, comment, generation)
 select t.id, ta.order_no, ta.account_name, ta.currency, ta.amount, ta.comment, ta.generation
 from transaction_accounts ta
-join profiles p in ta.profile=p.deprecated_uuid
-join transactions t on ta.transaction_id = t.ledger_id and t.profile_id=p.id;
+join profiles p on ta.profile=p.deprecated_uuid
+join transactions_new t on ta.transaction_id = t.ledger_id and t.profile_id=p.id;
 
 drop table transaction_accounts;
 alter table transaction_accounts_new rename to transaction_accounts;