2
-- not very sophisticated :-(
4
update account_account set level = 0;
6
update account_account a set level = level +1 where parent_id is null and level= 0;
8
update account_account a set level = 2 where parent_id in (select id from account_account b where b.level = 1);
10
update account_account a set level = 3 where parent_id in (select id from account_account b where b.level = 2);
12
update account_account a set level = 4 where parent_id in (select id from account_account b where b.level = 3);
14
update account_account a set level = 5 where parent_id in (select id from account_account b where b.level = 4);
16
update account_account a set level = 6 where parent_id in (select id from account_account b where b.level = 5);
18
update account_account a set level = 7 where parent_id in (select id from account_account b where b.level = 6);
20
update account_account a set level = 8 where parent_id in (select id from account_account b where b.level = 7);
22
update account_account a set level = 9 where parent_id in (select id from account_account b where b.level = 8);
24
update account_account a set level = 10 where parent_id in (select id from account_account b where b.level = 9);
26
update account_account a set level = 11 where parent_id in (select id from account_account b where b.level = 10);
28
update account_account a set level = 12 where parent_id in (select id from account_account b where b.level = 11);
30
update account_account a set level = 13 where parent_id in (select id from account_account b where b.level = 12);