Skip to main content

max / makenotwork

server: convert remaining money-path DB modules to compile-checked SQL (ultra-fuzz Run #1 --deep Phase 4) Finish D4: convert media_files, versions, sessions, auth, license_keys, promo_codes, subscriptions, transactions from runtime sqlx::query strings to compile-checked query!/query_as! macros (sqlx-offline), completing the money-path migration. Queries that bind a chrono DateTime<Utc> or build SQL dynamically stay runtime with a documented reason. Fixes surfaced and resolved by the offline gate: - ORDER BY on a macro-aliased column failed (sqlx sends the "col!: Type" suffix as the literal column name); reorder on the underlying expression instead. - get_user_purchases.license_key_code: a column selected from a derived subquery is inferred NOT NULL by sqlx, so a bare "col: Type" override panicked with UnexpectedNull at runtime when the LEFT JOIN produced no key. Forced nullable with "?: KeyCode".
Author: Max Johnson <me@maxj.phd> · 2026-06-23 00:01 UTC
Commit: 52a315ed7feade137c150f9259b129d26bed6bd6
Parent: b7eadd1
145 files changed, +7947 insertions, -606 deletions
@@ -0,0 +1,16 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n INSERT INTO user_downloads (user_id, item_id, version_id)\n VALUES ($1, $2, $3)\n ON CONFLICT (user_id, item_id, version_id) DO NOTHING\n ",
4 + "describe": {
5 + "columns": [],
6 + "parameters": {
7 + "Left": [
8 + "Uuid",
9 + "Uuid",
10 + "Uuid"
11 + ]
12 + },
13 + "nullable": []
14 + },
15 + "hash": "03e1ede9cf99290dabd6c809568142ff8e2e00ec13014d0b4b3e5eb3f5aa274b"
16 + }
@@ -0,0 +1,15 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "UPDATE versions SET is_current = false WHERE item_id = $1 AND version_number != $2",
4 + "describe": {
5 + "columns": [],
6 + "parameters": {
7 + "Left": [
8 + "Uuid",
9 + "Text"
10 + ]
11 + },
12 + "nullable": []
13 + },
14 + "hash": "0550dd5416b339101f50fe8d1a02b5bd50c1f8ac5ec919c9d3de0add29d73f92"
15 + }
@@ -0,0 +1,100 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n UPDATE subscriptions SET paused_at = NULL\n WHERE project_id IN (SELECT id FROM projects WHERE user_id = $1)\n AND status = 'active'\n AND paused_at IS NOT NULL\n RETURNING id AS \"id: SubscriptionId\", subscriber_id AS \"subscriber_id: UserId\",\n tier_id AS \"tier_id: SubscriptionTierId\", project_id AS \"project_id: ProjectId\",\n stripe_subscription_id, stripe_customer_id,\n status AS \"status: super::SubscriptionStatus\",\n current_period_start AS \"current_period_start: chrono::DateTime<chrono::Utc>\",\n current_period_end AS \"current_period_end: chrono::DateTime<chrono::Utc>\",\n canceled_at AS \"canceled_at: chrono::DateTime<chrono::Utc>\",\n created_at AS \"created_at: chrono::DateTime<chrono::Utc>\",\n updated_at AS \"updated_at: chrono::DateTime<chrono::Utc>\",\n item_id AS \"item_id: ItemId\",\n paused_at AS \"paused_at: chrono::DateTime<chrono::Utc>\"\n ",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "id: SubscriptionId",
9 + "type_info": "Uuid"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "subscriber_id: UserId",
14 + "type_info": "Uuid"
15 + },
16 + {
17 + "ordinal": 2,
18 + "name": "tier_id: SubscriptionTierId",
19 + "type_info": "Uuid"
20 + },
21 + {
22 + "ordinal": 3,
23 + "name": "project_id: ProjectId",
24 + "type_info": "Uuid"
25 + },
26 + {
27 + "ordinal": 4,
28 + "name": "stripe_subscription_id",
29 + "type_info": "Text"
30 + },
31 + {
32 + "ordinal": 5,
33 + "name": "stripe_customer_id",
34 + "type_info": "Text"
35 + },
36 + {
37 + "ordinal": 6,
38 + "name": "status: super::SubscriptionStatus",
39 + "type_info": "Varchar"
40 + },
41 + {
42 + "ordinal": 7,
43 + "name": "current_period_start: chrono::DateTime<chrono::Utc>",
44 + "type_info": "Timestamptz"
45 + },
46 + {
47 + "ordinal": 8,
48 + "name": "current_period_end: chrono::DateTime<chrono::Utc>",
49 + "type_info": "Timestamptz"
50 + },
51 + {
52 + "ordinal": 9,
53 + "name": "canceled_at: chrono::DateTime<chrono::Utc>",
54 + "type_info": "Timestamptz"
55 + },
56 + {
57 + "ordinal": 10,
58 + "name": "created_at: chrono::DateTime<chrono::Utc>",
59 + "type_info": "Timestamptz"
60 + },
61 + {
62 + "ordinal": 11,
63 + "name": "updated_at: chrono::DateTime<chrono::Utc>",
64 + "type_info": "Timestamptz"
65 + },
66 + {
67 + "ordinal": 12,
68 + "name": "item_id: ItemId",
69 + "type_info": "Uuid"
70 + },
71 + {
72 + "ordinal": 13,
73 + "name": "paused_at: chrono::DateTime<chrono::Utc>",
74 + "type_info": "Timestamptz"
75 + }
76 + ],
77 + "parameters": {
78 + "Left": [
79 + "Uuid"
80 + ]
81 + },
82 + "nullable": [
83 + false,
84 + false,
85 + false,
86 + true,
87 + false,
88 + false,
89 + false,
90 + true,
91 + true,
92 + true,
93 + false,
94 + false,
95 + true,
96 + true
97 + ]
98 + },
99 + "hash": "05fc1e551a7fb89119de0ac0801fdd5219e7e478dd8b63d7665dba25243a4c26"
100 + }
@@ -0,0 +1,14 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "DELETE FROM promo_codes WHERE creator_id = $1 AND expires_at IS NOT NULL AND expires_at < NOW()",
4 + "describe": {
5 + "columns": [],
6 + "parameters": {
7 + "Left": [
8 + "Uuid"
9 + ]
10 + },
11 + "nullable": []
12 + },
13 + "hash": "074a33db48f3349c0e8dcacb93cf70d6a66fb78866e7af46e988e952406461a6"
14 + }
@@ -0,0 +1,70 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n SELECT id AS \"id: LicenseKeyId\", item_id AS \"item_id: ItemId\",\n owner_id AS \"owner_id: UserId\", transaction_id AS \"transaction_id: TransactionId\",\n key_code AS \"key_code: KeyCode\", max_activations, activation_count,\n revoked_at AS \"revoked_at: chrono::DateTime<chrono::Utc>\",\n created_at AS \"created_at: chrono::DateTime<chrono::Utc>\"\n FROM license_keys WHERE item_id = $1 ORDER BY created_at DESC LIMIT 500\n ",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "id: LicenseKeyId",
9 + "type_info": "Uuid"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "item_id: ItemId",
14 + "type_info": "Uuid"
15 + },
16 + {
17 + "ordinal": 2,
18 + "name": "owner_id: UserId",
19 + "type_info": "Uuid"
20 + },
21 + {
22 + "ordinal": 3,
23 + "name": "transaction_id: TransactionId",
24 + "type_info": "Uuid"
25 + },
26 + {
27 + "ordinal": 4,
28 + "name": "key_code: KeyCode",
29 + "type_info": "Varchar"
30 + },
31 + {
32 + "ordinal": 5,
33 + "name": "max_activations",
34 + "type_info": "Int4"
35 + },
36 + {
37 + "ordinal": 6,
38 + "name": "activation_count",
39 + "type_info": "Int4"
40 + },
41 + {
42 + "ordinal": 7,
43 + "name": "revoked_at: chrono::DateTime<chrono::Utc>",
44 + "type_info": "Timestamptz"
45 + },
46 + {
47 + "ordinal": 8,
48 + "name": "created_at: chrono::DateTime<chrono::Utc>",
49 + "type_info": "Timestamptz"
50 + }
51 + ],
52 + "parameters": {
53 + "Left": [
54 + "Uuid"
55 + ]
56 + },
57 + "nullable": [
58 + false,
59 + false,
60 + false,
61 + true,
62 + false,
63 + true,
64 + false,
65 + true,
66 + false
67 + ]
68 + },
69 + "hash": "08a3603078a3aee0577f94add6b32ceb5633667a5a7dbcb6476c658dbed32ba7"
70 + }
@@ -0,0 +1,14 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n UPDATE license_keys\n SET revoked_at = NOW()\n WHERE transaction_id = $1 AND revoked_at IS NULL\n ",
4 + "describe": {
5 + "columns": [],
6 + "parameters": {
7 + "Left": [
8 + "Uuid"
9 + ]
10 + },
11 + "nullable": []
12 + },
13 + "hash": "0cc4a78544490a1bb1f21db1f53309f5f30fba02f1ddeafda6b761b62a9c8c6c"
14 + }
@@ -0,0 +1,159 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n INSERT INTO transactions (buyer_id, seller_id, item_id, amount_cents, platform_fee_cents, stripe_checkout_session_id, item_title, seller_username, share_contact, project_id, promo_code_id, guest_email)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)\n RETURNING\n id AS \"id: TransactionId\", buyer_id AS \"buyer_id: UserId\", seller_id AS \"seller_id: UserId\",\n item_id AS \"item_id: ItemId\", amount_cents AS \"amount_cents: Cents\", platform_fee_cents AS \"platform_fee_cents: Cents\",\n currency, status AS \"status: super::TransactionStatus\", stripe_payment_intent_id, stripe_checkout_session_id,\n created_at AS \"created_at: chrono::DateTime<chrono::Utc>\", completed_at AS \"completed_at: chrono::DateTime<chrono::Utc>\",\n item_title, seller_username, share_contact, project_id AS \"project_id: ProjectId\",\n parent_transaction_id AS \"parent_transaction_id: TransactionId\", promo_code_id AS \"promo_code_id: PromoCodeId\",\n guest_email, claim_token AS \"claim_token: ClaimToken\", claimed_by AS \"claimed_by: UserId\",\n download_token AS \"download_token: DownloadToken\"\n ",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "id: TransactionId",
9 + "type_info": "Uuid"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "buyer_id: UserId",
14 + "type_info": "Uuid"
15 + },
16 + {
17 + "ordinal": 2,
18 + "name": "seller_id: UserId",
19 + "type_info": "Uuid"
20 + },
21 + {
22 + "ordinal": 3,
23 + "name": "item_id: ItemId",
24 + "type_info": "Uuid"
25 + },
26 + {
27 + "ordinal": 4,
28 + "name": "amount_cents: Cents",
29 + "type_info": "Int4"
30 + },
31 + {
32 + "ordinal": 5,
33 + "name": "platform_fee_cents: Cents",
34 + "type_info": "Int4"
35 + },
36 + {
37 + "ordinal": 6,
38 + "name": "currency",
39 + "type_info": "Varchar"
40 + },
41 + {
42 + "ordinal": 7,
43 + "name": "status: super::TransactionStatus",
44 + "type_info": "Varchar"
45 + },
46 + {
47 + "ordinal": 8,
48 + "name": "stripe_payment_intent_id",
49 + "type_info": "Varchar"
50 + },
51 + {
52 + "ordinal": 9,
53 + "name": "stripe_checkout_session_id",
54 + "type_info": "Varchar"
55 + },
56 + {
57 + "ordinal": 10,
58 + "name": "created_at: chrono::DateTime<chrono::Utc>",
59 + "type_info": "Timestamptz"
60 + },
61 + {
62 + "ordinal": 11,
63 + "name": "completed_at: chrono::DateTime<chrono::Utc>",
64 + "type_info": "Timestamptz"
65 + },
66 + {
67 + "ordinal": 12,
68 + "name": "item_title",
69 + "type_info": "Varchar"
70 + },
71 + {
72 + "ordinal": 13,
73 + "name": "seller_username",
74 + "type_info": "Varchar"
75 + },
76 + {
77 + "ordinal": 14,
78 + "name": "share_contact",
79 + "type_info": "Bool"
80 + },
81 + {
82 + "ordinal": 15,
83 + "name": "project_id: ProjectId",
84 + "type_info": "Uuid"
85 + },
86 + {
87 + "ordinal": 16,
88 + "name": "parent_transaction_id: TransactionId",
89 + "type_info": "Uuid"
90 + },
91 + {
92 + "ordinal": 17,
93 + "name": "promo_code_id: PromoCodeId",
94 + "type_info": "Uuid"
95 + },
96 + {
97 + "ordinal": 18,
98 + "name": "guest_email",
99 + "type_info": "Varchar"
100 + },
101 + {
102 + "ordinal": 19,
103 + "name": "claim_token: ClaimToken",
104 + "type_info": "Uuid"
105 + },
106 + {
107 + "ordinal": 20,
108 + "name": "claimed_by: UserId",
109 + "type_info": "Uuid"
110 + },
111 + {
112 + "ordinal": 21,
113 + "name": "download_token: DownloadToken",
114 + "type_info": "Uuid"
115 + }
116 + ],
117 + "parameters": {
118 + "Left": [
119 + "Uuid",
120 + "Uuid",
121 + "Uuid",
122 + "Int4",
123 + "Int4",
124 + "Varchar",
125 + "Varchar",
126 + "Varchar",
127 + "Bool",
128 + "Uuid",
129 + "Uuid",
130 + "Varchar"
131 + ]
132 + },
133 + "nullable": [
134 + false,
135 + true,
136 + true,
137 + true,
138 + false,
139 + false,
140 + false,
141 + false,
142 + true,
143 + true,
144 + false,
145 + true,
146 + true,
147 + true,
148 + false,
149 + true,
150 + true,
151 + true,
152 + true,
153 + true,
154 + true,
155 + true
156 + ]
157 + },
158 + "hash": "0e3c392cde613d2447dbbba61bccccf276fb01ea2a550f50afbf540cd5f6ea2c"
159 + }
@@ -0,0 +1,149 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n SELECT\n id AS \"id: TransactionId\", buyer_id AS \"buyer_id: UserId\", seller_id AS \"seller_id: UserId\",\n item_id AS \"item_id: ItemId\", amount_cents AS \"amount_cents: Cents\", platform_fee_cents AS \"platform_fee_cents: Cents\",\n currency, status AS \"status: super::TransactionStatus\", stripe_payment_intent_id, stripe_checkout_session_id,\n created_at AS \"created_at: chrono::DateTime<chrono::Utc>\", completed_at AS \"completed_at: chrono::DateTime<chrono::Utc>\",\n item_title, seller_username, share_contact, project_id AS \"project_id: ProjectId\",\n parent_transaction_id AS \"parent_transaction_id: TransactionId\", promo_code_id AS \"promo_code_id: PromoCodeId\",\n guest_email, claim_token AS \"claim_token: ClaimToken\", claimed_by AS \"claimed_by: UserId\",\n download_token AS \"download_token: DownloadToken\"\n FROM transactions WHERE seller_id = $1 ORDER BY created_at DESC LIMIT $2\n ",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "id: TransactionId",
9 + "type_info": "Uuid"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "buyer_id: UserId",
14 + "type_info": "Uuid"
15 + },
16 + {
17 + "ordinal": 2,
18 + "name": "seller_id: UserId",
19 + "type_info": "Uuid"
20 + },
21 + {
22 + "ordinal": 3,
23 + "name": "item_id: ItemId",
24 + "type_info": "Uuid"
25 + },
26 + {
27 + "ordinal": 4,
28 + "name": "amount_cents: Cents",
29 + "type_info": "Int4"
30 + },
31 + {
32 + "ordinal": 5,
33 + "name": "platform_fee_cents: Cents",
34 + "type_info": "Int4"
35 + },
36 + {
37 + "ordinal": 6,
38 + "name": "currency",
39 + "type_info": "Varchar"
40 + },
41 + {
42 + "ordinal": 7,
43 + "name": "status: super::TransactionStatus",
44 + "type_info": "Varchar"
45 + },
46 + {
47 + "ordinal": 8,
48 + "name": "stripe_payment_intent_id",
49 + "type_info": "Varchar"
50 + },
51 + {
52 + "ordinal": 9,
53 + "name": "stripe_checkout_session_id",
54 + "type_info": "Varchar"
55 + },
56 + {
57 + "ordinal": 10,
58 + "name": "created_at: chrono::DateTime<chrono::Utc>",
59 + "type_info": "Timestamptz"
60 + },
61 + {
62 + "ordinal": 11,
63 + "name": "completed_at: chrono::DateTime<chrono::Utc>",
64 + "type_info": "Timestamptz"
65 + },
66 + {
67 + "ordinal": 12,
68 + "name": "item_title",
69 + "type_info": "Varchar"
70 + },
71 + {
72 + "ordinal": 13,
73 + "name": "seller_username",
74 + "type_info": "Varchar"
75 + },
76 + {
77 + "ordinal": 14,
78 + "name": "share_contact",
79 + "type_info": "Bool"
80 + },
81 + {
82 + "ordinal": 15,
83 + "name": "project_id: ProjectId",
84 + "type_info": "Uuid"
85 + },
86 + {
87 + "ordinal": 16,
88 + "name": "parent_transaction_id: TransactionId",
89 + "type_info": "Uuid"
90 + },
91 + {
92 + "ordinal": 17,
93 + "name": "promo_code_id: PromoCodeId",
94 + "type_info": "Uuid"
95 + },
96 + {
97 + "ordinal": 18,
98 + "name": "guest_email",
99 + "type_info": "Varchar"
100 + },
101 + {
102 + "ordinal": 19,
103 + "name": "claim_token: ClaimToken",
104 + "type_info": "Uuid"
105 + },
106 + {
107 + "ordinal": 20,
108 + "name": "claimed_by: UserId",
109 + "type_info": "Uuid"
110 + },
111 + {
112 + "ordinal": 21,
113 + "name": "download_token: DownloadToken",
114 + "type_info": "Uuid"
115 + }
116 + ],
117 + "parameters": {
118 + "Left": [
119 + "Uuid",
120 + "Int8"
121 + ]
122 + },
123 + "nullable": [
124 + false,
125 + true,
126 + true,
127 + true,
128 + false,
129 + false,
130 + false,
131 + false,
132 + true,
133 + true,
134 + false,
135 + true,
136 + true,
137 + true,
138 + false,
139 + true,
140 + true,
141 + true,
142 + true,
143 + true,
144 + true,
145 + true
146 + ]
147 + },
148 + "hash": "0edcbc78d86e90f5845d72797f65ed8d1071327610ef8a51dd775b3f709bec66"
149 + }
@@ -0,0 +1,22 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "SELECT COUNT(*) AS \"count!\" FROM media_files WHERE user_id = $1",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "count!",
9 + "type_info": "Int8"
10 + }
11 + ],
12 + "parameters": {
13 + "Left": [
14 + "Uuid"
15 + ]
16 + },
17 + "nullable": [
18 + null
19 + ]
20 + },
21 + "hash": "1391d8b7d9bf3b05a41a7e8fcd0fb7161bf0bc10532258f3c8269588bf753d54"
22 + }
@@ -0,0 +1,40 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n UPDATE user_sessions us\n SET last_active_at = NOW()\n FROM users u\n WHERE us.id = $1 AND u.id = us.user_id\n RETURNING\n u.suspended_at IS NOT NULL AS \"suspended!\",\n u.can_create_projects AS \"can_create_projects!\",\n EXISTS(SELECT 1 FROM fan_plus_subscriptions fps WHERE fps.user_id = u.id AND fps.status = 'active') AS \"is_fan_plus!\",\n (SELECT cs.tier FROM creator_subscriptions cs WHERE cs.user_id = u.id AND cs.status = 'active') AS \"creator_tier\"\n ",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "suspended!",
9 + "type_info": "Bool"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "can_create_projects!",
14 + "type_info": "Bool"
15 + },
16 + {
17 + "ordinal": 2,
18 + "name": "is_fan_plus!",
19 + "type_info": "Bool"
20 + },
21 + {
22 + "ordinal": 3,
23 + "name": "creator_tier",
24 + "type_info": "Text"
25 + }
26 + ],
27 + "parameters": {
28 + "Left": [
29 + "Uuid"
30 + ]
31 + },
32 + "nullable": [
33 + null,
34 + false,
35 + null,
36 + null
37 + ]
38 + },
39 + "hash": "1428b78893adfe9e3120fef1a0abc45a83ba4e303e199c9e9234b275ffe2b2c8"
40 + }
@@ -0,0 +1,70 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n SELECT s.id AS \"id: SubscriptionId\", s.project_id AS \"project_id!: ProjectId\",\n p.title AS project_title, p.slug AS \"project_slug: super::Slug\",\n t.name AS tier_name, t.price_cents, s.status AS \"status: super::SubscriptionStatus\",\n s.current_period_end AS \"current_period_end: chrono::DateTime<chrono::Utc>\",\n s.stripe_subscription_id\n FROM subscriptions s\n JOIN projects p ON p.id = s.project_id\n JOIN subscription_tiers t ON t.id = s.tier_id\n WHERE s.subscriber_id = $1\n ORDER BY s.created_at DESC\n LIMIT 1000\n ",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "id: SubscriptionId",
9 + "type_info": "Uuid"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "project_id!: ProjectId",
14 + "type_info": "Uuid"
15 + },
16 + {
17 + "ordinal": 2,
18 + "name": "project_title",
19 + "type_info": "Varchar"
20 + },
21 + {
22 + "ordinal": 3,
23 + "name": "project_slug: super::Slug",
24 + "type_info": "Varchar"
25 + },
26 + {
27 + "ordinal": 4,
28 + "name": "tier_name",
29 + "type_info": "Varchar"
30 + },
31 + {
32 + "ordinal": 5,
33 + "name": "price_cents",
34 + "type_info": "Int4"
35 + },
36 + {
37 + "ordinal": 6,
38 + "name": "status: super::SubscriptionStatus",
39 + "type_info": "Varchar"
40 + },
41 + {
42 + "ordinal": 7,
43 + "name": "current_period_end: chrono::DateTime<chrono::Utc>",
44 + "type_info": "Timestamptz"
45 + },
46 + {
47 + "ordinal": 8,
48 + "name": "stripe_subscription_id",
49 + "type_info": "Text"
50 + }
51 + ],
52 + "parameters": {
53 + "Left": [
54 + "Uuid"
55 + ]
56 + },
57 + "nullable": [
58 + false,
59 + true,
60 + false,
61 + false,
62 + false,
63 + false,
64 + false,
65 + true,
66 + false
67 + ]
68 + },
69 + "hash": "1612ae70defc4a469401a1fff74a1ba595fee86f372fb457b2f1316de9f2bf93"
70 + }
@@ -0,0 +1,95 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n SELECT id AS \"id: VersionId\", item_id AS \"item_id: ItemId\", version_number, changelog,\n file_url, file_size_bytes, file_name, download_count, is_current,\n created_at AS \"created_at: chrono::DateTime<chrono::Utc>\", s3_key,\n scan_status AS \"scan_status: super::FileScanStatus\", label\n FROM versions WHERE item_id = $1 ORDER BY created_at DESC LIMIT $2\n ",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "id: VersionId",
9 + "type_info": "Uuid"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "item_id: ItemId",
14 + "type_info": "Uuid"
15 + },
16 + {
17 + "ordinal": 2,
18 + "name": "version_number",
19 + "type_info": "Varchar"
20 + },
21 + {
22 + "ordinal": 3,
23 + "name": "changelog",
24 + "type_info": "Text"
25 + },
26 + {
27 + "ordinal": 4,
28 + "name": "file_url",
29 + "type_info": "Varchar"
30 + },
31 + {
32 + "ordinal": 5,
33 + "name": "file_size_bytes",
34 + "type_info": "Int8"
35 + },
36 + {
37 + "ordinal": 6,
38 + "name": "file_name",
39 + "type_info": "Varchar"
40 + },
41 + {
42 + "ordinal": 7,
43 + "name": "download_count",
44 + "type_info": "Int4"
45 + },
46 + {
47 + "ordinal": 8,
48 + "name": "is_current",
49 + "type_info": "Bool"
50 + },
51 + {
52 + "ordinal": 9,
53 + "name": "created_at: chrono::DateTime<chrono::Utc>",
54 + "type_info": "Timestamptz"
55 + },
56 + {
57 + "ordinal": 10,
58 + "name": "s3_key",
59 + "type_info": "Varchar"
60 + },
61 + {
62 + "ordinal": 11,
63 + "name": "scan_status: super::FileScanStatus",
64 + "type_info": "Text"
65 + },
66 + {
67 + "ordinal": 12,
68 + "name": "label",
69 + "type_info": "Text"
70 + }
71 + ],
72 + "parameters": {
73 + "Left": [
74 + "Uuid",
75 + "Int8"
76 + ]
77 + },
78 + "nullable": [
79 + false,
80 + false,
81 + false,
82 + true,
83 + true,
84 + true,
85 + true,
86 + false,
87 + false,
88 + false,
89 + true,
90 + false,
91 + true
92 + ]
93 + },
94 + "hash": "174ab0763d37afb6947e4c5acbf5f1d97e5c1b11525f676d96761aa699e6084d"
95 + }
@@ -0,0 +1,22 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n INSERT INTO transactions (\n buyer_id, seller_id, item_id, amount_cents, platform_fee_cents,\n stripe_checkout_session_id, status, completed_at,\n item_title, seller_username, share_contact,\n guest_email, claim_token, download_token\n )\n VALUES ($1, $2, $3, 0, 0, $4, 'completed', NOW(), $5, $6, false, $7, $8, $9)\n ON CONFLICT (guest_email, item_id) WHERE status = 'completed' AND guest_email IS NOT NULL DO NOTHING\n ",
4 + "describe": {
5 + "columns": [],
6 + "parameters": {
7 + "Left": [
8 + "Uuid",
9 + "Uuid",
10 + "Uuid",
11 + "Varchar",
12 + "Varchar",
13 + "Varchar",
14 + "Varchar",
15 + "Uuid",
16 + "Uuid"
17 + ]
18 + },
19 + "nullable": []
20 + },
21 + "hash": "1809ee8c6edfe34df75a8d989f4027fc6de449c76f1fb170159e2a7a0c0f75de"
22 + }
@@ -0,0 +1,29 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n SELECT id AS \"id: TransactionId\", created_at AS \"created_at: chrono::DateTime<chrono::Utc>\"\n FROM transactions\n WHERE buyer_id = $1 AND item_id = $2 AND status = 'pending'\n LIMIT 1\n ",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "id: TransactionId",
9 + "type_info": "Uuid"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "created_at: chrono::DateTime<chrono::Utc>",
14 + "type_info": "Timestamptz"
15 + }
16 + ],
17 + "parameters": {
18 + "Left": [
19 + "Uuid",
20 + "Uuid"
21 + ]
22 + },
23 + "nullable": [
24 + false,
25 + false
26 + ]
27 + },
28 + "hash": "184d0a9b6e48a8da897d7d62ed026c9213cc88ce2c7687df9d851618c31923c9"
29 + }
@@ -0,0 +1,100 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n SELECT s.id AS \"id: SubscriptionId\", s.subscriber_id AS \"subscriber_id: UserId\",\n s.tier_id AS \"tier_id: SubscriptionTierId\", s.project_id AS \"project_id: ProjectId\",\n s.stripe_subscription_id, s.stripe_customer_id,\n s.status AS \"status: super::SubscriptionStatus\",\n s.current_period_start AS \"current_period_start: chrono::DateTime<chrono::Utc>\",\n s.current_period_end AS \"current_period_end: chrono::DateTime<chrono::Utc>\",\n s.canceled_at AS \"canceled_at: chrono::DateTime<chrono::Utc>\",\n s.created_at AS \"created_at: chrono::DateTime<chrono::Utc>\",\n s.updated_at AS \"updated_at: chrono::DateTime<chrono::Utc>\",\n s.item_id AS \"item_id: ItemId\",\n s.paused_at AS \"paused_at: chrono::DateTime<chrono::Utc>\"\n FROM subscriptions s\n WHERE s.project_id IN (SELECT id FROM projects WHERE user_id = $1)\n AND s.status = 'active'\n AND s.paused_at IS NOT NULL\n ",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "id: SubscriptionId",
9 + "type_info": "Uuid"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "subscriber_id: UserId",
14 + "type_info": "Uuid"
15 + },
16 + {
17 + "ordinal": 2,
18 + "name": "tier_id: SubscriptionTierId",
19 + "type_info": "Uuid"
20 + },
21 + {
22 + "ordinal": 3,
23 + "name": "project_id: ProjectId",
24 + "type_info": "Uuid"
25 + },
26 + {
27 + "ordinal": 4,
28 + "name": "stripe_subscription_id",
29 + "type_info": "Text"
30 + },
31 + {
32 + "ordinal": 5,
33 + "name": "stripe_customer_id",
34 + "type_info": "Text"
35 + },
36 + {
37 + "ordinal": 6,
38 + "name": "status: super::SubscriptionStatus",
39 + "type_info": "Varchar"
40 + },
41 + {
42 + "ordinal": 7,
43 + "name": "current_period_start: chrono::DateTime<chrono::Utc>",
44 + "type_info": "Timestamptz"
45 + },
46 + {
47 + "ordinal": 8,
48 + "name": "current_period_end: chrono::DateTime<chrono::Utc>",
49 + "type_info": "Timestamptz"
50 + },
51 + {
52 + "ordinal": 9,
53 + "name": "canceled_at: chrono::DateTime<chrono::Utc>",
54 + "type_info": "Timestamptz"
55 + },
56 + {
57 + "ordinal": 10,
58 + "name": "created_at: chrono::DateTime<chrono::Utc>",
59 + "type_info": "Timestamptz"
60 + },
61 + {
62 + "ordinal": 11,
63 + "name": "updated_at: chrono::DateTime<chrono::Utc>",
64 + "type_info": "Timestamptz"
65 + },
66 + {
67 + "ordinal": 12,
68 + "name": "item_id: ItemId",
69 + "type_info": "Uuid"
70 + },
71 + {
72 + "ordinal": 13,
73 + "name": "paused_at: chrono::DateTime<chrono::Utc>",
74 + "type_info": "Timestamptz"
75 + }
76 + ],
77 + "parameters": {
78 + "Left": [
79 + "Uuid"
80 + ]
81 + },
82 + "nullable": [
83 + false,
84 + false,
85 + false,
86 + true,
87 + false,
88 + false,
89 + false,
90 + true,
91 + true,
92 + true,
93 + false,
94 + false,
95 + true,
96 + true
97 + ]
98 + },
99 + "hash": "1853806ae9a67639dee409c4e4a5e6ac648a5ecc2a8f652283e3b9e4ebe95b1a"
100 + }
@@ -0,0 +1,118 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "SELECT id AS \"id: PromoCodeId\", creator_id AS \"creator_id: UserId\", code,\n code_purpose AS \"code_purpose: super::CodePurpose\",\n discount_type AS \"discount_type: DiscountType\", discount_value, min_price_cents,\n trial_days, item_id AS \"item_id: ItemId\", project_id AS \"project_id: ProjectId\",\n tier_id AS \"tier_id: SubscriptionTierId\", max_uses, use_count,\n expires_at AS \"expires_at: chrono::DateTime<chrono::Utc>\",\n starts_at AS \"starts_at: chrono::DateTime<chrono::Utc>\",\n created_at AS \"created_at: chrono::DateTime<chrono::Utc>\", is_platform_wide\n FROM promo_codes WHERE upper(code) = upper($1) AND code_purpose = 'free_access'",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "id: PromoCodeId",
9 + "type_info": "Uuid"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "creator_id: UserId",
14 + "type_info": "Uuid"
15 + },
16 + {
17 + "ordinal": 2,
18 + "name": "code",
19 + "type_info": "Text"
20 + },
21 + {
22 + "ordinal": 3,
23 + "name": "code_purpose: super::CodePurpose",
24 + "type_info": "Text"
25 + },
26 + {
27 + "ordinal": 4,
28 + "name": "discount_type: DiscountType",
29 + "type_info": "Text"
30 + },
31 + {
32 + "ordinal": 5,
33 + "name": "discount_value",
34 + "type_info": "Int4"
35 + },
36 + {
37 + "ordinal": 6,
38 + "name": "min_price_cents",
39 + "type_info": "Int4"
40 + },
41 + {
42 + "ordinal": 7,
43 + "name": "trial_days",
44 + "type_info": "Int4"
45 + },
46 + {
47 + "ordinal": 8,
48 + "name": "item_id: ItemId",
49 + "type_info": "Uuid"
50 + },
51 + {
52 + "ordinal": 9,
53 + "name": "project_id: ProjectId",
54 + "type_info": "Uuid"
55 + },
56 + {
57 + "ordinal": 10,
58 + "name": "tier_id: SubscriptionTierId",
59 + "type_info": "Uuid"
60 + },
61 + {
62 + "ordinal": 11,
63 + "name": "max_uses",
64 + "type_info": "Int4"
65 + },
66 + {
67 + "ordinal": 12,
68 + "name": "use_count",
69 + "type_info": "Int4"
70 + },
71 + {
72 + "ordinal": 13,
73 + "name": "expires_at: chrono::DateTime<chrono::Utc>",
74 + "type_info": "Timestamptz"
75 + },
76 + {
77 + "ordinal": 14,
78 + "name": "starts_at: chrono::DateTime<chrono::Utc>",
79 + "type_info": "Timestamptz"
80 + },
81 + {
82 + "ordinal": 15,
83 + "name": "created_at: chrono::DateTime<chrono::Utc>",
84 + "type_info": "Timestamptz"
85 + },
86 + {
87 + "ordinal": 16,
88 + "name": "is_platform_wide",
89 + "type_info": "Bool"
90 + }
91 + ],
92 + "parameters": {
93 + "Left": [
94 + "Text"
95 + ]
96 + },
97 + "nullable": [
98 + false,
99 + false,
100 + false,
101 + false,
102 + true,
103 + true,
104 + false,
105 + true,
106 + true,
107 + true,
108 + true,
109 + true,
110 + false,
111 + true,
112 + true,
113 + false,
114 + false
115 + ]
116 + },
117 + "hash": "18fc7a1a5ce8c21081dd02308d7d46087329bd39b597f7996cc3dc68f2a2ed45"
118 + }
@@ -0,0 +1,15 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "DELETE FROM promo_code_redemptions WHERE promo_code_id = $1 AND user_id = $2",
4 + "describe": {
5 + "columns": [],
6 + "parameters": {
7 + "Left": [
8 + "Uuid",
9 + "Uuid"
10 + ]
11 + },
12 + "nullable": []
13 + },
14 + "hash": "1aa6b5ec03a09e60fc164075b3eff7df0329b5242846b1a732fb85388e6de725"
15 + }
@@ -0,0 +1,151 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "\n UPDATE transactions\n SET status = 'completed',\n stripe_payment_intent_id = $2,\n completed_at = NOW(),\n guest_email = $3,\n claim_token = $4,\n buyer_id = NULL\n WHERE stripe_checkout_session_id = $1\n AND status = 'pending'\n RETURNING\n id AS \"id: TransactionId\", buyer_id AS \"buyer_id: UserId\", seller_id AS \"seller_id: UserId\",\n item_id AS \"item_id: ItemId\", amount_cents AS \"amount_cents: Cents\", platform_fee_cents AS \"platform_fee_cents: Cents\",\n currency, status AS \"status: super::TransactionStatus\", stripe_payment_intent_id, stripe_checkout_session_id,\n created_at AS \"created_at: chrono::DateTime<chrono::Utc>\", completed_at AS \"completed_at: chrono::DateTime<chrono::Utc>\",\n item_title, seller_username, share_contact, project_id AS \"project_id: ProjectId\",\n parent_transaction_id AS \"parent_transaction_id: TransactionId\", promo_code_id AS \"promo_code_id: PromoCodeId\",\n guest_email, claim_token AS \"claim_token: ClaimToken\", claimed_by AS \"claimed_by: UserId\",\n download_token AS \"download_token: DownloadToken\"\n ",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "id: TransactionId",
9 + "type_info": "Uuid"
10 + },
11 + {
12 + "ordinal": 1,
13 + "name": "buyer_id: UserId",
14 + "type_info": "Uuid"
15 + },
16 + {
17 + "ordinal": 2,
18 + "name": "seller_id: UserId",
19 + "type_info": "Uuid"
20 + },
21 + {
22 + "ordinal": 3,
23 + "name": "item_id: ItemId",
24 + "type_info": "Uuid"
25 + },
26 + {
27 + "ordinal": 4,
28 + "name": "amount_cents: Cents",
29 + "type_info": "Int4"
30 + },
31 + {
32 + "ordinal": 5,
33 + "name": "platform_fee_cents: Cents",
34 + "type_info": "Int4"
35 + },
36 + {
37 + "ordinal": 6,
38 + "name": "currency",
39 + "type_info": "Varchar"
40 + },
41 + {
42 + "ordinal": 7,
43 + "name": "status: super::TransactionStatus",
44 + "type_info": "Varchar"
45 + },
46 + {
47 + "ordinal": 8,
48 + "name": "stripe_payment_intent_id",
49 + "type_info": "Varchar"
50 + },
51 + {
52 + "ordinal": 9,
53 + "name": "stripe_checkout_session_id",
54 + "type_info": "Varchar"
55 + },
56 + {
57 + "ordinal": 10,
58 + "name": "created_at: chrono::DateTime<chrono::Utc>",
59 + "type_info": "Timestamptz"
60 + },
61 + {
62 + "ordinal": 11,
63 + "name": "completed_at: chrono::DateTime<chrono::Utc>",
64 + "type_info": "Timestamptz"
65 + },
66 + {
67 + "ordinal": 12,
68 + "name": "item_title",
69 + "type_info": "Varchar"
70 + },
71 + {
72 + "ordinal": 13,
73 + "name": "seller_username",
74 + "type_info": "Varchar"
75 + },
76 + {
77 + "ordinal": 14,
78 + "name": "share_contact",
79 + "type_info": "Bool"
80 + },
81 + {
82 + "ordinal": 15,
83 + "name": "project_id: ProjectId",
84 + "type_info": "Uuid"
85 + },
86 + {
87 + "ordinal": 16,
88 + "name": "parent_transaction_id: TransactionId",
89 + "type_info": "Uuid"
90 + },
91 + {
92 + "ordinal": 17,
93 + "name": "promo_code_id: PromoCodeId",
94 + "type_info": "Uuid"
95 + },
96 + {
97 + "ordinal": 18,
98 + "name": "guest_email",
99 + "type_info": "Varchar"
100 + },
101 + {
102 + "ordinal": 19,
103 + "name": "claim_token: ClaimToken",
104 + "type_info": "Uuid"
105 + },
106 + {
107 + "ordinal": 20,
108 + "name": "claimed_by: UserId",
109 + "type_info": "Uuid"
110 + },
111 + {
112 + "ordinal": 21,
113 + "name": "download_token: DownloadToken",
114 + "type_info": "Uuid"
115 + }
116 + ],
117 + "parameters": {
118 + "Left": [
119 + "Text",
120 + "Varchar",
121 + "Varchar",
122 + "Uuid"
123 + ]
124 + },
125 + "nullable": [
126 + false,
127 + true,
128 + true,
129 + true,
130 + false,
131 + false,
132 + false,
133 + false,
134 + true,
135 + true,
136 + false,
137 + true,
138 + true,
139 + true,
140 + false,
141 + true,
142 + true,
143 + true,
144 + true,
145 + true,
146 + true,
147 + true
148 + ]
149 + },
150 + "hash": "1e4b48db02316269e0452632c3f8e14247545c8b539fe03b8eed786f16655e61"
151 + }
@@ -0,0 +1,14 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "UPDATE license_activations SET last_validated_at = NOW() WHERE id = $1",
4 + "describe": {
5 + "columns": [],
6 + "parameters": {
7 + "Left": [
8 + "Uuid"
9 + ]
10 + },
11 + "nullable": []
12 + },
13 + "hash": "20105e1d63a0685ca41ad67e0583f0019e54512afa7e8b7fc2e5dd084b1ec0f2"
14 + }
@@ -0,0 +1,14 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "UPDATE promo_codes SET use_count = GREATEST(0, use_count - 1) WHERE id = $1",
4 + "describe": {
5 + "columns": [],
6 + "parameters": {
7 + "Left": [
8 + "Uuid"
9 + ]
10 + },
11 + "nullable": []
12 + },
13 + "hash": "20a66695cd95325119e71a697a59c5cfe9e6338ae188b9f56f66e936a9fa1a20"
14 + }