Made accounts and their transaction accessible to account members only.

This commit is contained in:
2026-10-11 13:21:45 +02:00
parent 21f0c17af9
commit ce5046579b
34 changed files with 459 additions and 294 deletions
@@ -0,0 +1,231 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO recurring_transactions (\n id,\n name,\n account_id,\n amount_cents,\n direction,\n starts_at,\n ends_at,\n recurrence_every,\n recurrence_unit,\n weekend_adjustment\n )\n SELECT $2, $3, $4, $5, $6, $7, $8, $9, $10, $11\n FROM accessible_accounts($1) AS accounts\n WHERE accounts.id = $4\n ON CONFLICT (id) DO UPDATE SET\n name = EXCLUDED.name,\n account_id = EXCLUDED.account_id,\n amount_cents = EXCLUDED.amount_cents,\n direction = EXCLUDED.direction,\n starts_at = EXCLUDED.starts_at,\n ends_at = EXCLUDED.ends_at,\n recurrence_every = EXCLUDED.recurrence_every,\n recurrence_unit = EXCLUDED.recurrence_unit,\n weekend_adjustment = EXCLUDED.weekend_adjustment\n WHERE recurring_transactions.account_id IN (SELECT id FROM accessible_accounts($1))\n RETURNING WITH (OLD AS old_row, NEW AS new_row)\n old_row.id AS \"old_id?\",\n COALESCE(old_row.name, new_row.name) AS \"old_name!\",\n COALESCE(old_row.account_id, new_row.account_id) AS \"old_account_id!\",\n COALESCE(old_row.amount_cents, new_row.amount_cents) AS \"old_amount_cents!\",\n COALESCE(old_row.direction, new_row.direction) AS \"old_direction!\",\n COALESCE(old_row.starts_at, new_row.starts_at) AS \"old_starts_at!\",\n old_row.ends_at AS \"old_ends_at?\",\n COALESCE(old_row.recurrence_every, new_row.recurrence_every) AS \"old_recurrence_every!\",\n COALESCE(old_row.recurrence_unit, new_row.recurrence_unit) AS \"old_recurrence_unit!\",\n old_row.weekend_adjustment AS \"old_weekend_adjustment?\",\n new_row.id AS \"id!\",\n new_row.name AS \"name!\",\n new_row.account_id AS \"account_id!\",\n new_row.amount_cents AS \"amount_cents!\",\n new_row.direction AS \"direction!\",\n new_row.starts_at AS \"starts_at!\",\n new_row.ends_at AS \"ends_at?\",\n new_row.recurrence_every AS \"recurrence_every!\",\n new_row.recurrence_unit AS \"recurrence_unit!\",\n new_row.weekend_adjustment AS \"weekend_adjustment?\"\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "old_id?",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "old_name!",
"type_info": "Text",
"origin": "Expression"
},
{
"ordinal": 2,
"name": "old_account_id!",
"type_info": "Uuid",
"origin": "Expression"
},
{
"ordinal": 3,
"name": "old_amount_cents!",
"type_info": "Int8",
"origin": "Expression"
},
{
"ordinal": 4,
"name": "old_direction!",
"type_info": "Text",
"origin": "Expression"
},
{
"ordinal": 5,
"name": "old_starts_at!",
"type_info": "Timestamptz",
"origin": "Expression"
},
{
"ordinal": 6,
"name": "old_ends_at?",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "ends_at"
}
}
},
{
"ordinal": 7,
"name": "old_recurrence_every!",
"type_info": "Int4",
"origin": "Expression"
},
{
"ordinal": 8,
"name": "old_recurrence_unit!",
"type_info": "Text",
"origin": "Expression"
},
{
"ordinal": 9,
"name": "old_weekend_adjustment?",
"type_info": "Text",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "weekend_adjustment"
}
}
},
{
"ordinal": 10,
"name": "id!",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "id"
}
}
},
{
"ordinal": 11,
"name": "name!",
"type_info": "Text",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "name"
}
}
},
{
"ordinal": 12,
"name": "account_id!",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "account_id"
}
}
},
{
"ordinal": 13,
"name": "amount_cents!",
"type_info": "Int8",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "amount_cents"
}
}
},
{
"ordinal": 14,
"name": "direction!",
"type_info": "Text",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "direction"
}
}
},
{
"ordinal": 15,
"name": "starts_at!",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "starts_at"
}
}
},
{
"ordinal": 16,
"name": "ends_at?",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "ends_at"
}
}
},
{
"ordinal": 17,
"name": "recurrence_every!",
"type_info": "Int4",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "recurrence_every"
}
}
},
{
"ordinal": 18,
"name": "recurrence_unit!",
"type_info": "Text",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "recurrence_unit"
}
}
},
{
"ordinal": 19,
"name": "weekend_adjustment?",
"type_info": "Text",
"origin": {
"Table": {
"table": "recurring_transactions",
"name": "weekend_adjustment"
}
}
}
],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Text",
"Uuid",
"Int8",
"Text",
"Timestamptz",
"Timestamptz",
"Int4",
"Text",
"Text"
]
},
"nullable": [
false,
null,
null,
null,
null,
null,
true,
null,
null,
true,
false,
false,
false,
false,
false,
false,
true,
false,
false,
true
]
},
"hash": "129ff47c0d29ccba81eac0d40d7e9f2325911fb33b361300cd44073e1d0e3ed3"
}