backend(docker): embed demo migrations and SQLx offline cache

This commit is contained in:
Marco Allegretti 2026-01-29 00:30:56 +01:00
parent ad3215bfe6
commit 1f355bd19f
40 changed files with 705 additions and 249 deletions

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT \n m.id, m.community_id, m.action_type, m.reason, m.details, m.created_at,\n mod_user.username as moderator_username,\n target_user.username as target_username\n FROM moderation_log m\n LEFT JOIN users mod_user ON m.moderator_id = mod_user.id\n LEFT JOIN users target_user ON m.target_user_id = target_user.id\n WHERE m.community_id = $1\n ORDER BY m.created_at DESC\n LIMIT 50\n ",
"query": "\n SELECT \n m.id, m.community_id, m.action_type, m.reason, m.details, m.created_at,\n mod_user.username as \"moderator_username?\",\n target_user.username as \"target_username?\"\n FROM moderation_log m\n LEFT JOIN users mod_user ON m.moderator_id = mod_user.id\n LEFT JOIN users target_user ON m.target_user_id = target_user.id\n WHERE m.community_id = $1\n ORDER BY m.created_at DESC\n LIMIT 50\n ",
"describe": {
"columns": [
{
@ -35,12 +35,12 @@
},
{
"ordinal": 6,
"name": "moderator_username",
"name": "moderator_username?",
"type_info": "Varchar"
},
{
"ordinal": 7,
"name": "target_username",
"name": "target_username?",
"type_info": "Varchar"
}
],
@ -60,5 +60,5 @@
false
]
},
"hash": "28654edaba50887bd4c7f698e538ed9ec70543b1ba6d0ecc5b675a1040148b6a"
"hash": "1a913c6136f6e2ceeaea65132b17af459ca254baa0049ff5c7cebc3e06e45f91"
}

View file

@ -0,0 +1,20 @@
{
"db_name": "PostgreSQL",
"query": "SELECT id FROM roles WHERE name = 'user' AND community_id IS NULL LIMIT 1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": []
},
"nullable": [
false
]
},
"hash": "1ac1d53eebb241dc0d210845b555d06e3b8167642adeae4901e9d860ce144ac1"
}

View file

@ -0,0 +1,50 @@
{
"db_name": "PostgreSQL",
"query": "SELECT setup_completed, instance_name, platform_mode,\n registration_enabled, registration_mode,\n single_community_id\n FROM instance_settings\n LIMIT 1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "setup_completed",
"type_info": "Bool"
},
{
"ordinal": 1,
"name": "instance_name",
"type_info": "Varchar"
},
{
"ordinal": 2,
"name": "platform_mode",
"type_info": "Varchar"
},
{
"ordinal": 3,
"name": "registration_enabled",
"type_info": "Bool"
},
{
"ordinal": 4,
"name": "registration_mode",
"type_info": "Varchar"
},
{
"ordinal": 5,
"name": "single_community_id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": []
},
"nullable": [
false,
false,
false,
false,
false,
true
]
},
"hash": "200e864fa5778cf58d36d49f94a4006f7d104eb84e6f166b795df0f222ee93d8"
}

View file

@ -1,34 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "SELECT option_id, SUM(credits) as total_credits, COUNT(DISTINCT voter_id) as voter_count\n FROM quadratic_votes WHERE proposal_id = $1 GROUP BY option_id",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "option_id",
"type_info": "Uuid"
},
{
"ordinal": 1,
"name": "total_credits",
"type_info": "Int8"
},
{
"ordinal": 2,
"name": "voter_count",
"type_info": "Int8"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false,
null,
null
]
},
"hash": "222ef714ee6f0d715f09643cff679f1c9d5132051dea4cf1f809f06470ed9b44"
}

View file

@ -1,142 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "SELECT \n ml.id,\n ml.sequence_number,\n ml.community_id,\n ml.actor_user_id,\n u.username AS \"actor_username?\",\n ml.actor_role,\n ml.action_type::text AS \"action_type!\",\n ml.target_type,\n ml.target_id,\n ml.target_snapshot,\n ml.reason,\n ml.rule_reference,\n ml.evidence,\n ml.duration_hours,\n ml.expires_at,\n ml.decision_type,\n ml.vote_proposal_id,\n ml.vote_result,\n ml.previous_hash,\n ml.entry_hash,\n ml.created_at\n FROM moderation_ledger ml\n LEFT JOIN users u ON u.id = ml.actor_user_id\n WHERE ml.id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
},
{
"ordinal": 1,
"name": "sequence_number",
"type_info": "Int8"
},
{
"ordinal": 2,
"name": "community_id",
"type_info": "Uuid"
},
{
"ordinal": 3,
"name": "actor_user_id",
"type_info": "Uuid"
},
{
"ordinal": 4,
"name": "actor_username?",
"type_info": "Varchar"
},
{
"ordinal": 5,
"name": "actor_role",
"type_info": "Text"
},
{
"ordinal": 6,
"name": "action_type!",
"type_info": "Text"
},
{
"ordinal": 7,
"name": "target_type",
"type_info": "Text"
},
{
"ordinal": 8,
"name": "target_id",
"type_info": "Uuid"
},
{
"ordinal": 9,
"name": "target_snapshot",
"type_info": "Jsonb"
},
{
"ordinal": 10,
"name": "reason",
"type_info": "Text"
},
{
"ordinal": 11,
"name": "rule_reference",
"type_info": "Text"
},
{
"ordinal": 12,
"name": "evidence",
"type_info": "Jsonb"
},
{
"ordinal": 13,
"name": "duration_hours",
"type_info": "Int4"
},
{
"ordinal": 14,
"name": "expires_at",
"type_info": "Timestamptz"
},
{
"ordinal": 15,
"name": "decision_type",
"type_info": "Text"
},
{
"ordinal": 16,
"name": "vote_proposal_id",
"type_info": "Uuid"
},
{
"ordinal": 17,
"name": "vote_result",
"type_info": "Jsonb"
},
{
"ordinal": 18,
"name": "previous_hash",
"type_info": "Text"
},
{
"ordinal": 19,
"name": "entry_hash",
"type_info": "Text"
},
{
"ordinal": 20,
"name": "created_at",
"type_info": "Timestamptz"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false,
false,
true,
false,
false,
false,
null,
false,
false,
true,
false,
true,
true,
true,
true,
false,
true,
true,
false,
false,
false
]
},
"hash": "274cc3e62a3bc6659ae9e652d6ac15076f76a5fb7acad44f5e853678cfa2abf3"
}

View file

@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "UPDATE community_plugin_packages SET is_active = false WHERE package_id = $1",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": []
},
"hash": "27ae44fcc7edaabc3c061e476942f2f591c47f09ba55cdcf204dc8880ca9a0ae"
}

View file

@ -0,0 +1,15 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO user_roles (user_id, role_id, community_id, granted_by)\n VALUES ($1, $2, NULL, $1)\n ON CONFLICT (user_id, role_id, community_id) DO NOTHING",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Uuid"
]
},
"nullable": []
},
"hash": "2a7771a4914c74e7a68b2a570a6e1be27e5640856dd18462b97af6c98229fe0c"
}

View file

@ -1,22 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "SELECT COUNT(DISTINCT voter_id) FROM quadratic_votes WHERE proposal_id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "count",
"type_info": "Int8"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
null
]
},
"hash": "2c9bb8a5dca54ef476b2908dfad34371f6f34e4a8500f855d01209d32840f683"
}

View file

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "SELECT is_admin FROM users WHERE id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "is_admin",
"type_info": "Bool"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false
]
},
"hash": "2e4adc1d171a3b451bc213dfdbb58858fb4536f3e4156cfc67e5d62bafc13454"
}

View file

@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "UPDATE delegate_profiles SET total_delegators = GREATEST(0, total_delegators - 1) WHERE user_id = $1",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": []
},
"hash": "403544e4819bc7bcc4ac51c997fb9ec74c3b3fa2c6f2b170ab5b8c8c1d9c65d4"
}

View file

@ -0,0 +1,16 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO user_roles (user_id, role_id, community_id, granted_by)\n VALUES ($1, $2, NULL, $3)\n ON CONFLICT (user_id, role_id, community_id) DO NOTHING",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Uuid"
]
},
"nullable": []
},
"hash": "4c233b67c2fd3cbe3e1212218c7a65999cb87a4df8745cbfe59c6919ab61b683"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT id, voting_method, status as \"status: crate::models::ProposalStatus\" FROM proposals WHERE id = $1",
"query": "SELECT id, community_id, voting_method, status as \"status: crate::models::ProposalStatus\" FROM proposals WHERE id = $1",
"describe": {
"columns": [
{
@ -10,11 +10,16 @@
},
{
"ordinal": 1,
"name": "community_id",
"type_info": "Uuid"
},
{
"ordinal": 2,
"name": "voting_method",
"type_info": "Varchar"
},
{
"ordinal": 2,
"ordinal": 3,
"name": "status: crate::models::ProposalStatus",
"type_info": {
"Custom": {
@ -39,10 +44,11 @@
]
},
"nullable": [
false,
false,
false,
false
]
},
"hash": "b42cab53e091470ad8237271def4b42146a75d30b77aecb4c1ae7ab7a7cc32d3"
"hash": "50d14238cd358babc21436ee5aea2e889f92918625a5ba7a889b0fe01c2f2981"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT author_id, status as \"status: crate::models::ProposalStatus\", title FROM proposals WHERE id = $1",
"query": "SELECT author_id, community_id, status as \"status: crate::models::ProposalStatus\" FROM proposals WHERE id = $1",
"describe": {
"columns": [
{
@ -10,6 +10,11 @@
},
{
"ordinal": 1,
"name": "community_id",
"type_info": "Uuid"
},
{
"ordinal": 2,
"name": "status: crate::models::ProposalStatus",
"type_info": {
"Custom": {
@ -26,11 +31,6 @@
}
}
}
},
{
"ordinal": 2,
"name": "title",
"type_info": "Varchar"
}
],
"parameters": {
@ -44,5 +44,5 @@
false
]
},
"hash": "1fd0e024053913d7598c5cdb19f407cfa7fef149553e18efc9e5149dd77e7f1c"
"hash": "51a5301a129b24bdbe4f8532e9e270585f144852401550b0d1e3c56ace02f7b4"
}

View file

@ -0,0 +1,76 @@
{
"db_name": "PostgreSQL",
"query": "SELECT id, name, version, description, COALESCE(publisher,'') as publisher, source, registry_url, wasm_sha256,\n manifest as \"manifest!: serde_json::Value\", (signature IS NOT NULL) as \"signature_present!: bool\"\n FROM plugin_packages\n WHERE id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
},
{
"ordinal": 1,
"name": "name",
"type_info": "Varchar"
},
{
"ordinal": 2,
"name": "version",
"type_info": "Varchar"
},
{
"ordinal": 3,
"name": "description",
"type_info": "Text"
},
{
"ordinal": 4,
"name": "publisher",
"type_info": "Varchar"
},
{
"ordinal": 5,
"name": "source",
"type_info": "Varchar"
},
{
"ordinal": 6,
"name": "registry_url",
"type_info": "Text"
},
{
"ordinal": 7,
"name": "wasm_sha256",
"type_info": "Varchar"
},
{
"ordinal": 8,
"name": "manifest!: serde_json::Value",
"type_info": "Jsonb"
},
{
"ordinal": 9,
"name": "signature_present!: bool",
"type_info": "Bool"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false,
false,
false,
true,
null,
false,
true,
false,
false,
null
]
},
"hash": "5b90bc37f37536231e0ddf91eaceea7d1ce2ed5f329f163b4c2554e71027ebe7"
}

View file

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "SELECT id FROM communities WHERE id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false
]
},
"hash": "7175f11c4a329af9124e8134186f93600b3afbfd6e05adb0ae1ce8e3e2c8bcc2"
}

View file

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "SELECT EXISTS(SELECT 1 FROM communities WHERE id = $1 AND is_active = true) as \"exists!\"",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "exists!",
"type_info": "Bool"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
null
]
},
"hash": "7501cbb48f6084be8f7f4e4c9e10d0d3fc3ebb14e0e5626f3aea8fe54cbecfbb"
}

View file

@ -0,0 +1,16 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO public_events (community_id, actor_user_id, plugin_name, event_type, payload)\n VALUES ($1, $2, NULL, 'plugin.package_settings_updated', $3)",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Jsonb"
]
},
"nullable": []
},
"hash": "7b93cc6e6f05e4e6b0a182d4264b1024a0787f9b3bb56064213994ba7f760e0c"
}

View file

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "SELECT DISTINCT pp.id\n FROM plugin_packages pp\n JOIN community_plugin_packages cpp ON cpp.package_id = pp.id\n WHERE cpp.community_id = $1\n AND cpp.is_active = true",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false
]
},
"hash": "7cebde48fca3aa37f1aed37998456d337bc88d504e8f626f48e9818675287be4"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT d.id, d.delegator_id, d.delegate_id, u.username as delegate_username,\n d.scope as \"scope: DelegationScope\", d.community_id, d.topic_id, \n d.proposal_id, d.is_active, d.created_at\n FROM delegations d\n JOIN users u ON d.delegate_id = u.id\n WHERE d.delegator_id = $1\n AND ($2 = FALSE OR d.is_active = TRUE)\n AND ($3::uuid IS NULL OR d.community_id = $3)\n ORDER BY d.created_at DESC",
"query": "SELECT d.id, d.delegator_id, d.delegate_id, u.username as delegate_username,\n d.scope as \"scope: DelegationScope\", d.community_id, d.topic_id, \n d.proposal_id, d.weight::float8 as \"weight!\", d.is_active, d.created_at\n FROM delegations d\n JOIN users u ON d.delegate_id = u.id\n WHERE d.delegator_id = $1\n AND ($2 = FALSE OR d.is_active = TRUE)\n AND ($3::uuid IS NULL OR d.community_id = $3)\n ORDER BY d.created_at DESC",
"describe": {
"columns": [
{
@ -57,11 +57,16 @@
},
{
"ordinal": 8,
"name": "weight!",
"type_info": "Float8"
},
{
"ordinal": 9,
"name": "is_active",
"type_info": "Bool"
},
{
"ordinal": 9,
"ordinal": 10,
"name": "created_at",
"type_info": "Timestamptz"
}
@ -82,9 +87,10 @@
true,
true,
true,
null,
false,
false
]
},
"hash": "ce7f978d16864a568b49c47eaa68edcaafb0d293f6d08f5a945bd456c91fd417"
"hash": "8556c20180ee054ae78dec1d4aad739ce8d63de36bfc07dfd28d9d4ef6258a9d"
}

View file

@ -0,0 +1,20 @@
{
"db_name": "PostgreSQL",
"query": "SELECT id FROM roles WHERE name = 'platform_admin' AND community_id IS NULL LIMIT 1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": []
},
"nullable": [
false
]
},
"hash": "8a109220f9c63742d07f4f0893592ff160fc0e5f7b38b87dfcbaa49a65984d7f"
}

View file

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "SELECT id FROM topics WHERE id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false
]
},
"hash": "8bebaad0afb50e4440035422e899b22c8989134563dd11154aa6ce16b29b7969"
}

View file

@ -0,0 +1,18 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO plugin_events (plugin_name, community_id, actor_user_id, event_name, payload)\n VALUES ($1, $2, $3, $4, $5)",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Varchar",
"Uuid",
"Uuid",
"Varchar",
"Jsonb"
]
},
"nullable": []
},
"hash": "8cc59265ecf23980f4d362f2e76cbd129051a38b2c78b0c22eee58ad170ed5b0"
}

View file

@ -0,0 +1,20 @@
{
"db_name": "PostgreSQL",
"query": "SELECT DISTINCT p.name\n FROM plugins p\n JOIN community_plugins cp ON cp.plugin_id = p.id\n WHERE cp.is_active = true AND p.is_active = true",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "name",
"type_info": "Varchar"
}
],
"parameters": {
"Left": []
},
"nullable": [
false
]
},
"hash": "9192b973a627af6c9d097b5a6140eceba6af084b635d536c897236df277ca4b0"
}

View file

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "SELECT DISTINCT pp.id\n FROM plugin_packages pp\n JOIN community_plugin_packages cpp ON cpp.package_id = pp.id\n WHERE cpp.community_id = $1\n AND cpp.is_active = true",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false
]
},
"hash": "934a4bef00af1a1ab6bffdec743aecb6e129056137523b8361ba53da2d5b582e"
}

View file

@ -0,0 +1,34 @@
{
"db_name": "PostgreSQL",
"query": "SELECT voter_id, option_id, credits FROM quadratic_votes WHERE proposal_id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "voter_id",
"type_info": "Uuid"
},
{
"ordinal": 1,
"name": "option_id",
"type_info": "Uuid"
},
{
"ordinal": 2,
"name": "credits",
"type_info": "Int4"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false,
false,
false
]
},
"hash": "9ec7eac0e680a052dd609d4384032d27e31bece1d68166cd0550fbd0f47ee2b3"
}

View file

@ -0,0 +1,28 @@
{
"db_name": "PostgreSQL",
"query": "SELECT slug, name FROM communities WHERE id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "slug",
"type_info": "Varchar"
},
{
"ordinal": 1,
"name": "name",
"type_info": "Varchar"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false,
false
]
},
"hash": "9fd49c98ae0eeba356386141d53a0d3010529c2e2e4c8b9345c12001e4159be9"
}

View file

@ -0,0 +1,18 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO public_events (community_id, actor_user_id, plugin_name, event_type, payload)\n VALUES ($1, $2, $3, $4, $5)",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Varchar",
"Varchar",
"Jsonb"
]
},
"nullable": []
},
"hash": "ab8f6f342d035e52321fae9599ae72f5a3a83fa18a62d89345df9bb0e7664b8a"
}

View file

@ -0,0 +1,40 @@
{
"db_name": "PostgreSQL",
"query": "SELECT id, username, email, display_name FROM users WHERE id = $1 AND is_active = true",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
},
{
"ordinal": 1,
"name": "username",
"type_info": "Varchar"
},
{
"ordinal": 2,
"name": "email",
"type_info": "Varchar"
},
{
"ordinal": 3,
"name": "display_name",
"type_info": "Varchar"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false,
false,
false,
true
]
},
"hash": "ae9120b3ce852027ed5115cb22de26a900eee66214e76d963409e26cdf452f5d"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO delegations (delegator_id, delegate_id, scope, community_id, topic_id, proposal_id)\n VALUES ($1, $2, $3::delegation_scope, $4, $5, $6)\n RETURNING id, delegator_id, delegate_id, scope as \"scope: DelegationScope\", \n community_id, topic_id, proposal_id, is_active, created_at",
"query": "INSERT INTO delegations (delegator_id, delegate_id, scope, community_id, topic_id, proposal_id, weight)\n VALUES ($1, $2, $3::delegation_scope, $4, $5, $6, ($7::float8)::numeric)\n RETURNING id, delegator_id, delegate_id, scope as \"scope: DelegationScope\", \n community_id, topic_id, proposal_id, weight::float8 as \"weight!\", is_active, created_at",
"describe": {
"columns": [
{
@ -52,11 +52,16 @@
},
{
"ordinal": 7,
"name": "weight!",
"type_info": "Float8"
},
{
"ordinal": 8,
"name": "is_active",
"type_info": "Bool"
},
{
"ordinal": 8,
"ordinal": 9,
"name": "created_at",
"type_info": "Timestamptz"
}
@ -80,7 +85,8 @@
},
"Uuid",
"Uuid",
"Uuid"
"Uuid",
"Float8"
]
},
"nullable": [
@ -91,9 +97,10 @@
true,
true,
true,
null,
false,
false
]
},
"hash": "7b06af69ee03943c64083e5bc94cb6dbd6f5017ad44546dff7582c31345edc51"
"hash": "b5c36e2f70e6c7d5f501373d11b52254cb3c898866401e2e757071d81bfe53b0"
}

View file

@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "UPDATE delegate_profiles\n SET total_delegators = (\n SELECT COUNT(*)::int\n FROM delegations\n WHERE delegate_id = $1 AND is_active = TRUE\n )\n WHERE user_id = $1",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": []
},
"hash": "ba3baaed12e441979d05df98b3fce74718552f5359645768d6a2985d5964a089"
}

View file

@ -0,0 +1,17 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO public_events (community_id, actor_user_id, plugin_name, event_type, payload)\n VALUES ($1, $2, NULL, $3, $4)",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Varchar",
"Jsonb"
]
},
"nullable": []
},
"hash": "c25b3ec6589b42b6dffc4774b90e7bbbd9367bf56371e5cb82467c0ef696cf9e"
}

View file

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "SELECT id FROM proposals WHERE id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false
]
},
"hash": "cb1ce2fb0e93ef77a4e730db2481955d7f79b3f634228febef8ab0483f803ee0"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT dp.user_id, u.username, dp.display_name, dp.bio, \n dp.accepting_delegations, dp.delegation_policy,\n dp.total_delegators, dp.total_votes_cast\n FROM delegate_profiles dp\n JOIN users u ON dp.user_id = u.id\n WHERE dp.accepting_delegations = TRUE\n ORDER BY dp.total_delegators DESC\n LIMIT 50",
"query": "SELECT u.id as user_id,\n u.username,\n dp.display_name,\n dp.bio,\n COALESCE(dp.accepting_delegations, TRUE) as \"accepting_delegations!\",\n dp.delegation_policy,\n COALESCE(dp.total_delegators, 0) as \"total_delegators!\",\n COALESCE(dp.total_votes_cast, 0) as \"total_votes_cast!\"\n FROM users u\n LEFT JOIN delegate_profiles dp ON dp.user_id = u.id\n WHERE COALESCE(dp.accepting_delegations, TRUE) = TRUE\n ORDER BY COALESCE(dp.total_delegators, 0) DESC\n LIMIT 50",
"describe": {
"columns": [
{
@ -25,7 +25,7 @@
},
{
"ordinal": 4,
"name": "accepting_delegations",
"name": "accepting_delegations!",
"type_info": "Bool"
},
{
@ -35,12 +35,12 @@
},
{
"ordinal": 6,
"name": "total_delegators",
"name": "total_delegators!",
"type_info": "Int4"
},
{
"ordinal": 7,
"name": "total_votes_cast",
"name": "total_votes_cast!",
"type_info": "Int4"
}
],
@ -52,11 +52,11 @@
false,
true,
true,
false,
null,
true,
false,
false
null,
null
]
},
"hash": "522c64c31796d1d85b4ce6a6cbac86d0b440c2eb54d14fd700fd005848e4b146"
"hash": "d007217c665a2e67a43699fde6ae589a578afd1ac1300eda6dae81b143426e24"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO delegate_profiles (user_id, total_delegators)\n VALUES ($1, 1)\n ON CONFLICT (user_id) DO UPDATE SET total_delegators = delegate_profiles.total_delegators + 1",
"query": "INSERT INTO delegate_profiles (user_id, total_delegators)\n VALUES ($1, 0)\n ON CONFLICT (user_id) DO NOTHING",
"describe": {
"columns": [],
"parameters": {
@ -10,5 +10,5 @@
},
"nullable": []
},
"hash": "aadb91fe11c7e3106062a2055b0196ca12ed20e40513bc14f11f4a8bd5623a3f"
"hash": "dd62cd6e680730b179e470ccf536c4a457f0843963a057304732b3520d33d216"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT author_id, status as \"status: crate::models::ProposalStatus\" FROM proposals WHERE id = $1",
"query": "SELECT author_id, community_id, status as \"status: crate::models::ProposalStatus\", title FROM proposals WHERE id = $1",
"describe": {
"columns": [
{
@ -10,6 +10,11 @@
},
{
"ordinal": 1,
"name": "community_id",
"type_info": "Uuid"
},
{
"ordinal": 2,
"name": "status: crate::models::ProposalStatus",
"type_info": {
"Custom": {
@ -26,6 +31,11 @@
}
}
}
},
{
"ordinal": 3,
"name": "title",
"type_info": "Varchar"
}
],
"parameters": {
@ -34,9 +44,11 @@
]
},
"nullable": [
false,
false,
false,
false
]
},
"hash": "4f6d0f4d874780e2729f6e6f2e50ba35dddf8cfaa1de0f4213e2ca70aad2d3cc"
"hash": "df07e9600291df3781819e6cf35eb06266f12e4aba6d1368f763b84a197dda62"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT d.id, d.delegator_id, d.delegate_id, u.username as delegator_username,\n d.scope as \"scope: DelegationScope\", d.community_id, d.topic_id, \n d.proposal_id, d.is_active, d.created_at\n FROM delegations d\n JOIN users u ON d.delegator_id = u.id\n WHERE d.delegate_id = $1 AND d.is_active = TRUE\n ORDER BY d.created_at DESC",
"query": "SELECT d.id, d.delegator_id, d.delegate_id, u.username as delegator_username,\n d.scope as \"scope: DelegationScope\", d.community_id, d.topic_id, \n d.proposal_id, d.weight::float8 as \"weight!\", d.is_active, d.created_at\n FROM delegations d\n JOIN users u ON d.delegator_id = u.id\n WHERE d.delegate_id = $1 AND d.is_active = TRUE\n ORDER BY d.created_at DESC",
"describe": {
"columns": [
{
@ -57,11 +57,16 @@
},
{
"ordinal": 8,
"name": "weight!",
"type_info": "Float8"
},
{
"ordinal": 9,
"name": "is_active",
"type_info": "Bool"
},
{
"ordinal": 9,
"ordinal": 10,
"name": "created_at",
"type_info": "Timestamptz"
}
@ -80,9 +85,10 @@
true,
true,
true,
null,
false,
false
]
},
"hash": "2b38c2a93dda00a2ccd0ffe3d2cd83b9cf41d444b6f09b211a57dd6689a9e27e"
"hash": "e19f4b2d1eea5b4072b35ed1bb8203903a956d66a987d7f2164f3c93b43cfa8b"
}

View file

@ -0,0 +1,15 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO user_roles (user_id, role_id, community_id, granted_by)\n VALUES ($1, $2, NULL, $1)\n ON CONFLICT (user_id, role_id, community_id) DO NOTHING",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Uuid"
]
},
"nullable": []
},
"hash": "e23f0686c022f9afb03ea58547093363cd7ff183556b76dd58cf45b1ca75f791"
}

View file

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "SELECT settings as \"settings!: serde_json::Value\" FROM communities WHERE id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "settings!: serde_json::Value",
"type_info": "Jsonb"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false
]
},
"hash": "eb6a26de0c435cd43c5d6f9d05cb403d10f2f74f77f087e063bb664d614554cb"
}

View file

@ -0,0 +1,16 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO user_roles (user_id, role_id, community_id, granted_by)\n VALUES ($1, $2, NULL, $3)\n ON CONFLICT (user_id, role_id, community_id) DO NOTHING",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Uuid"
]
},
"nullable": []
},
"hash": "fc585d0e71cb2707414fba262cd8347b30962772c647c5a1e1e2bc0c7d0843ed"
}

View file

@ -1,8 +1,10 @@
# Likwid Backend Dockerfile
FROM rust:1.75-slim-bookworm as builder
FROM rust:1.88-slim-bookworm as builder
WORKDIR /app
ENV SQLX_OFFLINE=true
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
@ -20,6 +22,12 @@ RUN rm -rf src
# Copy source code
COPY src ./src
COPY migrations ./migrations
COPY migrations_demo ./migrations_demo
COPY .sqlx ./.sqlx
# Optionally exclude demo seed migration from the compiled binary (enterprise-safe prod builds)
ARG INCLUDE_DEMO_SEED=false
RUN if [ "$INCLUDE_DEMO_SEED" != "true" ]; then rm -f ./migrations_demo/20260127150000_demo_seed_data.sql; fi
# Build the actual binary
RUN touch src/main.rs && cargo build --release