diff --git a/.sqlx/query-04345d9c23430267f755b1420520df91bd403524fd60ba1a94e3a239ea70cae7.json b/.sqlx/query-04345d9c23430267f755b1420520df91bd403524fd60ba1a94e3a239ea70cae7.json
deleted file mode 100644
index 1c31aaa7..00000000
--- a/.sqlx/query-04345d9c23430267f755b1420520df91bd403524fd60ba1a94e3a239ea70cae7.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE mods\n SET source_url = $1\n WHERE (id = $2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Varchar",
- "Int8"
- ]
- },
- "nullable": []
- },
- "hash": "04345d9c23430267f755b1420520df91bd403524fd60ba1a94e3a239ea70cae7"
-}
diff --git a/.sqlx/query-268af672e8e475885c18da9edd81bac19f3a78a8a462bf9bb2dbe0a72c2f1ff7.json b/.sqlx/query-268af672e8e475885c18da9edd81bac19f3a78a8a462bf9bb2dbe0a72c2f1ff7.json
new file mode 100644
index 00000000..aa5b4f46
--- /dev/null
+++ b/.sqlx/query-268af672e8e475885c18da9edd81bac19f3a78a8a462bf9bb2dbe0a72c2f1ff7.json
@@ -0,0 +1,16 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO mods_links (\n joining_mod_id, joining_platform_id, url\n )\n SELECT * FROM UNNEST($1::bigint[], $2::int[], $3::varchar[])\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Int8Array",
+ "Int4Array",
+ "VarcharArray"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "268af672e8e475885c18da9edd81bac19f3a78a8a462bf9bb2dbe0a72c2f1ff7"
+}
diff --git a/.sqlx/query-2b8dafe9c3df9fd25235a13868e8e7607decfbe96a413cc576919a1fb510f269.json b/.sqlx/query-2b8dafe9c3df9fd25235a13868e8e7607decfbe96a413cc576919a1fb510f269.json
deleted file mode 100644
index c011c5b0..00000000
--- a/.sqlx/query-2b8dafe9c3df9fd25235a13868e8e7607decfbe96a413cc576919a1fb510f269.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE mods\n SET discord_url = $1\n WHERE (id = $2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Varchar",
- "Int8"
- ]
- },
- "nullable": []
- },
- "hash": "2b8dafe9c3df9fd25235a13868e8e7607decfbe96a413cc576919a1fb510f269"
-}
diff --git a/.sqlx/query-4567790f0dc98ff20b596a33161d1f6ac8af73da67fe8c54192724626c6bf670.json b/.sqlx/query-4567790f0dc98ff20b596a33161d1f6ac8af73da67fe8c54192724626c6bf670.json
deleted file mode 100644
index 7893cca8..00000000
--- a/.sqlx/query-4567790f0dc98ff20b596a33161d1f6ac8af73da67fe8c54192724626c6bf670.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM mods_donations\n WHERE joining_mod_id = $1\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Int8"
- ]
- },
- "nullable": []
- },
- "hash": "4567790f0dc98ff20b596a33161d1f6ac8af73da67fe8c54192724626c6bf670"
-}
diff --git a/.sqlx/query-473db826b691ae1131990ef0927cfe5b63d48829dd41edb7def22248d5668ac7.json b/.sqlx/query-473db826b691ae1131990ef0927cfe5b63d48829dd41edb7def22248d5668ac7.json
deleted file mode 100644
index de301423..00000000
--- a/.sqlx/query-473db826b691ae1131990ef0927cfe5b63d48829dd41edb7def22248d5668ac7.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO mods_donations (\n joining_mod_id, joining_platform_id, url\n )\n SELECT * FROM UNNEST($1::bigint[], $2::int[], $3::varchar[])\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Int8Array",
- "Int4Array",
- "VarcharArray"
- ]
- },
- "nullable": []
- },
- "hash": "473db826b691ae1131990ef0927cfe5b63d48829dd41edb7def22248d5668ac7"
-}
diff --git a/.sqlx/query-4d0e2d4345aeab5ee7eed847c03c913073eeb43caaf299cddcac6e41351661fd.json b/.sqlx/query-4d0e2d4345aeab5ee7eed847c03c913073eeb43caaf299cddcac6e41351661fd.json
new file mode 100644
index 00000000..801c4326
--- /dev/null
+++ b/.sqlx/query-4d0e2d4345aeab5ee7eed847c03c913073eeb43caaf299cddcac6e41351661fd.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n DELETE FROM mods_links\n WHERE joining_mod_id = $1 AND joining_platform_id IN (\n SELECT id FROM link_platforms WHERE name = ANY($2)\n )\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Int8",
+ "TextArray"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "4d0e2d4345aeab5ee7eed847c03c913073eeb43caaf299cddcac6e41351661fd"
+}
diff --git a/.sqlx/query-5db4b2678406a9977c1e37409920804e0225181befe8b784dea48e37e30fedcc.json b/.sqlx/query-5db4b2678406a9977c1e37409920804e0225181befe8b784dea48e37e30fedcc.json
new file mode 100644
index 00000000..0dcd2037
--- /dev/null
+++ b/.sqlx/query-5db4b2678406a9977c1e37409920804e0225181befe8b784dea48e37e30fedcc.json
@@ -0,0 +1,16 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)\n VALUES ($1, $2, $3)\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Int8",
+ "Int4",
+ "Varchar"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "5db4b2678406a9977c1e37409920804e0225181befe8b784dea48e37e30fedcc"
+}
diff --git a/.sqlx/query-07ebc9dc82cd012cd4f5880b1eb3d82602c195a3e3ddd557103ee037aa6dad1c.json b/.sqlx/query-5e7146bc9dc9145cf3d01875ee599ada89e28c63fd10b3f23680d6660d0e57a2.json
similarity index 55%
rename from .sqlx/query-07ebc9dc82cd012cd4f5880b1eb3d82602c195a3e3ddd557103ee037aa6dad1c.json
rename to .sqlx/query-5e7146bc9dc9145cf3d01875ee599ada89e28c63fd10b3f23680d6660d0e57a2.json
index 3f89936b..689e6395 100644
--- a/.sqlx/query-07ebc9dc82cd012cd4f5880b1eb3d82602c195a3e3ddd557103ee037aa6dad1c.json
+++ b/.sqlx/query-5e7146bc9dc9145cf3d01875ee599ada89e28c63fd10b3f23680d6660d0e57a2.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n INSERT INTO mods_donations (joining_mod_id, joining_platform_id, url)\n VALUES ($1, $2, $3)\n ",
+ "query": "\n INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)\n VALUES ($1, $2, $3)\n ",
"describe": {
"columns": [],
"parameters": {
@@ -12,5 +12,5 @@
},
"nullable": []
},
- "hash": "07ebc9dc82cd012cd4f5880b1eb3d82602c195a3e3ddd557103ee037aa6dad1c"
+ "hash": "5e7146bc9dc9145cf3d01875ee599ada89e28c63fd10b3f23680d6660d0e57a2"
}
diff --git a/.sqlx/query-83d428e1c07d16e356ef26bdf1d707940b1683b5f631ded1f6674a081453d67b.json b/.sqlx/query-83d428e1c07d16e356ef26bdf1d707940b1683b5f631ded1f6674a081453d67b.json
deleted file mode 100644
index 41542fd8..00000000
--- a/.sqlx/query-83d428e1c07d16e356ef26bdf1d707940b1683b5f631ded1f6674a081453d67b.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE mods\n SET source_url = $1\n WHERE (id = $2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Varchar",
- "Int8"
- ]
- },
- "nullable": []
- },
- "hash": "83d428e1c07d16e356ef26bdf1d707940b1683b5f631ded1f6674a081453d67b"
-}
diff --git a/.sqlx/query-fefb4f07a0f0c0cf74e554d120f8707d698fc8b4dbb66d2830f4ec0229bc1019.json b/.sqlx/query-83dc16cc7a0f4507e308a06f4924065e4ea25de0210be222ceae8eb645f888e3.json
similarity index 58%
rename from .sqlx/query-fefb4f07a0f0c0cf74e554d120f8707d698fc8b4dbb66d2830f4ec0229bc1019.json
rename to .sqlx/query-83dc16cc7a0f4507e308a06f4924065e4ea25de0210be222ceae8eb645f888e3.json
index e2b9c106..015a47d4 100644
--- a/.sqlx/query-fefb4f07a0f0c0cf74e554d120f8707d698fc8b4dbb66d2830f4ec0229bc1019.json
+++ b/.sqlx/query-83dc16cc7a0f4507e308a06f4924065e4ea25de0210be222ceae8eb645f888e3.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n INSERT INTO mods (\n id, team_id, title, description, body,\n published, downloads, icon_url, issues_url,\n source_url, wiki_url, status, requested_status, discord_url,\n license_url, license,\n slug, color, monetization_status\n )\n VALUES (\n $1, $2, $3, $4, $5,\n $6, $7, $8, $9,\n $10, $11, $12, $13, $14,\n $15, $16, \n LOWER($17), $18, $19\n )\n ",
+ "query": "\n INSERT INTO mods (\n id, team_id, title, description, body,\n published, downloads, icon_url, status, requested_status,\n license_url, license,\n slug, color, monetization_status\n )\n VALUES (\n $1, $2, $3, $4, $5, $6, \n $7, $8, $9, $10, \n $11, $12, \n LOWER($13), $14, $15\n )\n ",
"describe": {
"columns": [],
"parameters": {
@@ -17,10 +17,6 @@
"Varchar",
"Varchar",
"Varchar",
- "Varchar",
- "Varchar",
- "Varchar",
- "Varchar",
"Text",
"Int4",
"Varchar"
@@ -28,5 +24,5 @@
},
"nullable": []
},
- "hash": "fefb4f07a0f0c0cf74e554d120f8707d698fc8b4dbb66d2830f4ec0229bc1019"
+ "hash": "83dc16cc7a0f4507e308a06f4924065e4ea25de0210be222ceae8eb645f888e3"
}
diff --git a/.sqlx/query-872374755deb5d68092dff9fcbc355da7c5c9cea4b471e79b17c4a9cfd6f9954.json b/.sqlx/query-872374755deb5d68092dff9fcbc355da7c5c9cea4b471e79b17c4a9cfd6f9954.json
new file mode 100644
index 00000000..1dac397e
--- /dev/null
+++ b/.sqlx/query-872374755deb5d68092dff9fcbc355da7c5c9cea4b471e79b17c4a9cfd6f9954.json
@@ -0,0 +1,14 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n DELETE FROM mods_links\n WHERE joining_mod_id = $1\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Int8"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "872374755deb5d68092dff9fcbc355da7c5c9cea4b471e79b17c4a9cfd6f9954"
+}
diff --git a/.sqlx/query-d8946603f5894d2b18ad66f7747134234cd497c928fbbce6f8adef4fe3f3b1df.json b/.sqlx/query-877927a1310a1c835e1ca24b6995b7d95c62664629d7a59fbfe1404b4aff14d6.json
similarity index 66%
rename from .sqlx/query-d8946603f5894d2b18ad66f7747134234cd497c928fbbce6f8adef4fe3f3b1df.json
rename to .sqlx/query-877927a1310a1c835e1ca24b6995b7d95c62664629d7a59fbfe1404b4aff14d6.json
index 1634f3f1..af82884f 100644
--- a/.sqlx/query-d8946603f5894d2b18ad66f7747134234cd497c928fbbce6f8adef4fe3f3b1df.json
+++ b/.sqlx/query-877927a1310a1c835e1ca24b6995b7d95c62664629d7a59fbfe1404b4aff14d6.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n WITH version_fields_cte AS (\n SELECT mod_id, version_id, field_id, int_value, enum_value, string_value\n FROM mods m\n INNER JOIN versions v ON m.id = v.mod_id\n INNER JOIN version_fields vf ON v.id = vf.version_id\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n ),\n\t\t\t\tversion_fields_json AS (\n\t\t\t\t\tSELECT DISTINCT mod_id,\n JSONB_AGG( \n DISTINCT jsonb_build_object('version_id', version_id, 'field_id', field_id, 'int_value', int_value, 'enum_value', enum_value, 'string_value', string_value)\n ) version_fields_json\n FROM version_fields_cte\n GROUP BY mod_id\n\t\t\t\t),\n\t\t\t\tloader_fields_cte AS (\n\t\t\t\t\tSELECT DISTINCT vf.mod_id, vf.version_id, lf.*, l.loader\n\t\t\t\t\tFROM loader_fields lf\n INNER JOIN version_fields_cte vf ON lf.id = vf.field_id\n\t\t\t\t\tLEFT JOIN loaders_versions lv ON vf.version_id = lv.version_id\n\t\t\t\t\tLEFT JOIN loaders l ON lv.loader_id = l.id\n GROUP BY vf.mod_id, vf.version_id, lf.enum_type, lf.id, l.loader\n\t\t\t\t),\n loader_fields_json AS (\n SELECT DISTINCT mod_id,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'version_id', lf.version_id,\n 'lf_id', id, 'loader_name', loader, 'field', field, 'field_type', field_type, 'enum_type', enum_type, 'min_val', min_val, 'max_val', max_val, 'optional', optional\n )\n ) filter (where lf.id is not null) loader_fields_json\n FROM loader_fields_cte lf\n GROUP BY mod_id\n ),\n loader_field_enum_values_json AS (\n SELECT DISTINCT mod_id,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'id', lfev.id, 'enum_id', lfev.enum_id, 'value', lfev.value, 'ordering', lfev.ordering, 'created', lfev.created, 'metadata', lfev.metadata\n ) \n ) filter (where lfev.id is not null) loader_field_enum_values_json\n FROM loader_field_enum_values lfev\n INNER JOIN loader_fields_cte lf on lf.enum_type = lfev.enum_id\n GROUP BY mod_id\n ),\n versions_cte AS (\n SELECT DISTINCT mod_id, v.id as id, date_published\n FROM mods m\n INNER JOIN versions v ON m.id = v.mod_id AND v.status = ANY($3)\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n ),\n versions_json AS (\n SELECT DISTINCT mod_id,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'id', id, 'date_published', date_published\n )\n ) filter (where id is not null) versions_json\n FROM versions_cte\n GROUP BY mod_id\n ),\n loaders_cte AS (\n SELECT DISTINCT mod_id, l.id as id, l.loader\n FROM versions_cte\n INNER JOIN loaders_versions lv ON versions_cte.id = lv.version_id\n INNER JOIN loaders l ON lv.loader_id = l.id \n ),\n mods_gallery_json AS (\n SELECT DISTINCT mod_id,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'image_url', mg.image_url, 'featured', mg.featured, 'title', mg.title, 'description', mg.description, 'created', mg.created, 'ordering', mg.ordering\n )\n ) filter (where image_url is not null) mods_gallery_json\n FROM mods_gallery mg\n INNER JOIN mods m ON mg.mod_id = m.id\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n GROUP BY mod_id\n ),\n donations_json AS (\n SELECT DISTINCT joining_mod_id as mod_id,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'platform_id', md.joining_platform_id, 'platform_short', dp.short, 'platform_name', dp.name,'url', md.url\n )\n ) filter (where md.joining_platform_id is not null) donations_json\n FROM mods_donations md\n INNER JOIN mods m ON md.joining_mod_id = m.id AND m.id = ANY($1) OR m.slug = ANY($2)\n INNER JOIN donation_platforms dp ON md.joining_platform_id = dp.id\n GROUP BY mod_id\n )\n \n SELECT m.id id, m.title title, m.description description, m.downloads downloads, m.follows follows,\n m.icon_url icon_url, m.body body, m.published published,\n m.updated updated, m.approved approved, m.queued, m.status status, m.requested_status requested_status,\n m.issues_url issues_url, m.source_url source_url, m.wiki_url wiki_url, m.discord_url discord_url, m.license_url license_url,\n m.team_id team_id, m.organization_id organization_id, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,\n m.webhook_sent, m.color,\n t.id thread_id, m.monetization_status monetization_status,\n ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null) loaders,\n ARRAY_AGG(DISTINCT pt.name) filter (where pt.name is not null) project_types,\n ARRAY_AGG(DISTINCT g.slug) filter (where g.slug is not null) games,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,\n v.versions_json versions,\n mg.mods_gallery_json gallery,\n md.donations_json donations,\n vf.version_fields_json version_fields,\n lf.loader_fields_json loader_fields,\n lfev.loader_field_enum_values_json loader_field_enum_values\n FROM mods m \n INNER JOIN threads t ON t.mod_id = m.id\n LEFT JOIN mods_gallery_json mg ON mg.mod_id = m.id\n LEFT JOIN donations_json md ON md.mod_id = m.id\n LEFT JOIN mods_categories mc ON mc.joining_mod_id = m.id\n LEFT JOIN categories c ON mc.joining_category_id = c.id\n LEFT JOIN versions_json v ON v.mod_id = m.id\n LEFT JOIN loaders_cte l on l.mod_id = m.id\n LEFT JOIN loaders_project_types lpt ON lpt.joining_loader_id = l.id\n LEFT JOIN project_types pt ON pt.id = lpt.joining_project_type_id\n LEFT JOIN loaders_project_types_games lptg ON lptg.loader_id = l.id AND lptg.project_type_id = pt.id\n LEFT JOIN games g ON lptg.game_id = g.id\n LEFT OUTER JOIN version_fields_json vf ON m.id = vf.mod_id\n LEFT OUTER JOIN loader_fields_json lf ON m.id = lf.mod_id\n LEFT OUTER JOIN loader_field_enum_values_json lfev ON m.id = lfev.mod_id\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n GROUP BY t.id, m.id, version_fields_json, loader_fields_json, loader_field_enum_values_json, versions_json, mods_gallery_json, donations_json;\n ",
+ "query": "\n WITH version_fields_cte AS (\n SELECT mod_id, version_id, field_id, int_value, enum_value, string_value\n FROM mods m\n INNER JOIN versions v ON m.id = v.mod_id\n INNER JOIN version_fields vf ON v.id = vf.version_id\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n ),\n\t\t\t\tversion_fields_json AS (\n\t\t\t\t\tSELECT DISTINCT mod_id,\n JSONB_AGG( \n DISTINCT jsonb_build_object('version_id', version_id, 'field_id', field_id, 'int_value', int_value, 'enum_value', enum_value, 'string_value', string_value)\n ) version_fields_json\n FROM version_fields_cte\n GROUP BY mod_id\n\t\t\t\t),\n\t\t\t\tloader_fields_cte AS (\n\t\t\t\t\tSELECT DISTINCT vf.mod_id, vf.version_id, lf.*, l.loader\n\t\t\t\t\tFROM loader_fields lf\n INNER JOIN version_fields_cte vf ON lf.id = vf.field_id\n\t\t\t\t\tLEFT JOIN loaders_versions lv ON vf.version_id = lv.version_id\n\t\t\t\t\tLEFT JOIN loaders l ON lv.loader_id = l.id\n GROUP BY vf.mod_id, vf.version_id, lf.enum_type, lf.id, l.loader\n\t\t\t\t),\n loader_fields_json AS (\n SELECT DISTINCT mod_id,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'version_id', lf.version_id,\n 'lf_id', id, 'loader_name', loader, 'field', field, 'field_type', field_type, 'enum_type', enum_type, 'min_val', min_val, 'max_val', max_val, 'optional', optional\n )\n ) filter (where lf.id is not null) loader_fields_json\n FROM loader_fields_cte lf\n GROUP BY mod_id\n ),\n loader_field_enum_values_json AS (\n SELECT DISTINCT mod_id,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'id', lfev.id, 'enum_id', lfev.enum_id, 'value', lfev.value, 'ordering', lfev.ordering, 'created', lfev.created, 'metadata', lfev.metadata\n ) \n ) filter (where lfev.id is not null) loader_field_enum_values_json\n FROM loader_field_enum_values lfev\n INNER JOIN loader_fields_cte lf on lf.enum_type = lfev.enum_id\n GROUP BY mod_id\n ),\n versions_cte AS (\n SELECT DISTINCT mod_id, v.id as id, date_published\n FROM mods m\n INNER JOIN versions v ON m.id = v.mod_id AND v.status = ANY($3)\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n ),\n versions_json AS (\n SELECT DISTINCT mod_id,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'id', id, 'date_published', date_published\n )\n ) filter (where id is not null) versions_json\n FROM versions_cte\n GROUP BY mod_id\n ),\n loaders_cte AS (\n SELECT DISTINCT mod_id, l.id as id, l.loader\n FROM versions_cte\n INNER JOIN loaders_versions lv ON versions_cte.id = lv.version_id\n INNER JOIN loaders l ON lv.loader_id = l.id \n ),\n mods_gallery_json AS (\n SELECT DISTINCT mod_id,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'image_url', mg.image_url, 'featured', mg.featured, 'title', mg.title, 'description', mg.description, 'created', mg.created, 'ordering', mg.ordering\n )\n ) filter (where image_url is not null) mods_gallery_json\n FROM mods_gallery mg\n INNER JOIN mods m ON mg.mod_id = m.id\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n GROUP BY mod_id\n ),\n links_json AS (\n SELECT DISTINCT joining_mod_id as mod_id,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'platform_id', ml.joining_platform_id, 'platform_name', lp.name,'url', ml.url, 'donation', lp.donation\n )\n ) filter (where ml.joining_platform_id is not null) links_json\n FROM mods_links ml\n INNER JOIN mods m ON ml.joining_mod_id = m.id AND m.id = ANY($1) OR m.slug = ANY($2)\n INNER JOIN link_platforms lp ON ml.joining_platform_id = lp.id\n GROUP BY mod_id\n )\n \n SELECT m.id id, m.title title, m.description description, m.downloads downloads, m.follows follows,\n m.icon_url icon_url, m.body body, m.published published,\n m.updated updated, m.approved approved, m.queued, m.status status, m.requested_status requested_status,\n m.license_url license_url,\n m.team_id team_id, m.organization_id organization_id, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,\n m.webhook_sent, m.color,\n t.id thread_id, m.monetization_status monetization_status,\n ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null) loaders,\n ARRAY_AGG(DISTINCT pt.name) filter (where pt.name is not null) project_types,\n ARRAY_AGG(DISTINCT g.slug) filter (where g.slug is not null) games,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,\n v.versions_json versions,\n mg.mods_gallery_json gallery,\n ml.links_json links,\n vf.version_fields_json version_fields,\n lf.loader_fields_json loader_fields,\n lfev.loader_field_enum_values_json loader_field_enum_values\n FROM mods m \n INNER JOIN threads t ON t.mod_id = m.id\n LEFT JOIN mods_gallery_json mg ON mg.mod_id = m.id\n LEFT JOIN links_json ml ON ml.mod_id = m.id\n LEFT JOIN mods_categories mc ON mc.joining_mod_id = m.id\n LEFT JOIN categories c ON mc.joining_category_id = c.id\n LEFT JOIN versions_json v ON v.mod_id = m.id\n LEFT JOIN loaders_cte l on l.mod_id = m.id\n LEFT JOIN loaders_project_types lpt ON lpt.joining_loader_id = l.id\n LEFT JOIN project_types pt ON pt.id = lpt.joining_project_type_id\n LEFT JOIN loaders_project_types_games lptg ON lptg.loader_id = l.id AND lptg.project_type_id = pt.id\n LEFT JOIN games g ON lptg.game_id = g.id\n LEFT OUTER JOIN version_fields_json vf ON m.id = vf.mod_id\n LEFT OUTER JOIN loader_fields_json lf ON m.id = lf.mod_id\n LEFT OUTER JOIN loader_field_enum_values_json lfev ON m.id = lfev.mod_id\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n GROUP BY t.id, m.id, version_fields_json, loader_fields_json, loader_field_enum_values_json, versions_json, mods_gallery_json, links_json;\n ",
"describe": {
"columns": [
{
@@ -70,131 +70,111 @@
},
{
"ordinal": 13,
- "name": "issues_url",
- "type_info": "Varchar"
- },
- {
- "ordinal": 14,
- "name": "source_url",
- "type_info": "Varchar"
- },
- {
- "ordinal": 15,
- "name": "wiki_url",
- "type_info": "Varchar"
- },
- {
- "ordinal": 16,
- "name": "discord_url",
- "type_info": "Varchar"
- },
- {
- "ordinal": 17,
"name": "license_url",
"type_info": "Varchar"
},
{
- "ordinal": 18,
+ "ordinal": 14,
"name": "team_id",
"type_info": "Int8"
},
{
- "ordinal": 19,
+ "ordinal": 15,
"name": "organization_id",
"type_info": "Int8"
},
{
- "ordinal": 20,
+ "ordinal": 16,
"name": "license",
"type_info": "Varchar"
},
{
- "ordinal": 21,
+ "ordinal": 17,
"name": "slug",
"type_info": "Varchar"
},
{
- "ordinal": 22,
+ "ordinal": 18,
"name": "moderation_message",
"type_info": "Varchar"
},
{
- "ordinal": 23,
+ "ordinal": 19,
"name": "moderation_message_body",
"type_info": "Varchar"
},
{
- "ordinal": 24,
+ "ordinal": 20,
"name": "webhook_sent",
"type_info": "Bool"
},
{
- "ordinal": 25,
+ "ordinal": 21,
"name": "color",
"type_info": "Int4"
},
{
- "ordinal": 26,
+ "ordinal": 22,
"name": "thread_id",
"type_info": "Int8"
},
{
- "ordinal": 27,
+ "ordinal": 23,
"name": "monetization_status",
"type_info": "Varchar"
},
{
- "ordinal": 28,
+ "ordinal": 24,
"name": "loaders",
"type_info": "VarcharArray"
},
{
- "ordinal": 29,
+ "ordinal": 25,
"name": "project_types",
"type_info": "VarcharArray"
},
{
- "ordinal": 30,
+ "ordinal": 26,
"name": "games",
"type_info": "VarcharArray"
},
{
- "ordinal": 31,
+ "ordinal": 27,
"name": "categories",
"type_info": "VarcharArray"
},
{
- "ordinal": 32,
+ "ordinal": 28,
"name": "additional_categories",
"type_info": "VarcharArray"
},
{
- "ordinal": 33,
+ "ordinal": 29,
"name": "versions",
"type_info": "Jsonb"
},
{
- "ordinal": 34,
+ "ordinal": 30,
"name": "gallery",
"type_info": "Jsonb"
},
{
- "ordinal": 35,
- "name": "donations",
+ "ordinal": 31,
+ "name": "links",
"type_info": "Jsonb"
},
{
- "ordinal": 36,
+ "ordinal": 32,
"name": "version_fields",
"type_info": "Jsonb"
},
{
- "ordinal": 37,
+ "ordinal": 33,
"name": "loader_fields",
"type_info": "Jsonb"
},
{
- "ordinal": 38,
+ "ordinal": 34,
"name": "loader_field_enum_values",
"type_info": "Jsonb"
}
@@ -221,10 +201,6 @@
false,
true,
true,
- true,
- true,
- true,
- true,
false,
true,
false,
@@ -248,5 +224,5 @@
null
]
},
- "hash": "d8946603f5894d2b18ad66f7747134234cd497c928fbbce6f8adef4fe3f3b1df"
+ "hash": "877927a1310a1c835e1ca24b6995b7d95c62664629d7a59fbfe1404b4aff14d6"
}
diff --git a/.sqlx/query-88a085c2f2b1aa11eacdeedb68b490a695ebf2a9efb24bd5715b8d903f57e2c5.json b/.sqlx/query-88a085c2f2b1aa11eacdeedb68b490a695ebf2a9efb24bd5715b8d903f57e2c5.json
new file mode 100644
index 00000000..fd7b63b9
--- /dev/null
+++ b/.sqlx/query-88a085c2f2b1aa11eacdeedb68b490a695ebf2a9efb24bd5715b8d903f57e2c5.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n DELETE FROM mods_links\n WHERE joining_mod_id = $1 AND joining_platform_id IN (\n SELECT id FROM link_platforms WHERE name = ANY($2)\n )\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Int8",
+ "TextArray"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "88a085c2f2b1aa11eacdeedb68b490a695ebf2a9efb24bd5715b8d903f57e2c5"
+}
diff --git a/.sqlx/query-8abb317c85f48c7dd9ccf4a7b8fbc0b58ac73f7ae87ff2dfe67009a51089f784.json b/.sqlx/query-8abb317c85f48c7dd9ccf4a7b8fbc0b58ac73f7ae87ff2dfe67009a51089f784.json
deleted file mode 100644
index fc2c3450..00000000
--- a/.sqlx/query-8abb317c85f48c7dd9ccf4a7b8fbc0b58ac73f7ae87ff2dfe67009a51089f784.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE mods\n SET wiki_url = $1\n WHERE (id = $2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Varchar",
- "Int8"
- ]
- },
- "nullable": []
- },
- "hash": "8abb317c85f48c7dd9ccf4a7b8fbc0b58ac73f7ae87ff2dfe67009a51089f784"
-}
diff --git a/.sqlx/query-99a1eac69d7f5a5139703df431e6a5c3012a90143a8c635f93632f04d0bc41d4.json b/.sqlx/query-99a1eac69d7f5a5139703df431e6a5c3012a90143a8c635f93632f04d0bc41d4.json
deleted file mode 100644
index aba372c1..00000000
--- a/.sqlx/query-99a1eac69d7f5a5139703df431e6a5c3012a90143a8c635f93632f04d0bc41d4.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE mods\n SET wiki_url = $1\n WHERE (id = $2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Varchar",
- "Int8"
- ]
- },
- "nullable": []
- },
- "hash": "99a1eac69d7f5a5139703df431e6a5c3012a90143a8c635f93632f04d0bc41d4"
-}
diff --git a/.sqlx/query-9aab2350d576fd934b0541d1f71f320ac939b44a179fee3d1638113cdb3ddfe7.json b/.sqlx/query-9aab2350d576fd934b0541d1f71f320ac939b44a179fee3d1638113cdb3ddfe7.json
deleted file mode 100644
index 7683ee0c..00000000
--- a/.sqlx/query-9aab2350d576fd934b0541d1f71f320ac939b44a179fee3d1638113cdb3ddfe7.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO mods_donations (joining_mod_id, joining_platform_id, url)\n VALUES ($1, $2, $3)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Int8",
- "Int4",
- "Varchar"
- ]
- },
- "nullable": []
- },
- "hash": "9aab2350d576fd934b0541d1f71f320ac939b44a179fee3d1638113cdb3ddfe7"
-}
diff --git a/.sqlx/query-acbafe265c4b7a1c95b0494a0a03c8bd2cd778ae561ef5a662fa931ca26cf603.json b/.sqlx/query-acbafe265c4b7a1c95b0494a0a03c8bd2cd778ae561ef5a662fa931ca26cf603.json
deleted file mode 100644
index 9cbd917c..00000000
--- a/.sqlx/query-acbafe265c4b7a1c95b0494a0a03c8bd2cd778ae561ef5a662fa931ca26cf603.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM mods_donations\n WHERE joining_mod_id = $1\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Int8"
- ]
- },
- "nullable": []
- },
- "hash": "acbafe265c4b7a1c95b0494a0a03c8bd2cd778ae561ef5a662fa931ca26cf603"
-}
diff --git a/.sqlx/query-d8020ed838c032c2c287dc0f08989b3ab7156f2571bc75505e6f57b0caeef9c7.json b/.sqlx/query-b1bfb62f4a28ca0fae778738e8a8f325185a83c5d5a240c088a2397b35c55f2a.json
similarity index 59%
rename from .sqlx/query-d8020ed838c032c2c287dc0f08989b3ab7156f2571bc75505e6f57b0caeef9c7.json
rename to .sqlx/query-b1bfb62f4a28ca0fae778738e8a8f325185a83c5d5a240c088a2397b35c55f2a.json
index c8e8481e..5610c103 100644
--- a/.sqlx/query-d8020ed838c032c2c287dc0f08989b3ab7156f2571bc75505e6f57b0caeef9c7.json
+++ b/.sqlx/query-b1bfb62f4a28ca0fae778738e8a8f325185a83c5d5a240c088a2397b35c55f2a.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT id FROM donation_platforms\n WHERE short = $1\n ",
+ "query": "\n SELECT id FROM link_platforms\n WHERE name = $1\n ",
"describe": {
"columns": [
{
@@ -18,5 +18,5 @@
false
]
},
- "hash": "d8020ed838c032c2c287dc0f08989b3ab7156f2571bc75505e6f57b0caeef9c7"
+ "hash": "b1bfb62f4a28ca0fae778738e8a8f325185a83c5d5a240c088a2397b35c55f2a"
}
diff --git a/.sqlx/query-bad7cae347771e801976c26f2afaf33bda371051923b8f74a2f32a0ef5c65e57.json b/.sqlx/query-bad7cae347771e801976c26f2afaf33bda371051923b8f74a2f32a0ef5c65e57.json
deleted file mode 100644
index 1ab92b4c..00000000
--- a/.sqlx/query-bad7cae347771e801976c26f2afaf33bda371051923b8f74a2f32a0ef5c65e57.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE mods\n SET discord_url = $1\n WHERE (id = $2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Varchar",
- "Int8"
- ]
- },
- "nullable": []
- },
- "hash": "bad7cae347771e801976c26f2afaf33bda371051923b8f74a2f32a0ef5c65e57"
-}
diff --git a/.sqlx/query-bc91841f9672608a28bd45a862919f2bd34fac0b3479e3b4b67a9f6bea2a562a.json b/.sqlx/query-bc91841f9672608a28bd45a862919f2bd34fac0b3479e3b4b67a9f6bea2a562a.json
deleted file mode 100644
index fb1b14f1..00000000
--- a/.sqlx/query-bc91841f9672608a28bd45a862919f2bd34fac0b3479e3b4b67a9f6bea2a562a.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE mods\n SET issues_url = $1\n WHERE (id = $2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Varchar",
- "Int8"
- ]
- },
- "nullable": []
- },
- "hash": "bc91841f9672608a28bd45a862919f2bd34fac0b3479e3b4b67a9f6bea2a562a"
-}
diff --git a/.sqlx/query-e3fb74a94a6a78b1007dd99ad11bdcfaa0957ed7d1683997aef7301e0f15baba.json b/.sqlx/query-e3fb74a94a6a78b1007dd99ad11bdcfaa0957ed7d1683997aef7301e0f15baba.json
deleted file mode 100644
index ab0f3449..00000000
--- a/.sqlx/query-e3fb74a94a6a78b1007dd99ad11bdcfaa0957ed7d1683997aef7301e0f15baba.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE mods\n SET issues_url = $1\n WHERE (id = $2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Varchar",
- "Int8"
- ]
- },
- "nullable": []
- },
- "hash": "e3fb74a94a6a78b1007dd99ad11bdcfaa0957ed7d1683997aef7301e0f15baba"
-}
diff --git a/.sqlx/query-76db1c204139e18002e5751c3dcefff79791a1dd852b62d34fcf008151e8945a.json b/.sqlx/query-fef7802edefa1a6957fa43ccf64b987c3547294f0c8581028ac6b83de42b3a00.json
similarity index 64%
rename from .sqlx/query-76db1c204139e18002e5751c3dcefff79791a1dd852b62d34fcf008151e8945a.json
rename to .sqlx/query-fef7802edefa1a6957fa43ccf64b987c3547294f0c8581028ac6b83de42b3a00.json
index a16f796c..bcca3ff2 100644
--- a/.sqlx/query-76db1c204139e18002e5751c3dcefff79791a1dd852b62d34fcf008151e8945a.json
+++ b/.sqlx/query-fef7802edefa1a6957fa43ccf64b987c3547294f0c8581028ac6b83de42b3a00.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT id, short, name FROM donation_platforms\n ",
+ "query": "\n SELECT id, name, donation FROM link_platforms\n ",
"describe": {
"columns": [
{
@@ -10,13 +10,13 @@
},
{
"ordinal": 1,
- "name": "short",
+ "name": "name",
"type_info": "Varchar"
},
{
"ordinal": 2,
- "name": "name",
- "type_info": "Varchar"
+ "name": "donation",
+ "type_info": "Bool"
}
],
"parameters": {
@@ -28,5 +28,5 @@
false
]
},
- "hash": "76db1c204139e18002e5751c3dcefff79791a1dd852b62d34fcf008151e8945a"
+ "hash": "fef7802edefa1a6957fa43ccf64b987c3547294f0c8581028ac6b83de42b3a00"
}
diff --git a/migrations/20231117073600_links_overhaul.sql b/migrations/20231117073600_links_overhaul.sql
new file mode 100644
index 00000000..808f2d0b
--- /dev/null
+++ b/migrations/20231117073600_links_overhaul.sql
@@ -0,0 +1,69 @@
+CREATE TABLE link_platforms (
+ id SERIAL PRIMARY KEY,
+ name VARCHAR(16) UNIQUE NOT NULL,
+
+ -- Used for v2 conversion
+ donation BOOLEAN NOT NULL DEFAULT false,
+ -- Will be removed at the end of the migration
+ donation_platform_id INTEGER REFERENCES donation_platforms (id)
+);
+
+INSERT INTO link_platforms (donation_platform_id, name, donation)
+SELECT id, short, true FROM donation_platforms;
+
+INSERT INTO link_platforms (name, donation) VALUES ('issues', false);
+INSERT INTO link_platforms (name, donation) VALUES ('wiki', false);
+INSERT INTO link_platforms (name, donation) VALUES ('discord', false);
+INSERT INTO link_platforms (name, donation) VALUES ('source', false);
+INSERT INTO link_platforms (name, donation) VALUES ('site', false);
+
+CREATE TABLE mods_links (
+ id SERIAL PRIMARY KEY,
+ joining_mod_id BIGINT NOT NULL REFERENCES mods (id),
+ joining_platform_id INTEGER NOT NULL REFERENCES link_platforms (id),
+ url VARCHAR(255) NOT NULL
+);
+
+INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)
+SELECT DISTINCT m.id, lp.id, md.url
+FROM mods m
+INNER JOIN mods_donations md ON m.id = md.joining_mod_id
+INNER JOIN donation_platforms dp ON dp.id = md.joining_platform_id
+INNER JOIN link_platforms lp ON lp.donation_platform_id = dp.id;
+
+INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)
+SELECT DISTINCT m.id, lp.id, issues_url
+FROM mods m
+CROSS JOIN link_platforms lp
+WHERE issues_url IS NOT NULL
+AND lp.name = 'issues';
+
+INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)
+SELECT DISTINCT m.id, lp.id, wiki_url
+FROM mods m
+CROSS JOIN link_platforms lp
+WHERE wiki_url IS NOT NULL
+AND lp.name = 'wiki';
+
+INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)
+SELECT DISTINCT m.id, lp.id, discord_url
+FROM mods m
+CROSS JOIN link_platforms lp
+WHERE discord_url IS NOT NULL
+AND lp.name = 'discord';
+
+INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)
+SELECT DISTINCT m.id, lp.id, source_url
+FROM mods m
+CROSS JOIN link_platforms lp
+WHERE source_url IS NOT NULL
+AND lp.name = 'source';
+
+ALTER TABLE mods DROP COLUMN issues_url;
+ALTER TABLE mods DROP COLUMN wiki_url;
+ALTER TABLE mods DROP COLUMN discord_url;
+ALTER TABLE mods DROP COLUMN source_url;
+
+ALTER TABLE link_platforms DROP COLUMN donation_platform_id;
+DROP TABLE mods_donations;
+DROP TABLE donation_platforms;
\ No newline at end of file
diff --git a/src/database/models/categories.rs b/src/database/models/categories.rs
index 6205fab8..4e04dba5 100644
--- a/src/database/models/categories.rs
+++ b/src/database/models/categories.rs
@@ -29,10 +29,10 @@ pub struct ReportType {
}
#[derive(Serialize, Deserialize)]
-pub struct DonationPlatform {
- pub id: DonationPlatformId,
- pub short: String,
+pub struct LinkPlatform {
+ pub id: LinkPlatformId,
pub name: String,
+ pub donation: bool,
}
impl Category {
@@ -129,38 +129,32 @@ impl Category {
}
}
-impl DonationPlatform {
- pub async fn get_id<'a, E>(
- id: &str,
- exec: E,
- ) -> Result