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
@@ -1,40 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\tSELECT id, name\n\t\tFROM accounts\n\t\tWHERE id = ANY($1)\n\t\t",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "accounts",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "name",
"type_info": "Text",
"origin": {
"Table": {
"table": "accounts",
"name": "name"
}
}
}
],
"parameters": {
"Left": [
"UuidArray"
]
},
"nullable": [
false,
false
]
},
"hash": "016dcd0136e2284546f7ad4db96cadba51847776866997f0e978cff9c869c635"
}
@@ -1,6 +1,6 @@
{
"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 VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)\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 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 ",
"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": [
{
@@ -191,6 +191,7 @@
],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Text",
"Uuid",
@@ -226,5 +227,5 @@
true
]
},
"hash": "8bc3dbca6ff74e9775321d64337db88dfab2bf30f8128fcb81a8c980337da483"
"hash": "129ff47c0d29ccba81eac0d40d7e9f2325911fb33b361300cd44073e1d0e3ed3"
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\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 FROM recurring_transactions\n ORDER BY starts_at DESC, id DESC\n LIMIT $1 OFFSET $2\n ",
"query": "\n SELECT\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 FROM recurring_transactions\n WHERE account_id IN (SELECT id FROM accessible_accounts($1))\n ORDER BY starts_at DESC, id DESC\n LIMIT $2 OFFSET $3\n ",
"describe": {
"columns": [
{
@@ -116,6 +116,7 @@
],
"parameters": {
"Left": [
"Uuid",
"Int8",
"Int8"
]
@@ -133,5 +134,5 @@
true
]
},
"hash": "f4b604ad13d3424a7f3fc32bb40aa91981fe861b661169ac5310e9df0e7b99d9"
"hash": "216e891a0ad648d1b23a0c9ba158a26b51f67b3ef7715d2b6b0e252e7e321743"
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM transactions\n WHERE id = $1\n RETURNING id, account_id, amount_cents, direction, date, description\n ",
"query": "\n DELETE FROM transactions\n WHERE account_id IN (SELECT id FROM accessible_accounts($1))\n AND id = $2\n RETURNING id, account_id, amount_cents, direction, date, description\n ",
"describe": {
"columns": [
{
@@ -72,6 +72,7 @@
],
"parameters": {
"Left": [
"Uuid",
"Uuid"
]
},
@@ -84,5 +85,5 @@
false
]
},
"hash": "0c75096fe78c303e4676880840fc768b4150dfb9a0654229bf6581bd67494eb3"
"hash": "445ce23e4d76c2311b18c2a44d8d7199c5b4e865d60b0e39f5cd5101fbf60b57"
}
@@ -0,0 +1,31 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\tSELECT id AS \"id!\", name AS \"name!\"\n\t\tFROM accessible_accounts($1)\n\t\tWHERE id = $2\n\t\t",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id!",
"type_info": "Uuid",
"origin": "Expression"
},
{
"ordinal": 1,
"name": "name!",
"type_info": "Text",
"origin": "Expression"
}
],
"parameters": {
"Left": [
"Uuid",
"Uuid"
]
},
"nullable": [
null,
null
]
},
"hash": "4ab020caa34fd1b6a1479e2da759d26ad6c944ca01992430ba03c21cbe0764e0"
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM recurring_transactions\n WHERE id = $1\n RETURNING\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 ",
"query": "\n DELETE FROM recurring_transactions\n WHERE account_id IN (SELECT id FROM accessible_accounts($1))\n AND id = $2\n RETURNING\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 ",
"describe": {
"columns": [
{
@@ -116,6 +116,7 @@
],
"parameters": {
"Left": [
"Uuid",
"Uuid"
]
},
@@ -132,5 +133,5 @@
true
]
},
"hash": "be72d1cc51b27ae37afd44d85fe29e9226bcf428701dd931f9d03673729f11a2"
"hash": "590bd11fc994d0d22bb238ff7c140b1c48c4e31c34c18505c1d2a6aad01ddcdd"
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO transactions (id, account_id, amount_cents, direction, date, description)\n VALUES ($1, $2, $3, $4, $5, $6)\n\t\tON CONFLICT (id) DO UPDATE SET\n account_id = EXCLUDED.account_id,\n\t\t\tamount_cents = EXCLUDED.amount_cents,\n\t\t\tdirection = EXCLUDED.direction,\n\t\t\tdate = EXCLUDED.date,\n\t\t\tdescription = EXCLUDED.description\n\t\tRETURNING WITH (OLD AS old_row, NEW AS new_row)\n\t\t\told_row.id AS \"old_id?\",\n\t\t\tCOALESCE(old_row.account_id, new_row.account_id) AS \"old_account_id!\",\n\t\t\tCOALESCE(old_row.amount_cents, new_row.amount_cents) AS \"old_amount_cents!\",\n\t\t\tCOALESCE(old_row.direction, new_row.direction) AS \"old_direction!\",\n\t\t\tCOALESCE(old_row.date, new_row.date) AS \"old_date!\",\n\t\t\tCOALESCE(old_row.description, new_row.description) AS \"old_description!\",\n\t\t\tnew_row.id AS \"id!\",\n new_row.account_id AS \"account_id!\",\n\t\t\tnew_row.amount_cents AS \"amount_cents!\",\n\t\t\tnew_row.direction AS \"direction!\",\n\t\t\tnew_row.date AS \"date!\",\n\t\t\tnew_row.description AS \"description!\"\n\t\t",
"query": "\n INSERT INTO transactions (id, account_id, amount_cents, direction, date, description)\n SELECT $2, $3, $4, $5, $6, $7\n FROM accessible_accounts($1) AS accounts\n WHERE accounts.id = $3\n ON CONFLICT (id) DO UPDATE SET\n account_id = EXCLUDED.account_id,\n amount_cents = EXCLUDED.amount_cents,\n direction = EXCLUDED.direction,\n date = EXCLUDED.date,\n description = EXCLUDED.description\n WHERE 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.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.date, new_row.date) AS \"old_date!\",\n COALESCE(old_row.description, new_row.description) AS \"old_description!\",\n new_row.id AS \"id!\",\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.date AS \"date!\",\n new_row.description AS \"description!\"\n ",
"describe": {
"columns": [
{
@@ -113,6 +113,7 @@
],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Uuid",
"Int8",
@@ -136,5 +137,5 @@
false
]
},
"hash": "26a5b764d38ca78508087d1e793ae81530064a3ae661ff3c73c7cd686097aa81"
"hash": "644b5254e749e03696892b2234c1e8feee5d852e443c4fe0c1c71cdddfab3f6e"
}
@@ -1,42 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\tSELECT id, name\n\t\tFROM accounts\n\t\tWHERE ($1::text IS NULL OR name ILIKE '%' || $1 || '%')\n\t\tORDER BY name DESC, id DESC\n\t\tLIMIT $2\n\t\tOFFSET $3\n\t\t",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "accounts",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "name",
"type_info": "Text",
"origin": {
"Table": {
"table": "accounts",
"name": "name"
}
}
}
],
"parameters": {
"Left": [
"Text",
"Int8",
"Int8"
]
},
"nullable": [
false,
false
]
},
"hash": "9b5267c3bd09fb64717565c5c7e3084195d09c0a30f7e963a2497892398c6adc"
}
@@ -0,0 +1,33 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\tSELECT id AS \"id!\", name AS \"name!\"\n\t\tFROM accessible_accounts($1)\n\t\tWHERE ($2::text IS NULL OR name ILIKE '%' || $2 || '%')\n\t\tORDER BY name DESC, id DESC\n\t\tLIMIT $3\n\t\tOFFSET $4\n\t\t",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id!",
"type_info": "Uuid",
"origin": "Expression"
},
{
"ordinal": 1,
"name": "name!",
"type_info": "Text",
"origin": "Expression"
}
],
"parameters": {
"Left": [
"Uuid",
"Text",
"Int8",
"Int8"
]
},
"nullable": [
null,
null
]
},
"hash": "9d072194b9f245f29ec5d97b3363e7a9b069cf38ed1fecdb739b85715cba26ca"
}
@@ -0,0 +1,31 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\tSELECT id AS \"id!\", name AS \"name!\"\n\t\tFROM accessible_accounts($1)\n\t\tWHERE id = ANY($2)\n\t\t",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id!",
"type_info": "Uuid",
"origin": "Expression"
},
{
"ordinal": 1,
"name": "name!",
"type_info": "Text",
"origin": "Expression"
}
],
"parameters": {
"Left": [
"Uuid",
"UuidArray"
]
},
"nullable": [
null,
null
]
},
"hash": "b83902d6b3ccb3163c88ba684663a6774dd446a3dbd5301513e9f64cda75a325"
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\tINSERT INTO accounts (id, name)\n\t\tVALUES ($1, $2)\n\t\tON CONFLICT (id) DO UPDATE SET\n\t\t\tname = EXCLUDED.name\n\t\tRETURNING WITH (OLD AS old_row, NEW AS new_row)\n\t\t\told_row.id AS \"old_id?\",\n\t\t\tCOALESCE(old_row.name, new_row.name) AS \"old_name!\",\n\t\t\tnew_row.id AS \"id!\",\n\t\t\tnew_row.name AS \"name!\"\n\t\t",
"query": "\n\t\tINSERT INTO accounts (id, name)\n\t\tVALUES ($2, $3)\n\t\tON CONFLICT (id) DO UPDATE SET\n\t\t\tname = EXCLUDED.name\n\t\tWHERE accounts.id IN (SELECT id FROM accessible_accounts($1))\n\t\tRETURNING WITH (OLD AS old_row, NEW AS new_row)\n\t\t\told_row.id AS \"old_id?\",\n\t\t\tCOALESCE(old_row.name, new_row.name) AS \"old_name!\",\n\t\t\tnew_row.id AS \"id!\",\n\t\t\tnew_row.name AS \"name!\"\n\t\t",
"describe": {
"columns": [
{
@@ -45,6 +45,7 @@
],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Text"
]
@@ -56,5 +57,5 @@
false
]
},
"hash": "3b4b5bac598a8ef53be0c31ae751fb7e69f2e0b2ee18d628035fc198dadb4b9c"
"hash": "c5a2016942aadfafee38e7b4ad2926684d3d846a36d99bc0b33a48ae8a3076a9"
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\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 FROM recurring_transactions\n WHERE id = $1\n ",
"query": "\n SELECT\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 FROM recurring_transactions\n WHERE account_id IN (SELECT id FROM accessible_accounts($1))\n AND id = $2\n ",
"describe": {
"columns": [
{
@@ -116,6 +116,7 @@
],
"parameters": {
"Left": [
"Uuid",
"Uuid"
]
},
@@ -132,5 +133,5 @@
true
]
},
"hash": "ed9ae08575930c5b161d3f0c0f50479e51b54e348e1651f4a4e9b8328741cec7"
"hash": "cb4d0185f7464e4c7e6f4e0cb6bc40be6a56076c88d8356bf034838f1e22f2e3"
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT id, account_id, amount_cents, direction, date, description\n\t\tFROM transactions\n\t\tWHERE id = $1\n\t\t",
"query": "\n SELECT id, account_id, amount_cents, direction, date, description\n\t\tFROM transactions\n\t\tWHERE account_id IN (SELECT id FROM accessible_accounts($1))\n\t\tAND id = $2\n\t\t",
"describe": {
"columns": [
{
@@ -72,6 +72,7 @@
],
"parameters": {
"Left": [
"Uuid",
"Uuid"
]
},
@@ -84,5 +85,5 @@
false
]
},
"hash": "6fbffb56421dfc314468e6f7ea5b76594dfcdb06bd5d82ba61330fb8e51e88dc"
"hash": "cbb576c1e4d8404059a4ea5972027c2845a7de913052d076744ffde8383fdf86"
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM accounts WHERE id = $1 RETURNING id, name",
"query": "\n\t\tDELETE FROM accounts\n\t\tWHERE id IN (SELECT id FROM accessible_accounts($1))\n\t\tAND id = $2\n\t\tRETURNING id, name\n\t\t",
"describe": {
"columns": [
{
@@ -28,6 +28,7 @@
],
"parameters": {
"Left": [
"Uuid",
"Uuid"
]
},
@@ -36,5 +37,5 @@
false
]
},
"hash": "910c19f1022dcf5923c64f43cd3c55b6cf7a41a4907fc70d09b0b4770209acc3"
"hash": "d1774b1ccd955a93433e1149be03fad7ab09afd5eaa67a87e042b26d0a52e450"
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT id, account_id, amount_cents, direction, date, description\n\t\tFROM transactions\n\t\tORDER BY date DESC, id DESC\n\t\tLIMIT $1\n\t\tOFFSET $2\n\t\t",
"query": "\n SELECT id, account_id, amount_cents, direction, date, description\n\t\tFROM transactions\n\t\tWHERE account_id IN (SELECT id FROM accessible_accounts($1))\n\t\tORDER BY date DESC, id DESC\n\t\tLIMIT $2\n\t\tOFFSET $3\n\t\t",
"describe": {
"columns": [
{
@@ -72,6 +72,7 @@
],
"parameters": {
"Left": [
"Uuid",
"Int8",
"Int8"
]
@@ -85,5 +86,5 @@
false
]
},
"hash": "a962ef0282ca37bb5eba2ee1b0bd93da2527f7e5a0c4332527f1e533f3ecd4f0"
"hash": "d4a872e24aaff164619557665960013cf838d38e407ef5730a26dfe00a0dd96b"
}
@@ -1,40 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\tSELECT id, name\n\t\tFROM accounts\n\t\tWHERE id = $1\n\t\t",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "accounts",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "name",
"type_info": "Text",
"origin": {
"Table": {
"table": "accounts",
"name": "name"
}
}
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false,
false
]
},
"hash": "f671ec25a4bc22127ea7d3a63be134719dc4aa4eb4c96d7c4d64388cfb658fa8"
}