Propagate user app ownership conflict.
This commit is contained in:
+14
-2
@@ -6,12 +6,24 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "accounts",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "accounts",
|
||||||
|
"name": "name"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+14
-2
@@ -6,12 +6,24 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_apps",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "user_id",
|
"name": "user_id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_apps",
|
||||||
|
"name": "user_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+14
-2
@@ -6,12 +6,24 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_apps",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "user_id",
|
"name": "user_id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_apps",
|
||||||
|
"name": "user_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+7
-1
@@ -6,7 +6,13 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+7
-1
@@ -6,7 +6,13 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "users",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+7
-1
@@ -6,7 +6,13 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+7
-1
@@ -6,7 +6,13 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+7
-1
@@ -6,7 +6,13 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_apps",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+7
-1
@@ -6,7 +6,13 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "users",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+42
-6
@@ -6,32 +6,68 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "account_id",
|
"name": "account_id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "account_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
"name": "amount_cents",
|
"name": "amount_cents",
|
||||||
"type_info": "Int8"
|
"type_info": "Int8",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "amount_cents"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 3,
|
"ordinal": 3,
|
||||||
"name": "direction",
|
"name": "direction",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "direction"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 4,
|
"ordinal": 4,
|
||||||
"name": "date",
|
"name": "date",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "date"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 5,
|
"ordinal": 5,
|
||||||
"name": "description",
|
"name": "description",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "description"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+77
-11
@@ -6,57 +6,123 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "old_id?",
|
"name": "old_id?",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "id!",
|
"name": "id!",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
"name": "name!",
|
"name": "name!",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "name"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 3,
|
"ordinal": 3,
|
||||||
"name": "account_id!",
|
"name": "account_id!",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "account_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 4,
|
"ordinal": 4,
|
||||||
"name": "amount_cents!",
|
"name": "amount_cents!",
|
||||||
"type_info": "Int8"
|
"type_info": "Int8",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "amount_cents"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 5,
|
"ordinal": 5,
|
||||||
"name": "direction!",
|
"name": "direction!",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "direction"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "starts_at!",
|
"name": "starts_at!",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "starts_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 7,
|
"ordinal": 7,
|
||||||
"name": "ends_at?",
|
"name": "ends_at?",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "ends_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 8,
|
"ordinal": 8,
|
||||||
"name": "recurrence_every!",
|
"name": "recurrence_every!",
|
||||||
"type_info": "Int4"
|
"type_info": "Int4",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "recurrence_every"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 9,
|
"ordinal": 9,
|
||||||
"name": "recurrence_unit!",
|
"name": "recurrence_unit!",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "recurrence_unit"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 10,
|
"ordinal": 10,
|
||||||
"name": "weekend_adjustment?",
|
"name": "weekend_adjustment?",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "weekend_adjustment"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+7
-1
@@ -6,7 +6,13 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "users",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+49
-7
@@ -6,37 +6,79 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "old_id?",
|
"name": "old_id?",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "id!",
|
"name": "id!",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
"name": "account_id!",
|
"name": "account_id!",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "account_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 3,
|
"ordinal": 3,
|
||||||
"name": "amount_cents!",
|
"name": "amount_cents!",
|
||||||
"type_info": "Int8"
|
"type_info": "Int8",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "amount_cents"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 4,
|
"ordinal": 4,
|
||||||
"name": "direction!",
|
"name": "direction!",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "direction"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 5,
|
"ordinal": 5,
|
||||||
"name": "date!",
|
"name": "date!",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "date"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "description!",
|
"name": "description!",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "description"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+35
-5
@@ -6,27 +6,57 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "app_id",
|
"name": "app_id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "app_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
"name": "secret_hash",
|
"name": "secret_hash",
|
||||||
"type_info": "Bytea"
|
"type_info": "Bytea",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "secret_hash"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 3,
|
"ordinal": 3,
|
||||||
"name": "expires_at",
|
"name": "expires_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "expires_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 4,
|
"ordinal": 4,
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "created_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "\n INSERT INTO user_apps (id, user_id)\n VALUES ($1, $2)\n ON CONFLICT (id) DO UPDATE SET\n id = EXCLUDED.id\n WHERE user_apps.user_id = $2\n RETURNING WITH (OLD AS old_row, NEW AS new_row)\n old_row.id AS \"old_id?\",\n new_row.id AS \"id!\",\n new_row.user_id AS \"user_id!\"\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "old_id?",
|
||||||
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_apps",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "id!",
|
||||||
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_apps",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 2,
|
||||||
|
"name": "user_id!",
|
||||||
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_apps",
|
||||||
|
"name": "user_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Uuid",
|
||||||
|
"Uuid"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "977a6afaf7511915973fd20ab3a3fb03aeda84d0d460c9db1b5b1e7025493879"
|
||||||
|
}
|
||||||
+14
-2
@@ -6,12 +6,24 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "accounts",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "accounts",
|
||||||
|
"name": "name"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+2
-1
@@ -6,7 +6,8 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "is_valid!",
|
"name": "is_valid!",
|
||||||
"type_info": "Bool"
|
"type_info": "Bool",
|
||||||
|
"origin": "Expression"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+42
-6
@@ -6,32 +6,68 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "account_id",
|
"name": "account_id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "account_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
"name": "amount_cents",
|
"name": "amount_cents",
|
||||||
"type_info": "Int8"
|
"type_info": "Int8",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "amount_cents"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 3,
|
"ordinal": 3,
|
||||||
"name": "direction",
|
"name": "direction",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "direction"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 4,
|
"ordinal": 4,
|
||||||
"name": "date",
|
"name": "date",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "date"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 5,
|
"ordinal": 5,
|
||||||
"name": "description",
|
"name": "description",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "transactions",
|
||||||
|
"name": "description"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+21
-3
@@ -6,17 +6,35 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "old_id?",
|
"name": "old_id?",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "accounts",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "id!",
|
"name": "id!",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "accounts",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
"name": "name!",
|
"name": "name!",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "accounts",
|
||||||
|
"name": "name"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+42
-6
@@ -6,32 +6,68 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "old_id?",
|
"name": "old_id?",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "id!",
|
"name": "id!",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
"name": "app_id!",
|
"name": "app_id!",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "app_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 3,
|
"ordinal": 3,
|
||||||
"name": "secret_hash!",
|
"name": "secret_hash!",
|
||||||
"type_info": "Bytea"
|
"type_info": "Bytea",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "secret_hash"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 4,
|
"ordinal": 4,
|
||||||
"name": "expires_at!",
|
"name": "expires_at!",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "expires_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 5,
|
"ordinal": 5,
|
||||||
"name": "created_at!",
|
"name": "created_at!",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "created_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+7
-1
@@ -6,7 +6,13 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "accounts",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+35
-5
@@ -6,27 +6,57 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "app_id",
|
"name": "app_id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "app_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
"name": "secret_hash",
|
"name": "secret_hash",
|
||||||
"type_info": "Bytea"
|
"type_info": "Bytea",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "secret_hash"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 3,
|
"ordinal": 3,
|
||||||
"name": "expires_at",
|
"name": "expires_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "expires_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 4,
|
"ordinal": 4,
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "user_app_secrets",
|
||||||
|
"name": "created_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
"db_name": "PostgreSQL",
|
|
||||||
"query": "\n INSERT INTO user_apps (id, user_id)\n VALUES ($1, $2)\n ON CONFLICT (id) DO UPDATE SET\n id = EXCLUDED.id\n RETURNING WITH (OLD AS old_row, NEW AS new_row)\n old_row.id AS \"old_id?\",\n new_row.id AS \"id!\",\n new_row.user_id AS \"user_id!\"\n ",
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"ordinal": 0,
|
|
||||||
"name": "old_id?",
|
|
||||||
"type_info": "Uuid"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 1,
|
|
||||||
"name": "id!",
|
|
||||||
"type_info": "Uuid"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 2,
|
|
||||||
"name": "user_id!",
|
|
||||||
"type_info": "Uuid"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Uuid",
|
|
||||||
"Uuid"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"nullable": [
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"hash": "e4cc5672787e94ee849cb175416e92f053d6a36609af5f6a244a2c236e3ffb21"
|
|
||||||
}
|
|
||||||
+70
-10
@@ -6,52 +6,112 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "name"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
"name": "account_id",
|
"name": "account_id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "account_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 3,
|
"ordinal": 3,
|
||||||
"name": "amount_cents",
|
"name": "amount_cents",
|
||||||
"type_info": "Int8"
|
"type_info": "Int8",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "amount_cents"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 4,
|
"ordinal": 4,
|
||||||
"name": "direction",
|
"name": "direction",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "direction"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 5,
|
"ordinal": 5,
|
||||||
"name": "starts_at",
|
"name": "starts_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "starts_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "ends_at",
|
"name": "ends_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "ends_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 7,
|
"ordinal": 7,
|
||||||
"name": "recurrence_every",
|
"name": "recurrence_every",
|
||||||
"type_info": "Int4"
|
"type_info": "Int4",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "recurrence_every"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 8,
|
"ordinal": 8,
|
||||||
"name": "recurrence_unit",
|
"name": "recurrence_unit",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "recurrence_unit"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 9,
|
"ordinal": 9,
|
||||||
"name": "weekend_adjustment",
|
"name": "weekend_adjustment",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "weekend_adjustment"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+14
-2
@@ -6,12 +6,24 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "old_id?",
|
"name": "old_id?",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "users",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "id!",
|
"name": "id!",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "users",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+70
-10
@@ -6,52 +6,112 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "name"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
"name": "account_id",
|
"name": "account_id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "account_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 3,
|
"ordinal": 3,
|
||||||
"name": "amount_cents",
|
"name": "amount_cents",
|
||||||
"type_info": "Int8"
|
"type_info": "Int8",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "amount_cents"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 4,
|
"ordinal": 4,
|
||||||
"name": "direction",
|
"name": "direction",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "direction"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 5,
|
"ordinal": 5,
|
||||||
"name": "starts_at",
|
"name": "starts_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "starts_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "ends_at",
|
"name": "ends_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "ends_at"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 7,
|
"ordinal": 7,
|
||||||
"name": "recurrence_every",
|
"name": "recurrence_every",
|
||||||
"type_info": "Int4"
|
"type_info": "Int4",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "recurrence_every"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 8,
|
"ordinal": 8,
|
||||||
"name": "recurrence_unit",
|
"name": "recurrence_unit",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "recurrence_unit"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 9,
|
"ordinal": 9,
|
||||||
"name": "weekend_adjustment",
|
"name": "weekend_adjustment",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "recurring_transactions",
|
||||||
|
"name": "weekend_adjustment"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+14
-2
@@ -6,12 +6,24 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "accounts",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type_info": "Text"
|
"type_info": "Text",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "accounts",
|
||||||
|
"name": "name"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
+7
-1
@@ -6,7 +6,13 @@
|
|||||||
{
|
{
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type_info": "Uuid"
|
"type_info": "Uuid",
|
||||||
|
"origin": {
|
||||||
|
"Table": {
|
||||||
|
"table": "tokens",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
@@ -12,6 +12,22 @@ impl<T> Upsert<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum GuardedUpsert<T> {
|
||||||
|
Created(T),
|
||||||
|
Updated(T),
|
||||||
|
Rejected,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> GuardedUpsert<T> {
|
||||||
|
pub fn try_map<U, E>(self, f: impl FnOnce(T) -> Result<U, E>) -> Result<GuardedUpsert<U>, E> {
|
||||||
|
Ok(match self {
|
||||||
|
Self::Created(value) => GuardedUpsert::Created(f(value)?),
|
||||||
|
Self::Updated(value) => GuardedUpsert::Updated(f(value)?),
|
||||||
|
Self::Rejected => GuardedUpsert::Rejected,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum Delete {
|
pub enum Delete {
|
||||||
Deleted,
|
Deleted,
|
||||||
NotFound,
|
NotFound,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
DatabaseError,
|
DatabaseError,
|
||||||
dtos::{Delete, Upsert, UserAppRow},
|
dtos::{Delete, GuardedUpsert, UserAppRow},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Query {
|
pub struct Query {
|
||||||
@@ -60,7 +60,7 @@ where
|
|||||||
pub async fn upsert<'e, E>(
|
pub async fn upsert<'e, E>(
|
||||||
executor: E,
|
executor: E,
|
||||||
app: UserAppRow,
|
app: UserAppRow,
|
||||||
) -> Result<Upsert<UserAppRow>, DatabaseError>
|
) -> Result<GuardedUpsert<UserAppRow>, DatabaseError>
|
||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
@@ -70,6 +70,7 @@ where
|
|||||||
VALUES ($1, $2)
|
VALUES ($1, $2)
|
||||||
ON CONFLICT (id) DO UPDATE SET
|
ON CONFLICT (id) DO UPDATE SET
|
||||||
id = EXCLUDED.id
|
id = EXCLUDED.id
|
||||||
|
WHERE user_apps.user_id = $2
|
||||||
RETURNING WITH (OLD AS old_row, NEW AS new_row)
|
RETURNING WITH (OLD AS old_row, NEW AS new_row)
|
||||||
old_row.id AS "old_id?",
|
old_row.id AS "old_id?",
|
||||||
new_row.id AS "id!",
|
new_row.id AS "id!",
|
||||||
@@ -78,19 +79,23 @@ where
|
|||||||
app.id,
|
app.id,
|
||||||
app.user_id,
|
app.user_id,
|
||||||
)
|
)
|
||||||
.fetch_one(executor)
|
.fetch_optional(executor)
|
||||||
.await
|
.await
|
||||||
.map_err(DatabaseError::from)?;
|
.map_err(DatabaseError::from)?;
|
||||||
|
|
||||||
|
let Some(row) = row else {
|
||||||
|
return Ok(GuardedUpsert::Rejected);
|
||||||
|
};
|
||||||
|
|
||||||
let app = UserAppRow {
|
let app = UserAppRow {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
user_id: row.user_id,
|
user_id: row.user_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(if row.old_id.is_some() {
|
Ok(if row.old_id.is_some() {
|
||||||
Upsert::Updated(app)
|
GuardedUpsert::Updated(app)
|
||||||
} else {
|
} else {
|
||||||
Upsert::Created(app)
|
GuardedUpsert::Created(app)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,15 @@ impl IntoResponse for AppError {
|
|||||||
Self::Repository(RepositoryError::Decode(error)) => {
|
Self::Repository(RepositoryError::Decode(error)) => {
|
||||||
tracing::error!(%error, "invalid stored data");
|
tracing::error!(%error, "invalid stored data");
|
||||||
}
|
}
|
||||||
|
Self::Repository(RepositoryError::OwnershipConflict {
|
||||||
|
relation: ReferenceRelation::UserApp,
|
||||||
|
}) => {
|
||||||
|
tracing::warn!("user app ownership conflict");
|
||||||
|
return error_response(StatusCode::CONFLICT, "User app belongs to another user");
|
||||||
|
}
|
||||||
|
Self::Repository(RepositoryError::OwnershipConflict { relation }) => {
|
||||||
|
tracing::error!(%relation, "unhandled ownership conflict");
|
||||||
|
}
|
||||||
Self::Repository(RepositoryError::ReferenceViolation {
|
Self::Repository(RepositoryError::ReferenceViolation {
|
||||||
relation: ReferenceRelation::User,
|
relation: ReferenceRelation::User,
|
||||||
kind: ReferenceViolationKind::Missing,
|
kind: ReferenceViolationKind::Missing,
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ pub enum RepositoryError {
|
|||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Decode(#[from] DecodeError),
|
Decode(#[from] DecodeError),
|
||||||
|
|
||||||
|
#[error("{relation} is owned by another user")]
|
||||||
|
OwnershipConflict { relation: ReferenceRelation },
|
||||||
|
|
||||||
#[error("reference violation ({kind}: {relation})")]
|
#[error("reference violation ({kind}: {relation})")]
|
||||||
ReferenceViolation {
|
ReferenceViolation {
|
||||||
relation: ReferenceRelation,
|
relation: ReferenceRelation,
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use super::{QueryConversionError, RepositoryError, dtos::Upsert};
|
use super::{QueryConversionError, ReferenceRelation, RepositoryError, dtos::Upsert};
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{Constraint, DatabaseError, dtos::UserAppRow, user_apps as db},
|
database::{
|
||||||
|
Constraint, DatabaseError,
|
||||||
|
dtos::{GuardedUpsert, UserAppRow},
|
||||||
|
user_apps as db,
|
||||||
|
},
|
||||||
domain::UserApp,
|
domain::UserApp,
|
||||||
repository::DecodeError,
|
repository::DecodeError,
|
||||||
};
|
};
|
||||||
@@ -58,13 +62,23 @@ pub async fn upsert<'e, E>(executor: E, app: UserApp) -> Result<Upsert<UserApp>,
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let app = db::upsert(executor, encode(app))
|
let outcome = db::upsert(executor, encode(app))
|
||||||
.await
|
.await
|
||||||
.map_err(classify_upsert_error)?
|
.map_err(classify_upsert_error)?;
|
||||||
.try_map(decode)?
|
|
||||||
.into();
|
|
||||||
|
|
||||||
Ok(app)
|
map_upsert(outcome)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn map_upsert(outcome: GuardedUpsert<UserAppRow>) -> Result<Upsert<UserApp>, RepositoryError> {
|
||||||
|
Ok(match outcome.try_map(decode)? {
|
||||||
|
GuardedUpsert::Created(app) => Upsert::Created(app),
|
||||||
|
GuardedUpsert::Updated(app) => Upsert::Updated(app),
|
||||||
|
GuardedUpsert::Rejected => {
|
||||||
|
return Err(RepositoryError::OwnershipConflict {
|
||||||
|
relation: ReferenceRelation::UserApp,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn classify_upsert_error(error: DatabaseError) -> RepositoryError {
|
fn classify_upsert_error(error: DatabaseError) -> RepositoryError {
|
||||||
@@ -138,6 +152,41 @@ mod tests {
|
|||||||
assert!(matches!(error, RepositoryError::Database(_)));
|
assert!(matches!(error, RepositoryError::Database(_)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn maps_created_upsert() {
|
||||||
|
let row = row();
|
||||||
|
let id = row.id;
|
||||||
|
|
||||||
|
let Ok(Upsert::Created(app)) = map_upsert(GuardedUpsert::Created(row)) else {
|
||||||
|
panic!("expected created upsert");
|
||||||
|
};
|
||||||
|
assert_eq!(app.id, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn maps_updated_upsert() {
|
||||||
|
let row = row();
|
||||||
|
let id = row.id;
|
||||||
|
|
||||||
|
let Ok(Upsert::Updated(app)) = map_upsert(GuardedUpsert::Updated(row)) else {
|
||||||
|
panic!("expected updated upsert");
|
||||||
|
};
|
||||||
|
assert_eq!(app.id, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn maps_rejected_upsert_to_ownership_conflict() {
|
||||||
|
let Err(error) = map_upsert(GuardedUpsert::Rejected) else {
|
||||||
|
panic!("expected ownership conflict");
|
||||||
|
};
|
||||||
|
assert!(matches!(
|
||||||
|
error,
|
||||||
|
RepositoryError::OwnershipConflict {
|
||||||
|
relation: ReferenceRelation::UserApp,
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
fn row() -> UserAppRow {
|
fn row() -> UserAppRow {
|
||||||
UserAppRow {
|
UserAppRow {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|||||||
Reference in New Issue
Block a user