Skip to content

Database manipulations

Glandos edited this page Apr 30, 2022 · 1 revision

Warning, these manipulations are not supported and dangerous. Please backup your data!

Split project (SQLite)

If you have a project with two payers having payer_id 9 and 10, and you want to split bills in another project. First, create the new project in the Web interface and create the 2 new payers. Look for their payer_id, since they will be different for this new project. Let's say for this example that they have payer_id 23 and 24 (so old one + 14).

First, update payer_id in bill table.

update bill set payer_id = payer_id + 14 where payer_id in ('9', '10') and date < '2021-09-01';

Then update owers in billowers table

update billowers
set person_id=person_id+14
from (select id from bill where payer_id in ('23', '24')) as bills
where billowers.bill_id=bills.id;

This last query only works in SQLite.