diff --git a/db/db-sqlx-maria/Cargo.toml b/db/db-sqlx-maria/Cargo.toml new file mode 100644 index 00000000..7f419404 --- /dev/null +++ b/db/db-sqlx-maria/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "db-sqlx-maria" +version = "0.1.0" +edition = "2021" +homepage = "https://mcaptcha.org" +repository = "https://github.com/mCaptcha/mCaptcha" +documentation = "https://mcaptcha.org/docs/" +license = "AGPLv3 or later version" +authors = ["realaravinth "] + +[dependencies] +async-trait = "0.1.51" +db-core = {path = "../db-core"} +futures = "0.3.15" +sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "mysql", "time", "offline" ] } + +[dev-dependencies] +actix-rt = "2" +sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "mysql", "time", "offline" ] } +db-core = {path = "../db-core", features = ["test"]} +url = { version = "2.2.2", features = ["serde"] } diff --git a/db/db-sqlx-maria/migrations/20210310122154_mcaptcha_users.sql b/db/db-sqlx-maria/migrations/20210310122154_mcaptcha_users.sql new file mode 100644 index 00000000..c62a8d26 --- /dev/null +++ b/db/db-sqlx-maria/migrations/20210310122154_mcaptcha_users.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS mcaptcha_users ( + name VARCHAR(100) NOT NULL UNIQUE, + email VARCHAR(100) UNIQUE DEFAULT NULL, + email_verified BOOLEAN DEFAULT NULL, + secret varchar(50) NOT NULL UNIQUE, + password TEXT NOT NULL, + ID INT auto_increment, + PRIMARY KEY(ID) +); diff --git a/db/db-sqlx-maria/migrations/20210310122617_mcaptcha_config.sql b/db/db-sqlx-maria/migrations/20210310122617_mcaptcha_config.sql new file mode 100644 index 00000000..091f9a82 --- /dev/null +++ b/db/db-sqlx-maria/migrations/20210310122617_mcaptcha_config.sql @@ -0,0 +1,16 @@ +-- TODO: changed key -> captcha_key + +CREATE TABLE IF NOT EXISTS mcaptcha_config ( + config_id INT auto_increment, + PRIMARY KEY(config_id), + user_id INT NOT NULL, + captcha_key varchar(100) NOT NULL UNIQUE, + name varchar(100) NOT NULL, + duration integer NOT NULL DEFAULT 30, + + CONSTRAINT `fk_mcaptcha_user` + FOREIGN KEY (user_id) + REFERENCES mcaptcha_users (ID) + ON DELETE CASCADE + ON UPDATE CASCADE +); diff --git a/db/db-sqlx-maria/migrations/20210310122902_mcaptcha_levels.sql b/db/db-sqlx-maria/migrations/20210310122902_mcaptcha_levels.sql new file mode 100644 index 00000000..6e153165 --- /dev/null +++ b/db/db-sqlx-maria/migrations/20210310122902_mcaptcha_levels.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS mcaptcha_levels ( + config_id INTEGER NOT NULL, + difficulty_factor INTEGER NOT NULL, + visitor_threshold INTEGER NOT NULL, + level_id INT auto_increment, + PRIMARY KEY(level_id), + CONSTRAINT `fk_mcaptcha_config_id` + FOREIGN KEY (config_id) + REFERENCES mcaptcha_config (config_id) + ON DELETE CASCADE + ON UPDATE CASCADE +); diff --git a/db/db-sqlx-maria/migrations/20210430032935_mcaptcha_pow_fetched_stats.sql b/db/db-sqlx-maria/migrations/20210430032935_mcaptcha_pow_fetched_stats.sql new file mode 100644 index 00000000..431150fe --- /dev/null +++ b/db/db-sqlx-maria/migrations/20210430032935_mcaptcha_pow_fetched_stats.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS mcaptcha_pow_fetched_stats ( + config_id INTEGER NOT NULL, + time timestamp NOT NULL DEFAULT now(), + CONSTRAINT `fk_mcaptcha_config_id_pow_fetched_stats` + FOREIGN KEY (config_id) + REFERENCES mcaptcha_config (config_id) + ON DELETE CASCADE + ON UPDATE CASCADE + +); diff --git a/db/db-sqlx-maria/migrations/20210509135118_mcaptcha_pow_solved_stats.sql b/db/db-sqlx-maria/migrations/20210509135118_mcaptcha_pow_solved_stats.sql new file mode 100644 index 00000000..d0883c3a --- /dev/null +++ b/db/db-sqlx-maria/migrations/20210509135118_mcaptcha_pow_solved_stats.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS mcaptcha_pow_solved_stats ( + config_id INTEGER NOT NULL, + time timestamp NOT NULL DEFAULT now(), + CONSTRAINT `fk_mcaptcha_config_id_pow_solved_stats` + FOREIGN KEY (config_id) + REFERENCES mcaptcha_config (config_id) + ON DELETE CASCADE + ON UPDATE CASCADE +); diff --git a/db/db-sqlx-maria/migrations/20210509135154_mcaptcha_pow_confirmed_stats.sql b/db/db-sqlx-maria/migrations/20210509135154_mcaptcha_pow_confirmed_stats.sql new file mode 100644 index 00000000..6aca7f20 --- /dev/null +++ b/db/db-sqlx-maria/migrations/20210509135154_mcaptcha_pow_confirmed_stats.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS mcaptcha_pow_confirmed_stats ( + config_id INTEGER NOT NULL, + time timestamp NOT NULL DEFAULT now(), + CONSTRAINT `fk_mcaptcha_config_id_pow_confirmed_stats` + FOREIGN KEY (config_id) + REFERENCES mcaptcha_config (config_id) + ON DELETE CASCADE + ON UPDATE CASCADE + +); diff --git a/db/db-sqlx-maria/migrations/20210509151150_mcaptcha_notifications.sql b/db/db-sqlx-maria/migrations/20210509151150_mcaptcha_notifications.sql new file mode 100644 index 00000000..50ab18cf --- /dev/null +++ b/db/db-sqlx-maria/migrations/20210509151150_mcaptcha_notifications.sql @@ -0,0 +1,19 @@ +-- Add migration script here +CREATE TABLE IF NOT EXISTS mcaptcha_notifications ( + id INT auto_increment, + PRIMARY KEY(id), + + tx INT NOT NULL, + rx INT NOT NULL, + heading varchar(30) NOT NULL, + message varchar(250) NOT NULL, + -- todo: mv read -> read_notification + read_notification BOOLEAN DEFAULT null, + received timestamp NOT NULL DEFAULT now(), + + CONSTRAINT `fk_mcaptcha_mcaptcha_user_notifications_tx` + FOREIGN KEY (tx) + REFERENCES mcaptcha_users (ID) + ON DELETE CASCADE + ON UPDATE CASCADE +); diff --git a/db/db-sqlx-maria/migrations/20211202141927_mcaptcha_sitekey_user_provided_avg_traffic.sql b/db/db-sqlx-maria/migrations/20211202141927_mcaptcha_sitekey_user_provided_avg_traffic.sql new file mode 100644 index 00000000..b8eb99b1 --- /dev/null +++ b/db/db-sqlx-maria/migrations/20211202141927_mcaptcha_sitekey_user_provided_avg_traffic.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS mcaptcha_sitekey_user_provided_avg_traffic ( + config_id INT NOT NULL, + PRIMARY KEY(config_id), + avg_traffic INTEGER DEFAULT NULL, + peak_sustainable_traffic INTEGER DEFAULT NULL, + broke_my_site_traffic INT DEFAULT NULL, + + CONSTRAINT `fk_mcaptcha_sitekey_user_provided_avg_trafic_config_id` + FOREIGN KEY (config_id) + REFERENCES mcaptcha_config (config_id) + ON DELETE CASCADE + ON UPDATE CASCADE +); diff --git a/db/db-sqlx-maria/migrations/20211218133703_change_user_provided_avg_traffic_col_datatype.sql b/db/db-sqlx-maria/migrations/20211218133703_change_user_provided_avg_traffic_col_datatype.sql new file mode 100644 index 00000000..457a3230 --- /dev/null +++ b/db/db-sqlx-maria/migrations/20211218133703_change_user_provided_avg_traffic_col_datatype.sql @@ -0,0 +1,3 @@ +ALTER TABLE mcaptcha_sitekey_user_provided_avg_traffic + MODIFY avg_traffic INTEGER NOT NULL, + MODIFY peak_sustainable_traffic INTEGER NOT NULL; diff --git a/db/db-sqlx-maria/migrations/20220526114806_alter_notifications_table.sql b/db/db-sqlx-maria/migrations/20220526114806_alter_notifications_table.sql new file mode 100644 index 00000000..f3bef072 --- /dev/null +++ b/db/db-sqlx-maria/migrations/20220526114806_alter_notifications_table.sql @@ -0,0 +1,2 @@ +-- Add migration script here +ALTER TABLE mcaptcha_notifications MODIFY heading varchar(100) NOT NULL; diff --git a/db/db-sqlx-maria/sqlx-data.json b/db/db-sqlx-maria/sqlx-data.json new file mode 100644 index 00000000..256ceeeb --- /dev/null +++ b/db/db-sqlx-maria/sqlx-data.json @@ -0,0 +1,861 @@ +{ + "db": "MySQL", + "1367dceb151a766a901b5dd771d0b75d0bc61d2fef17a94a90c8ffa0065e2c44": { + "describe": { + "columns": [ + { + "name": "time", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 1185 + }, + "max_size": 19, + "type": "Timestamp" + } + } + ], + "nullable": [ + false + ], + "parameters": { + "Right": 2 + } + }, + "query": "SELECT time FROM mcaptcha_pow_confirmed_stats \n WHERE \n config_id = (\n SELECT config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?))\n ORDER BY time DESC" + }, + "22e697114c3ed5b0156cdceab11a398f1ef3a804f482e1cd948bc615ef95fc92": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 5 + } + }, + "query": "INSERT INTO mcaptcha_sitekey_user_provided_avg_traffic (\n config_id,\n avg_traffic,\n peak_sustainable_traffic,\n broke_my_site_traffic\n ) VALUES ( \n (SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n ), ?, ?, ?)" + }, + "34b29417f9ff3f4d5987df0ce81023b1985eb84e560602b36182f55de6cd9d83": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "INSERT INTO mcaptcha_pow_confirmed_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)" + }, + "3812693a9ae4402d900bcbf680981e6194073bd1937af11a77daa3776fb4c873": { + "describe": { + "columns": [ + { + "name": "captcha_key", + "ordinal": 0, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4101 + }, + "max_size": 400, + "type": "VarString" + } + }, + { + "name": "name", + "ordinal": 1, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4097 + }, + "max_size": 400, + "type": "VarString" + } + }, + { + "name": "config_id", + "ordinal": 2, + "type_info": { + "char_set": 63, + "flags": { + "bits": 515 + }, + "max_size": 11, + "type": "Long" + } + }, + { + "name": "duration", + "ordinal": 3, + "type_info": { + "char_set": 63, + "flags": { + "bits": 1 + }, + "max_size": 11, + "type": "Long" + } + } + ], + "nullable": [ + false, + false, + false, + false + ], + "parameters": { + "Right": 1 + } + }, + "query": "SELECT captcha_key, name, config_id, duration FROM mcaptcha_config WHERE\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) " + }, + "3a8381eb0f0542a492d9dd51368e769e2b313e0576a1873e5c7630011e463daf": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 4 + } + }, + "query": "UPDATE mcaptcha_config SET name = ?, duration = ?\n WHERE user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n AND captcha_key = ?" + }, + "413ea53cea8b8f114fc009bad527b054a68a94477dfcc50d860d45bbd864d4f1": { + "describe": { + "columns": [ + { + "name": "email", + "ordinal": 0, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4 + }, + "max_size": 400, + "type": "VarString" + } + } + ], + "nullable": [ + true + ], + "parameters": { + "Right": 1 + } + }, + "query": "SELECT email FROM mcaptcha_users WHERE name = ?" + }, + "598a8202942771eff460faa6f09bd3fb1fc910d5fab7edb07c49dadbbaeb1cb8": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "INSERT INTO mcaptcha_pow_fetched_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)" + }, + "5d5a106981345e9f62bc2239c00cdc683d3aaaa820d63da300dc51e3f6f363d3": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 3 + } + }, + "query": "INSERT INTO mcaptcha_users \n (name , password, secret) VALUES (?, ?, ?)" + }, + "66ec7df10484f8e0206f3c97afc9136021589556c38dbbed341d6574487f79f2": { + "describe": { + "columns": [ + { + "name": "config_id", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 515 + }, + "max_size": 11, + "type": "Long" + } + } + ], + "nullable": [ + false + ], + "parameters": { + "Right": 2 + } + }, + "query": "SELECT config_id FROM mcaptcha_config\n WHERE\n captcha_key = ? \n AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)" + }, + "676a9f1761c3b63cf16d7d4dd6261507cc7707feb32d458f4b946ed9caa53721": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "UPDATE mcaptcha_users set name = ?\n WHERE name = ?" + }, + "6d1b6e5e58ca2ba285cab7b050bbdc43de1f3e46cf7d420bc95c124a1c7c9d1f": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 1 + } + }, + "query": "DELETE FROM mcaptcha_users WHERE name = (?)" + }, + "6d43e6ceb54a0ff8a803bd96dd9134b15da01d48776ac0cf3d66a2997dadce5e": { + "describe": { + "columns": [ + { + "name": "difficulty_factor", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 4097 + }, + "max_size": 11, + "type": "Long" + } + }, + { + "name": "visitor_threshold", + "ordinal": 1, + "type_info": { + "char_set": 63, + "flags": { + "bits": 4097 + }, + "max_size": 11, + "type": "Long" + } + } + ], + "nullable": [ + false, + false + ], + "parameters": { + "Right": 1 + } + }, + "query": "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n ) ORDER BY difficulty_factor ASC;" + }, + "74d68a86f852d3d85957e94ed04e8acd8e6144744f7b13e383ebcb2bcf3360ae": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 4 + } + }, + "query": "INSERT INTO mcaptcha_levels (\n difficulty_factor, \n visitor_threshold,\n config_id) VALUES (\n ?, ?, (\n SELECT config_id FROM mcaptcha_config WHERE\n captcha_key = (?) AND user_id = (\n SELECT ID FROM mcaptcha_users WHERE name = ?\n )));" + }, + "7838ade4a48068e25c6f117ee8e38f088b867b1ab08a7dd0269b76891266ace6": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "UPDATE mcaptcha_users set secret = ?\n WHERE name = ?" + }, + "7894dda54cd65559fe3b81bab7df8cc848e21ed5c7f5e88951bf1c98c78ed820": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "DELETE FROM mcaptcha_levels \n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?) \n AND user_id = (\n SELECT ID from mcaptcha_users WHERE name = ?\n )\n )" + }, + "89386c46668a2653a54687e65958af5cf7a8da268339a1f5a379ede47b3c6d2a": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 5 + } + }, + "query": "INSERT INTO mcaptcha_notifications (\n heading, message, tx, rx, received)\n VALUES (\n ?, ?,\n (SELECT ID FROM mcaptcha_users WHERE name = ?),\n (SELECT ID FROM mcaptcha_users WHERE name = ?),\n ?\n );" + }, + "8acbf84d4801e86221d8f6324ae50488a0986182d66b20ad414bce4e2ac18eca": { + "describe": { + "columns": [ + { + "name": "duration", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 1 + }, + "max_size": 11, + "type": "Long" + } + } + ], + "nullable": [ + false + ], + "parameters": { + "Right": 1 + } + }, + "query": "SELECT duration FROM mcaptcha_config \n where captcha_key= ?" + }, + "8e6026abf7c0e8ab90ee8eb7ada9f66962ab6999d3127944b058d6f96346e72f": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 3 + } + }, + "query": "UPDATE mcaptcha_config SET captcha_key = ? \n WHERE captcha_key = ? AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)" + }, + "8ec8bbde0c02a99f74d12e6778f123a973283e6d56b6861b30f559768617848a": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 4 + } + }, + "query": "insert into mcaptcha_users \n (name , password, email, secret) values (?, ?, ?, ?)" + }, + "9c435148ed5655e79dd1e73e3566ce23b7c6d38edcedbb988c95813c5da893ed": { + "describe": { + "columns": [ + { + "name": "config_id", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 515 + }, + "max_size": 11, + "type": "Long" + } + }, + { + "name": "duration", + "ordinal": 1, + "type_info": { + "char_set": 63, + "flags": { + "bits": 1 + }, + "max_size": 11, + "type": "Long" + } + }, + { + "name": "name", + "ordinal": 2, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4097 + }, + "max_size": 400, + "type": "VarString" + } + }, + { + "name": "captcha_key", + "ordinal": 3, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4101 + }, + "max_size": 400, + "type": "VarString" + } + } + ], + "nullable": [ + false, + false, + false, + false + ], + "parameters": { + "Right": 2 + } + }, + "query": "SELECT `config_id`, `duration`, `name`, `captcha_key` from mcaptcha_config WHERE\n `captcha_key` = ? AND\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) " + }, + "9cb416de904872d66af90baa0024f382ce6f8344464c607fe6e6c2572816dfc2": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "UPDATE mcaptcha_users set email = ?\n WHERE name = ?" + }, + "a89c066db044cddfdebee6a0fd0d80a5a26dcb7ecc00a9899f5634b72ea0a952": { + "describe": { + "columns": [ + { + "name": "config_id", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 515 + }, + "max_size": 11, + "type": "Long" + } + } + ], + "nullable": [ + false + ], + "parameters": { + "Right": 1 + } + }, + "query": "SELECT config_id from mcaptcha_config WHERE captcha_key = ?" + }, + "b95e5a60a202cb646d5e76df8c7395e4bf881a6dd14e28e6f2e8b93e0536b331": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "DELETE FROM mcaptcha_config where captcha_key= (?)\n AND\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)" + }, + "b9b0c63380bc0dfdea8aae092dcefceb316fe94667d74f53d53063810cdd2ba8": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 515 + }, + "max_size": 11, + "type": "Long" + } + }, + { + "name": "heading", + "ordinal": 1, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4097 + }, + "max_size": 400, + "type": "VarString" + } + }, + { + "name": "message", + "ordinal": 2, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4097 + }, + "max_size": 1000, + "type": "VarString" + } + }, + { + "name": "received", + "ordinal": 3, + "type_info": { + "char_set": 63, + "flags": { + "bits": 1185 + }, + "max_size": 19, + "type": "Timestamp" + } + }, + { + "name": "name", + "ordinal": 4, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4101 + }, + "max_size": 400, + "type": "VarString" + } + } + ], + "nullable": [ + false, + false, + false, + false, + false + ], + "parameters": { + "Right": 1 + } + }, + "query": "-- gets all unread notifications a user has\nSELECT \n mcaptcha_notifications.id,\n mcaptcha_notifications.heading,\n mcaptcha_notifications.message,\n mcaptcha_notifications.received,\n mcaptcha_users.name\nFROM\n mcaptcha_notifications \nINNER JOIN \n mcaptcha_users \nON \n mcaptcha_notifications.tx = mcaptcha_users.id\nWHERE \n mcaptcha_notifications.rx = (\n SELECT \n id \n FROM \n mcaptcha_users\n WHERE\n name = ?\n )\nAND \n mcaptcha_notifications.read_notification IS NULL;\n" + }, + "caa1638ee510ef62b86817e5d2baeaca8dfa432c23d7630c0e70737211a4680b": { + "describe": { + "columns": [ + { + "name": "name", + "ordinal": 0, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4101 + }, + "max_size": 400, + "type": "VarString" + } + } + ], + "nullable": [ + false + ], + "parameters": { + "Right": 1 + } + }, + "query": "SELECT name from mcaptcha_users WHERE email = ?" + }, + "cad5b403470f26c565e74a1dca19b7dee066141dec0f708070067e34d5bf72cc": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "UPDATE mcaptcha_users set password = ?\n WHERE name = ?" + }, + "cf333541509213f11a9bf7119dcb3289bb77abf1482fc1d47e7f5bb27bdc8d97": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "-- mark a notification as read\nUPDATE mcaptcha_notifications\n SET read_notification = TRUE\nWHERE \n mcaptcha_notifications.id = ?\nAND\n mcaptcha_notifications.rx = (\n SELECT\n id\n FROM\n mcaptcha_users\n WHERE\n name = ?\n );\n" + }, + "d05b84966f4e70c53789221f961bf3637f404f3ba45e880115e97ed1ba5a2809": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 4 + } + }, + "query": "INSERT INTO mcaptcha_config\n (`captcha_key`, `user_id`, `duration`, `name`)\n VALUES (?, (SELECT ID FROM mcaptcha_users WHERE name = ?), ?, ?)" + }, + "d4b92e8099cd29cfdb99aadeeada739bb6858667fc65f528ec484e98a9da21bc": { + "describe": { + "columns": [ + { + "name": "time", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 1185 + }, + "max_size": 19, + "type": "Timestamp" + } + } + ], + "nullable": [ + false + ], + "parameters": { + "Right": 2 + } + }, + "query": "SELECT time FROM mcaptcha_pow_solved_stats \n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?)) \n ORDER BY time DESC" + }, + "daac5e937aeac2f106eb89154b431fa8bd1bd7baa95e51704fdcdf50bd970a1d": { + "describe": { + "columns": [ + { + "name": "time", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 1185 + }, + "max_size": 19, + "type": "Timestamp" + } + } + ], + "nullable": [ + false + ], + "parameters": { + "Right": 2 + } + }, + "query": "SELECT time FROM mcaptcha_pow_fetched_stats\n WHERE \n config_id = (\n SELECT \n config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?))\n ORDER BY time DESC" + }, + "dd5ff10b88fa6f374e105b6bed9e34e0870ac8dd7ce36dfb09d13a1b7005b2eb": { + "describe": { + "columns": [ + { + "name": "name", + "ordinal": 0, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4101 + }, + "max_size": 400, + "type": "VarString" + } + }, + { + "name": "password", + "ordinal": 1, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4113 + }, + "max_size": 262140, + "type": "Blob" + } + } + ], + "nullable": [ + false, + false + ], + "parameters": { + "Right": 1 + } + }, + "query": "SELECT name, password FROM mcaptcha_users WHERE name = ?" + }, + "dd9b4dec39405ff19af21faabb6a7c3bb3207e7e785fe15357146b88c6c27f01": { + "describe": { + "columns": [ + { + "name": "secret", + "ordinal": 0, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4101 + }, + "max_size": 200, + "type": "VarString" + } + } + ], + "nullable": [ + false + ], + "parameters": { + "Right": 1 + } + }, + "query": "SELECT secret FROM mcaptcha_users WHERE name = ?" + }, + "df6de3b96afcfb7f364f98954995e506b19e80e7f88204405d970c360ad5e1a0": { + "describe": { + "columns": [ + { + "name": "difficulty_factor", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 4097 + }, + "max_size": 11, + "type": "Long" + } + }, + { + "name": "visitor_threshold", + "ordinal": 1, + "type_info": { + "char_set": 63, + "flags": { + "bits": 4097 + }, + "max_size": 11, + "type": "Long" + } + } + ], + "nullable": [ + false, + false + ], + "parameters": { + "Right": 2 + } + }, + "query": "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n AND user_id = (SELECT ID from mcaptcha_users WHERE name = ?)\n )\n ORDER BY difficulty_factor ASC;" + }, + "e2b0b85f2afac1cbca43ce684641bf75ef070e44ce3d00404fc6151d2f4d7bcf": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "INSERT INTO mcaptcha_pow_solved_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)" + }, + "e6569a6064d0e07abea4c0bd4686cdfdaac64f0109ac40efaed06a744a2eaf5e": { + "describe": { + "columns": [ + { + "name": "name", + "ordinal": 0, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4101 + }, + "max_size": 400, + "type": "VarString" + } + } + ], + "nullable": [ + false + ], + "parameters": { + "Right": 1 + } + }, + "query": "SELECT name from mcaptcha_users WHERE name = ?" + }, + "e91116ebce127833488130cf1060e0817e5677f39588632452b8d621688c405a": { + "describe": { + "columns": [ + { + "name": "avg_traffic", + "ordinal": 0, + "type_info": { + "char_set": 63, + "flags": { + "bits": 4097 + }, + "max_size": 11, + "type": "Long" + } + }, + { + "name": "peak_sustainable_traffic", + "ordinal": 1, + "type_info": { + "char_set": 63, + "flags": { + "bits": 4097 + }, + "max_size": 11, + "type": "Long" + } + }, + { + "name": "broke_my_site_traffic", + "ordinal": 2, + "type_info": { + "char_set": 63, + "flags": { + "bits": 0 + }, + "max_size": 11, + "type": "Long" + } + } + ], + "nullable": [ + false, + false, + true + ], + "parameters": { + "Right": 2 + } + }, + "query": "SELECT \n avg_traffic, \n peak_sustainable_traffic, \n broke_my_site_traffic \n FROM \n mcaptcha_sitekey_user_provided_avg_traffic \n WHERE \n config_id = (\n SELECT \n config_id \n FROM \n mcaptcha_config \n WHERE \n captcha_key = ? \n AND user_id = (\n SELECT \n id \n FROM \n mcaptcha_users \n WHERE \n NAME = ?\n )\n )\n " + }, + "ed943cbf7e16536d81010255ce2f5beb207b2b9d44cb859fa9f2233405b80ae0": { + "describe": { + "columns": [ + { + "name": "name", + "ordinal": 0, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4101 + }, + "max_size": 400, + "type": "VarString" + } + }, + { + "name": "password", + "ordinal": 1, + "type_info": { + "char_set": 224, + "flags": { + "bits": 4113 + }, + "max_size": 262140, + "type": "Blob" + } + } + ], + "nullable": [ + false, + false + ], + "parameters": { + "Right": 1 + } + }, + "query": "SELECT name, password FROM mcaptcha_users WHERE email = ?" + }, + "fc717ff0827ccfaa1cc61a71cc7f71c348ebb03d35895c54b011c03121ad2385": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Right": 2 + } + }, + "query": "DELETE FROM mcaptcha_sitekey_user_provided_avg_traffic\n WHERE config_id = (\n SELECT config_id \n FROM \n mcaptcha_config \n WHERE\n captcha_key = ?\n AND \n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n );" + } +} \ No newline at end of file diff --git a/db/db-sqlx-maria/src/errors.rs b/db/db-sqlx-maria/src/errors.rs new file mode 100644 index 00000000..00e3b333 --- /dev/null +++ b/db/db-sqlx-maria/src/errors.rs @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2022 Aravinth Manivannan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +//! Error-handling utilities +use std::borrow::Cow; + +use db_core::dev::*; +use sqlx::Error; + +/// map custom row not found error to DB error +pub fn map_row_not_found_err(e: Error, row_not_found: DBError) -> DBError { + if let Error::RowNotFound = e { + row_not_found + } else { + map_register_err(e) + } +} + +/// map postgres errors to [DBError](DBError) types +pub fn map_register_err(e: Error) -> DBError { + if let Error::Database(err) = e { + if err.code() == Some(Cow::from("23505")) { + let msg = err.message(); + println!("{}", msg); + if msg.contains("mcaptcha_users_name_key") { + DBError::UsernameTaken + } else if msg.contains("mcaptcha_users_email_key") { + DBError::EmailTaken + } else if msg.contains("mcaptcha_users_secret_key") { + DBError::SecretTaken + } else if msg.contains("mcaptcha_config_key_key") { + DBError::CaptchaKeyTaken + } else { + DBError::DBError(Box::new(Error::Database(err))) + } + } else { + DBError::DBError(Box::new(Error::Database(err))) + } + } else { + DBError::DBError(Box::new(e)) + } +} diff --git a/db/db-sqlx-maria/src/get_all_unread_notifications.sql b/db/db-sqlx-maria/src/get_all_unread_notifications.sql new file mode 100644 index 00000000..6bd9551a --- /dev/null +++ b/db/db-sqlx-maria/src/get_all_unread_notifications.sql @@ -0,0 +1,24 @@ +-- gets all unread notifications a user has +SELECT + mcaptcha_notifications.id, + mcaptcha_notifications.heading, + mcaptcha_notifications.message, + mcaptcha_notifications.received, + mcaptcha_users.name +FROM + mcaptcha_notifications +INNER JOIN + mcaptcha_users +ON + mcaptcha_notifications.tx = mcaptcha_users.id +WHERE + mcaptcha_notifications.rx = ( + SELECT + id + FROM + mcaptcha_users + WHERE + name = ? + ) +AND + mcaptcha_notifications.read_notification IS NULL; diff --git a/db/db-sqlx-maria/src/lib.rs b/db/db-sqlx-maria/src/lib.rs new file mode 100644 index 00000000..c30dc207 --- /dev/null +++ b/db/db-sqlx-maria/src/lib.rs @@ -0,0 +1,949 @@ +/* + * Copyright (C) 2022 Aravinth Manivannan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +use std::str::FromStr; + +use db_core::dev::*; + +use sqlx::mysql::MySqlPoolOptions; +use sqlx::types::time::OffsetDateTime; +use sqlx::ConnectOptions; +use sqlx::MySqlPool; + +pub mod errors; +#[cfg(test)] +pub mod tests; + +#[derive(Clone)] +pub struct Database { + pub pool: MySqlPool, +} + +/// Use an existing database pool +pub struct Conn(pub MySqlPool); + +/// Connect to databse +pub enum ConnectionOptions { + /// fresh connection + Fresh(Fresh), + /// existing connection + Existing(Conn), +} + +pub struct Fresh { + pub pool_options: MySqlPoolOptions, + pub disable_logging: bool, + pub url: String, +} + +pub mod dev { + pub use super::errors::*; + pub use super::Database; + pub use db_core::dev::*; + pub use prelude::*; + pub use sqlx::Error; +} + +pub mod prelude { + pub use super::*; + pub use db_core::prelude::*; +} + +#[async_trait] +impl Connect for ConnectionOptions { + type Pool = Database; + async fn connect(self) -> DBResult { + let pool = match self { + Self::Fresh(fresh) => { + let mut connect_options = + sqlx::mysql::MySqlConnectOptions::from_str(&fresh.url).unwrap(); + if fresh.disable_logging { + connect_options.disable_statement_logging(); + } + sqlx::mysql::MySqlConnectOptions::from_str(&fresh.url) + .unwrap() + .disable_statement_logging(); + fresh + .pool_options + .connect_with(connect_options) + .await + .map_err(|e| DBError::DBError(Box::new(e)))? + } + + Self::Existing(conn) => conn.0, + }; + Ok(Database { pool }) + } +} + +use dev::*; + +#[async_trait] +impl Migrate for Database { + async fn migrate(&self) -> DBResult<()> { + sqlx::migrate!("./migrations/") + .run(&self.pool) + .await + .map_err(|e| DBError::DBError(Box::new(e)))?; + Ok(()) + } +} + +#[async_trait] +impl MCDatabase for Database { + /// ping DB + async fn ping(&self) -> bool { + use sqlx::Connection; + + if let Ok(mut con) = self.pool.acquire().await { + con.ping().await.is_ok() + } else { + false + } + } + + /// register a new user + async fn register(&self, p: &Register) -> DBResult<()> { + let res = if let Some(email) = &p.email { + sqlx::query!( + "insert into mcaptcha_users + (name , password, email, secret) values (?, ?, ?, ?)", + &p.username, + &p.hash, + &email, + &p.secret, + ) + .execute(&self.pool) + .await + } else { + sqlx::query!( + "INSERT INTO mcaptcha_users + (name , password, secret) VALUES (?, ?, ?)", + &p.username, + &p.hash, + &p.secret, + ) + .execute(&self.pool) + .await + }; + res.map_err(map_register_err)?; + Ok(()) + } + + /// delete a user + async fn delete_user(&self, username: &str) -> DBResult<()> { + sqlx::query!("DELETE FROM mcaptcha_users WHERE name = (?)", username) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?; + Ok(()) + } + + /// check if username exists + async fn username_exists(&self, username: &str) -> DBResult { + match sqlx::query!("SELECT name from mcaptcha_users WHERE name = ?", username,) + .fetch_one(&self.pool) + .await + { + Ok(_) => Ok(true), + Err(sqlx::Error::RowNotFound) => Ok(false), + Err(e) => Err(map_register_err(e)), + } + } + + /// get user email + async fn get_email(&self, username: &str) -> DBResult> { + struct Email { + email: Option, + } + + let res = sqlx::query_as!( + Email, + "SELECT email FROM mcaptcha_users WHERE name = ?", + username + ) + .fetch_one(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?; + Ok(res.email) + } + + /// check if email exists + async fn email_exists(&self, email: &str) -> DBResult { + match sqlx::query!("SELECT name from mcaptcha_users WHERE email = ?", email) + .fetch_one(&self.pool) + .await + { + Ok(_) => Ok(true), + Err(sqlx::Error::RowNotFound) => Ok(false), + Err(e) => Err(map_register_err(e)), + } + } + + /// update a user's email + async fn update_email(&self, p: &UpdateEmail) -> DBResult<()> { + sqlx::query!( + "UPDATE mcaptcha_users set email = ? + WHERE name = ?", + &p.new_email, + &p.username, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?; + + Ok(()) + } + + /// get a user's password + async fn get_password(&self, l: &Login) -> DBResult { + struct Password { + name: String, + password: String, + } + + let rec = match l { + Login::Username(u) => sqlx::query_as!( + Password, + r#"SELECT name, password FROM mcaptcha_users WHERE name = ?"#, + u, + ) + .fetch_one(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?, + + Login::Email(e) => sqlx::query_as!( + Password, + r#"SELECT name, password FROM mcaptcha_users WHERE email = ?"#, + e, + ) + .fetch_one(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?, + }; + + let res = NameHash { + hash: rec.password, + username: rec.name, + }; + + Ok(res) + } + + /// update user's password + async fn update_password(&self, p: &NameHash) -> DBResult<()> { + sqlx::query!( + "UPDATE mcaptcha_users set password = ? + WHERE name = ?", + &p.hash, + &p.username, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?; + + Ok(()) + } + + /// update username + async fn update_username(&self, current: &str, new: &str) -> DBResult<()> { + sqlx::query!( + "UPDATE mcaptcha_users set name = ? + WHERE name = ?", + new, + current, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?; + + Ok(()) + } + + /// get a user's secret + async fn get_secret(&self, username: &str) -> DBResult { + let secret = sqlx::query_as!( + Secret, + r#"SELECT secret FROM mcaptcha_users WHERE name = ?"#, + username, + ) + .fetch_one(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?; + + Ok(secret) + } + + /// update a user's secret + async fn update_secret(&self, username: &str, secret: &str) -> DBResult<()> { + sqlx::query!( + "UPDATE mcaptcha_users set secret = ? + WHERE name = ?", + &secret, + &username, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?; + + Ok(()) + } + + /// create new captcha + async fn create_captcha(&self, username: &str, p: &CreateCaptcha) -> DBResult<()> { + sqlx::query!( + "INSERT INTO mcaptcha_config + (`captcha_key`, `user_id`, `duration`, `name`) + VALUES (?, (SELECT ID FROM mcaptcha_users WHERE name = ?), ?, ?)", + p.key, + username, + p.duration as i32, + p.description, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?; + + Ok(()) + } + + /// Get captcha config + async fn get_captcha_config(&self, username: &str, key: &str) -> DBResult { + let captcha = sqlx::query_as!( + InternaleCaptchaConfig, + "SELECT `config_id`, `duration`, `name`, `captcha_key` from mcaptcha_config WHERE + `captcha_key` = ? AND + user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) ", + &key, + &username, + ) + .fetch_one(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + + Ok(captcha.into()) + } + + /// Get all captchas belonging to user + async fn get_all_user_captchas(&self, username: &str) -> DBResult> { + let mut res = sqlx::query_as!( + InternaleCaptchaConfig, + "SELECT captcha_key, name, config_id, duration FROM mcaptcha_config WHERE + user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) ", + &username, + ) + .fetch_all(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?; + + let mut captchas = Vec::with_capacity(res.len()); + + res.drain(0..).for_each(|r| captchas.push(r.into())); + + Ok(captchas) + } + + /// update captcha metadata; doesn't change captcha key + async fn update_captcha_metadata( + &self, + username: &str, + p: &CreateCaptcha, + ) -> DBResult<()> { + sqlx::query!( + "UPDATE mcaptcha_config SET name = ?, duration = ? + WHERE user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) + AND captcha_key = ?", + p.description, + p.duration, + username, + p.key, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + + Ok(()) + } + + /// update captcha key; doesn't change metadata + async fn update_captcha_key( + &self, + username: &str, + old_key: &str, + new_key: &str, + ) -> DBResult<()> { + sqlx::query!( + "UPDATE mcaptcha_config SET captcha_key = ? + WHERE captcha_key = ? AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)", + new_key, + old_key, + username, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + + Ok(()) + } + + /// Add levels to captcha + async fn add_captcha_levels( + &self, + username: &str, + captcha_key: &str, + levels: &[Level], + ) -> DBResult<()> { + use futures::future::try_join_all; + let mut futs = Vec::with_capacity(levels.len()); + + for level in levels.iter() { + let difficulty_factor = level.difficulty_factor as i32; + let visitor_threshold = level.visitor_threshold as i32; + let fut = sqlx::query!( + "INSERT INTO mcaptcha_levels ( + difficulty_factor, + visitor_threshold, + config_id) VALUES ( + ?, ?, ( + SELECT config_id FROM mcaptcha_config WHERE + captcha_key = (?) AND user_id = ( + SELECT ID FROM mcaptcha_users WHERE name = ? + )));", + difficulty_factor, + visitor_threshold, + &captcha_key, + username, + ) + .execute(&self.pool); + futs.push(fut); + } + + try_join_all(futs) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + + Ok(()) + } + + /// check if captcha exists + async fn captcha_exists( + &self, + username: Option<&str>, + captcha_key: &str, + ) -> DBResult { + // let mut exists = false; + + #[allow(dead_code)] + struct ConfigId { + config_id: i32, + } + let res = match username { + Some(username) => { + sqlx::query_as!( + ConfigId, + "SELECT config_id FROM mcaptcha_config + WHERE + captcha_key = ? + AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)", + captcha_key, + username + ) + .fetch_one(&self.pool) + .await + // if let Some(x) = x.exists { + // exists = x; + // }; + } + + None => { + sqlx::query_as!( + ConfigId, + "SELECT config_id from mcaptcha_config WHERE captcha_key = ?", + &captcha_key, + ) + .fetch_one(&self.pool) + .await + } //if let Some(x) = x.exists { + // exists = x; + //}; + }; + match res { + Ok(_) => Ok(true), + Err(sqlx::Error::RowNotFound) => Ok(false), + Err(e) => Err(map_register_err(e)), + } + } + + /// Delete all levels of a captcha + async fn delete_captcha_levels( + &self, + username: &str, + captcha_key: &str, + ) -> DBResult<()> { + sqlx::query!( + "DELETE FROM mcaptcha_levels + WHERE config_id = ( + SELECT config_id FROM mcaptcha_config where captcha_key= (?) + AND user_id = ( + SELECT ID from mcaptcha_users WHERE name = ? + ) + )", + captcha_key, + username + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + + Ok(()) + } + + /// Delete captcha + async fn delete_captcha(&self, username: &str, captcha_key: &str) -> DBResult<()> { + sqlx::query!( + "DELETE FROM mcaptcha_config where captcha_key= (?) + AND + user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)", + captcha_key, + username, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + + Ok(()) + } + + /// Get captcha levels + async fn get_captcha_levels( + &self, + username: Option<&str>, + captcha_key: &str, + ) -> DBResult> { + struct I32Levels { + difficulty_factor: i32, + visitor_threshold: i32, + } + let levels = match username { + None => sqlx::query_as!( + I32Levels, + "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE + config_id = ( + SELECT config_id FROM mcaptcha_config where captcha_key= (?) + ) ORDER BY difficulty_factor ASC;", + captcha_key, + ) + .fetch_all(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?, + + Some(username) => sqlx::query_as!( + I32Levels, + "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE + config_id = ( + SELECT config_id FROM mcaptcha_config where captcha_key= (?) + AND user_id = (SELECT ID from mcaptcha_users WHERE name = ?) + ) + ORDER BY difficulty_factor ASC;", + captcha_key, + username + ) + .fetch_all(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?, + }; + + let mut new_levels = Vec::with_capacity(levels.len()); + for l in levels.iter() { + new_levels.push(Level { + difficulty_factor: l.difficulty_factor as u32, + visitor_threshold: l.visitor_threshold as u32, + }); + } + Ok(new_levels) + } + + /// Get captcha's cooldown period + async fn get_captcha_cooldown(&self, captcha_key: &str) -> DBResult { + struct DurationResp { + duration: i32, + } + + let resp = sqlx::query_as!( + DurationResp, + "SELECT duration FROM mcaptcha_config + where captcha_key= ?", + captcha_key, + ) + .fetch_one(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + + Ok(resp.duration) + } + /// Add traffic configuration + async fn add_traffic_pattern( + &self, + username: &str, + captcha_key: &str, + pattern: &TrafficPattern, + ) -> DBResult<()> { + sqlx::query!( + "INSERT INTO mcaptcha_sitekey_user_provided_avg_traffic ( + config_id, + avg_traffic, + peak_sustainable_traffic, + broke_my_site_traffic + ) VALUES ( + (SELECT config_id FROM mcaptcha_config where captcha_key= (?) + AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) + ), ?, ?, ?)", + //payload.avg_traffic, + captcha_key, + username, + pattern.avg_traffic as i32, + pattern.peak_sustainable_traffic as i32, + pattern.broke_my_site_traffic.as_ref().map(|v| *v as i32), + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + Ok(()) + } + + /// Get traffic configuration + async fn get_traffic_pattern( + &self, + username: &str, + captcha_key: &str, + ) -> DBResult { + struct Traffic { + peak_sustainable_traffic: i32, + avg_traffic: i32, + broke_my_site_traffic: Option, + } + let res = sqlx::query_as!( + Traffic, + "SELECT + avg_traffic, + peak_sustainable_traffic, + broke_my_site_traffic + FROM + mcaptcha_sitekey_user_provided_avg_traffic + WHERE + config_id = ( + SELECT + config_id + FROM + mcaptcha_config + WHERE + captcha_key = ? + AND user_id = ( + SELECT + id + FROM + mcaptcha_users + WHERE + NAME = ? + ) + ) + ", + captcha_key, + username + ) + .fetch_one(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::TrafficPatternNotFound))?; + Ok(TrafficPattern { + broke_my_site_traffic: res.broke_my_site_traffic.as_ref().map(|v| *v as u32), + avg_traffic: res.avg_traffic as u32, + peak_sustainable_traffic: res.peak_sustainable_traffic as u32, + }) + } + + /// Delete traffic configuration + async fn delete_traffic_pattern( + &self, + username: &str, + captcha_key: &str, + ) -> DBResult<()> { + sqlx::query!( + "DELETE FROM mcaptcha_sitekey_user_provided_avg_traffic + WHERE config_id = ( + SELECT config_id + FROM + mcaptcha_config + WHERE + captcha_key = ? + AND + user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) + );", + captcha_key, + username, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::TrafficPatternNotFound))?; + Ok(()) + } + + /// create new notification + async fn create_notification(&self, p: &AddNotification) -> DBResult<()> { + let now = now_unix_time_stamp(); + sqlx::query!( + "INSERT INTO mcaptcha_notifications ( + heading, message, tx, rx, received) + VALUES ( + ?, ?, + (SELECT ID FROM mcaptcha_users WHERE name = ?), + (SELECT ID FROM mcaptcha_users WHERE name = ?), + ? + );", + p.heading, + p.message, + p.from, + p.to, + now + ) + .execute(&self.pool) + .await + .map_err(map_register_err)?; + + Ok(()) + } + + /// get all unread notifications + async fn get_all_unread_notifications( + &self, + username: &str, + ) -> DBResult> { + let mut inner_notifications = sqlx::query_file_as!( + InnerNotification, + "./src/get_all_unread_notifications.sql", + &username + ) + .fetch_all(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?; + + let mut notifications = Vec::with_capacity(inner_notifications.len()); + + inner_notifications + .drain(0..) + .for_each(|n| notifications.push(n.into())); + + Ok(notifications) + } + + /// mark a notification read + async fn mark_notification_read(&self, username: &str, id: i32) -> DBResult<()> { + sqlx::query_file_as!( + Notification, + "./src/mark_notification_read.sql", + id, + &username + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::NotificationNotFound))?; + + Ok(()) + } + + /// record PoWConfig fetches + async fn record_fetch(&self, key: &str) -> DBResult<()> { + let now = now_unix_time_stamp(); + let _ = sqlx::query!( + "INSERT INTO mcaptcha_pow_fetched_stats + (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)", + key, + &now, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + Ok(()) + } + + /// record PoWConfig solves + async fn record_solve(&self, key: &str) -> DBResult<()> { + let now = OffsetDateTime::now_utc(); + let _ = sqlx::query!( + "INSERT INTO mcaptcha_pow_solved_stats + (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)", + key, + &now, + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + Ok(()) + } + + /// record PoWConfig confirms + async fn record_confirm(&self, key: &str) -> DBResult<()> { + let now = now_unix_time_stamp(); + let _ = sqlx::query!( + "INSERT INTO mcaptcha_pow_confirmed_stats + (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)", + key, + &now + ) + .execute(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + Ok(()) + } + + /// featch PoWConfig fetches + async fn fetch_config_fetched(&self, user: &str, key: &str) -> DBResult> { + let records = sqlx::query_as!( + Date, + "SELECT time FROM mcaptcha_pow_fetched_stats + WHERE + config_id = ( + SELECT + config_id FROM mcaptcha_config + WHERE + captcha_key = ? + AND + user_id = ( + SELECT + ID FROM mcaptcha_users WHERE name = ?)) + ORDER BY time DESC", + &key, + &user, + ) + .fetch_all(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + + Ok(Date::dates_to_unix(records)) + } + + /// featch PoWConfig solves + async fn fetch_solve(&self, user: &str, key: &str) -> DBResult> { + let records = sqlx::query_as!( + Date, + "SELECT time FROM mcaptcha_pow_solved_stats + WHERE config_id = ( + SELECT config_id FROM mcaptcha_config + WHERE + captcha_key = ? + AND + user_id = ( + SELECT + ID FROM mcaptcha_users WHERE name = ?)) + ORDER BY time DESC", + &key, + &user + ) + .fetch_all(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + + Ok(Date::dates_to_unix(records)) + } + + /// featch PoWConfig confirms + async fn fetch_confirm(&self, user: &str, key: &str) -> DBResult> { + let records = sqlx::query_as!( + Date, + "SELECT time FROM mcaptcha_pow_confirmed_stats + WHERE + config_id = ( + SELECT config_id FROM mcaptcha_config + WHERE + captcha_key = ? + AND + user_id = ( + SELECT + ID FROM mcaptcha_users WHERE name = ?)) + ORDER BY time DESC", + &key, + &user + ) + .fetch_all(&self.pool) + .await + .map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?; + + Ok(Date::dates_to_unix(records)) + } +} + +#[derive(Clone)] +struct Date { + time: OffsetDateTime, +} + +impl Date { + fn dates_to_unix(mut d: Vec) -> Vec { + let mut dates = Vec::with_capacity(d.len()); + d.drain(0..) + .for_each(|x| dates.push(x.time.unix_timestamp())); + dates + } +} + +fn now_unix_time_stamp() -> OffsetDateTime { + OffsetDateTime::now_utc() +} + +#[derive(Debug, Clone, PartialEq)] +/// Represents notification +pub struct InnerNotification { + /// receiver name of the notification + pub name: String, + /// heading of the notification + pub heading: String, + /// message of the notification + pub message: String, + /// when notification was received + pub received: OffsetDateTime, + /// db assigned ID of the notification + pub id: i32, +} + +impl From for Notification { + fn from(n: InnerNotification) -> Self { + Notification { + name: Some(n.name), + heading: Some(n.heading), + message: Some(n.message), + received: Some(n.received.unix_timestamp()), + id: Some(n.id), + } + } +} + +#[derive(Clone)] +struct InternaleCaptchaConfig { + config_id: i32, + duration: i32, + name: String, + captcha_key: String, +} + +impl From for Captcha { + fn from(i: InternaleCaptchaConfig) -> Self { + Self { + config_id: i.config_id, + duration: i.duration, + description: i.name, + key: i.captcha_key, + } + } +} diff --git a/db/db-sqlx-maria/src/mark_notification_read.sql b/db/db-sqlx-maria/src/mark_notification_read.sql new file mode 100644 index 00000000..9a19e0bb --- /dev/null +++ b/db/db-sqlx-maria/src/mark_notification_read.sql @@ -0,0 +1,14 @@ +-- mark a notification as read +UPDATE mcaptcha_notifications + SET read_notification = TRUE +WHERE + mcaptcha_notifications.id = ? +AND + mcaptcha_notifications.rx = ( + SELECT + id + FROM + mcaptcha_users + WHERE + name = ? + ); diff --git a/db/db-sqlx-maria/src/tests.rs b/db/db-sqlx-maria/src/tests.rs new file mode 100644 index 00000000..62fe290f --- /dev/null +++ b/db/db-sqlx-maria/src/tests.rs @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2022 Aravinth Manivannan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#![cfg(test)] + +use sqlx::mysql::MySqlPoolOptions; +use std::env; + +use crate::*; + +use db_core::tests::*; + +#[actix_rt::test] +async fn everyting_works() { + const EMAIL: &str = "mariadbuser@foo.com"; + const NAME: &str = "mariadbuser"; + const PASSWORD: &str = "pasdfasdfasdfadf"; + const SECRET1: &str = "mariadbsecret1"; + // captcha config + const CAPTCHA_SECRET: &str = "mariadbcaptchasecret"; + const CAPTCHA_DESCRIPTION: &str = "mariadbcaptchadescription"; + const CAPTCHA_DURATION: i32 = 30; + // notification config + const HEADING: &str = "testing notifications get db mariadb"; + const MESSAGE: &str = "testing notifications get message db mariadb"; + + // easy traffic pattern + const TRAFFIC_PATTERN: TrafficPattern = TrafficPattern { + avg_traffic: 500, + peak_sustainable_traffic: 5_000, + broke_my_site_traffic: Some(10_000), + }; + + const LEVELS: [Level; 3] = [ + Level { + difficulty_factor: 1, + visitor_threshold: 1, + }, + Level { + difficulty_factor: 2, + visitor_threshold: 2, + }, + Level { + difficulty_factor: 3, + visitor_threshold: 3, + }, + ]; + + const ADD_NOTIFICATION: AddNotification = AddNotification { + from: NAME, + to: NAME, + message: MESSAGE, + heading: HEADING, + }; + + let url = env::var("MARIA_DATABASE_URL").unwrap(); + let pool_options = MySqlPoolOptions::new().max_connections(2); + let connection_options = ConnectionOptions::Fresh(Fresh { + pool_options, + url, + disable_logging: false, + }); + let db = connection_options.connect().await.unwrap(); + + db.migrate().await.unwrap(); + let p = Register { + username: NAME, + email: Some(EMAIL), + hash: PASSWORD, + secret: SECRET1, + }; + + let c = CreateCaptcha { + duration: CAPTCHA_DURATION, + key: CAPTCHA_SECRET, + description: CAPTCHA_DESCRIPTION, + }; + database_works(&db, &p, &c, &LEVELS, &TRAFFIC_PATTERN, &ADD_NOTIFICATION).await; +} diff --git a/db/db-sqlx-maria/target/sqlx/query-02f728d61701808148f7de4697ccab05f55e1014a2c8d1f4f1244e1ad4d831f0.json b/db/db-sqlx-maria/target/sqlx/query-02f728d61701808148f7de4697ccab05f55e1014a2c8d1f4f1244e1ad4d831f0.json new file mode 100644 index 00000000..f623126f --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-02f728d61701808148f7de4697ccab05f55e1014a2c8d1f4f1244e1ad4d831f0.json @@ -0,0 +1,39 @@ +{ + "query": "SELECT name, password FROM mcaptcha_users WHERE email = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 1, + "name": "password", + "type_info": { + "type": "Blob", + "flags": { + "bits": 4113 + }, + "char_set": 224, + "max_size": 262140 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false + ] + }, + "hash": "ed943cbf7e16536d81010255ce2f5beb207b2b9d44cb859fa9f2233405b80ae0" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-07e28adbb89bae614bba0c0904f15b822f0f0105b76acdf96858e7024cec58a1.json b/db/db-sqlx-maria/target/sqlx/query-07e28adbb89bae614bba0c0904f15b822f0f0105b76acdf96858e7024cec58a1.json new file mode 100644 index 00000000..adc9ba33 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-07e28adbb89bae614bba0c0904f15b822f0f0105b76acdf96858e7024cec58a1.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_users \n (name , password, secret) VALUES (?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + }, + "hash": "5d5a106981345e9f62bc2239c00cdc683d3aaaa820d63da300dc51e3f6f363d3" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-097b3442a187b47dc14fdf38fe17d3ab67af26919be4274c9e9e1b44a7a561f2.json b/db/db-sqlx-maria/target/sqlx/query-097b3442a187b47dc14fdf38fe17d3ab67af26919be4274c9e9e1b44a7a561f2.json new file mode 100644 index 00000000..bbd5c73b --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-097b3442a187b47dc14fdf38fe17d3ab67af26919be4274c9e9e1b44a7a561f2.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_notifications (\n heading, message, tx, rx, received)\n VALUES (\n ?, ?,\n (SELECT ID FROM mcaptcha_users WHERE name = ?),\n (SELECT ID FROM mcaptcha_users WHERE name = ?),\n ?\n );", + "describe": { + "columns": [], + "parameters": { + "Right": 5 + }, + "nullable": [] + }, + "hash": "89386c46668a2653a54687e65958af5cf7a8da268339a1f5a379ede47b3c6d2a" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-0a7a833bea3fe85f63c5c79272a9654b81ccbf502db5465dbde99bbbac8cc504.json b/db/db-sqlx-maria/target/sqlx/query-0a7a833bea3fe85f63c5c79272a9654b81ccbf502db5465dbde99bbbac8cc504.json new file mode 100644 index 00000000..4dff4f69 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-0a7a833bea3fe85f63c5c79272a9654b81ccbf502db5465dbde99bbbac8cc504.json @@ -0,0 +1,39 @@ +{ + "query": "SELECT name, password FROM mcaptcha_users WHERE name = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 1, + "name": "password", + "type_info": { + "type": "Blob", + "flags": { + "bits": 4113 + }, + "char_set": 224, + "max_size": 262140 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false + ] + }, + "hash": "dd5ff10b88fa6f374e105b6bed9e34e0870ac8dd7ce36dfb09d13a1b7005b2eb" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-0cc3965bf873878964fcf8f49c15e8f18f3aa46704023f2c0390f2ca452a29c6.json b/db/db-sqlx-maria/target/sqlx/query-0cc3965bf873878964fcf8f49c15e8f18f3aa46704023f2c0390f2ca452a29c6.json new file mode 100644 index 00000000..e842b3a8 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-0cc3965bf873878964fcf8f49c15e8f18f3aa46704023f2c0390f2ca452a29c6.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_config SET captcha_key = ? \n WHERE captcha_key = ? AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + }, + "hash": "8e6026abf7c0e8ab90ee8eb7ada9f66962ab6999d3127944b058d6f96346e72f" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-0ea092b8e99aaf89ce8f594bb6bea1f4d1a7864c618afc8303e70834661bc322.json b/db/db-sqlx-maria/target/sqlx/query-0ea092b8e99aaf89ce8f594bb6bea1f4d1a7864c618afc8303e70834661bc322.json new file mode 100644 index 00000000..1591379a --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-0ea092b8e99aaf89ce8f594bb6bea1f4d1a7864c618afc8303e70834661bc322.json @@ -0,0 +1,65 @@ +{ + "query": "SELECT captcha_key, name, config_id, duration FROM mcaptcha_config WHERE\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "captcha_key", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 1, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4097 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 2, + "name": "config_id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 3, + "name": "duration", + "type_info": { + "type": "Long", + "flags": { + "bits": 1 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "3812693a9ae4402d900bcbf680981e6194073bd1937af11a77daa3776fb4c873" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-0f332230c9bf9073ca76e4c2d12d830c108152dda38b21a3fb79d6d8bbafbfe4.json b/db/db-sqlx-maria/target/sqlx/query-0f332230c9bf9073ca76e4c2d12d830c108152dda38b21a3fb79d6d8bbafbfe4.json new file mode 100644 index 00000000..47a43b8c --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-0f332230c9bf9073ca76e4c2d12d830c108152dda38b21a3fb79d6d8bbafbfe4.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_users set email = ?\n WHERE name = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "9cb416de904872d66af90baa0024f382ce6f8344464c607fe6e6c2572816dfc2" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-0f5073c130439cbd8af6a32652953bd02b384abb520cd86a0677252d195e126d.json b/db/db-sqlx-maria/target/sqlx/query-0f5073c130439cbd8af6a32652953bd02b384abb520cd86a0677252d195e126d.json new file mode 100644 index 00000000..e842b3a8 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-0f5073c130439cbd8af6a32652953bd02b384abb520cd86a0677252d195e126d.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_config SET captcha_key = ? \n WHERE captcha_key = ? AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + }, + "hash": "8e6026abf7c0e8ab90ee8eb7ada9f66962ab6999d3127944b058d6f96346e72f" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-158a5b368a1cc649ea0cad755ac3db896d0e70758d73bd2fee0b0f84100c62bf.json b/db/db-sqlx-maria/target/sqlx/query-158a5b368a1cc649ea0cad755ac3db896d0e70758d73bd2fee0b0f84100c62bf.json new file mode 100644 index 00000000..4cd7af03 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-158a5b368a1cc649ea0cad755ac3db896d0e70758d73bd2fee0b0f84100c62bf.json @@ -0,0 +1,11 @@ +{ + "query": "DELETE FROM mcaptcha_sitekey_user_provided_avg_traffic\n WHERE config_id = (\n SELECT config_id \n FROM \n mcaptcha_config \n WHERE\n captcha_key = ?\n AND \n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n );", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "fc717ff0827ccfaa1cc61a71cc7f71c348ebb03d35895c54b011c03121ad2385" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-1d5eb46e28800b99de9aceb23e1ab2df84b1d366d2da23fcf91bee7aeb57c150.json b/db/db-sqlx-maria/target/sqlx/query-1d5eb46e28800b99de9aceb23e1ab2df84b1d366d2da23fcf91bee7aeb57c150.json new file mode 100644 index 00000000..38491ffa --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-1d5eb46e28800b99de9aceb23e1ab2df84b1d366d2da23fcf91bee7aeb57c150.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_users set password = ?\n WHERE name = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "cad5b403470f26c565e74a1dca19b7dee066141dec0f708070067e34d5bf72cc" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-224e80197d11caaded6fac021109949340cee94109f4dc74a0f88f473d85f9d2.json b/db/db-sqlx-maria/target/sqlx/query-224e80197d11caaded6fac021109949340cee94109f4dc74a0f88f473d85f9d2.json new file mode 100644 index 00000000..d3296840 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-224e80197d11caaded6fac021109949340cee94109f4dc74a0f88f473d85f9d2.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT config_id FROM mcaptcha_config\n WHERE\n captcha_key = ? \n AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "config_id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false + ] + }, + "hash": "66ec7df10484f8e0206f3c97afc9136021589556c38dbbed341d6574487f79f2" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-24000e17c9f323b887f25c78380a7fd40e6a208ed6154b63b89a54a77b986cf9.json b/db/db-sqlx-maria/target/sqlx/query-24000e17c9f323b887f25c78380a7fd40e6a208ed6154b63b89a54a77b986cf9.json new file mode 100644 index 00000000..2f6cb49c --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-24000e17c9f323b887f25c78380a7fd40e6a208ed6154b63b89a54a77b986cf9.json @@ -0,0 +1,11 @@ +{ + "query": "DELETE FROM mcaptcha_levels \n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?) \n AND user_id = (\n SELECT ID from mcaptcha_users WHERE name = ?\n )\n )", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "7894dda54cd65559fe3b81bab7df8cc848e21ed5c7f5e88951bf1c98c78ed820" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-2482c80253baa2c6f9468cad07d46dab576cd5aa60b60d91a49ad50087f27600.json b/db/db-sqlx-maria/target/sqlx/query-2482c80253baa2c6f9468cad07d46dab576cd5aa60b60d91a49ad50087f27600.json new file mode 100644 index 00000000..a72b455c --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-2482c80253baa2c6f9468cad07d46dab576cd5aa60b60d91a49ad50087f27600.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT duration FROM mcaptcha_config \n where captcha_key= ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "duration", + "type_info": { + "type": "Long", + "flags": { + "bits": 1 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "8acbf84d4801e86221d8f6324ae50488a0986182d66b20ad414bce4e2ac18eca" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-25a219dac97706cb910c5e1d0f33415bc086f17e5e594ef52db2ab9c190f55ef.json b/db/db-sqlx-maria/target/sqlx/query-25a219dac97706cb910c5e1d0f33415bc086f17e5e594ef52db2ab9c190f55ef.json new file mode 100644 index 00000000..c2701567 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-25a219dac97706cb910c5e1d0f33415bc086f17e5e594ef52db2ab9c190f55ef.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_users set name = ?\n WHERE name = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "676a9f1761c3b63cf16d7d4dd6261507cc7707feb32d458f4b946ed9caa53721" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-2669fa9729fb661d2a9849566e13682ab4a2c556073b260f24f33bee794dd8c3.json b/db/db-sqlx-maria/target/sqlx/query-2669fa9729fb661d2a9849566e13682ab4a2c556073b260f24f33bee794dd8c3.json new file mode 100644 index 00000000..a8b603e2 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-2669fa9729fb661d2a9849566e13682ab4a2c556073b260f24f33bee794dd8c3.json @@ -0,0 +1,65 @@ +{ + "query": "SELECT `config_id`, `duration`, `name`, `captcha_key` from mcaptcha_config WHERE\n `captcha_key` = ? AND\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "config_id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 1, + "name": "duration", + "type_info": { + "type": "Long", + "flags": { + "bits": 1 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 2, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4097 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 3, + "name": "captcha_key", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "9c435148ed5655e79dd1e73e3566ce23b7c6d38edcedbb988c95813c5da893ed" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-2c61a6af4c984fe9b824ec33f0f7453131e1ec94b0ab0d8ae1c38ae7708865a7.json b/db/db-sqlx-maria/target/sqlx/query-2c61a6af4c984fe9b824ec33f0f7453131e1ec94b0ab0d8ae1c38ae7708865a7.json new file mode 100644 index 00000000..3ce256c1 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-2c61a6af4c984fe9b824ec33f0f7453131e1ec94b0ab0d8ae1c38ae7708865a7.json @@ -0,0 +1,11 @@ +{ + "query": "DELETE FROM mcaptcha_config where captcha_key= (?)\n AND\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "b95e5a60a202cb646d5e76df8c7395e4bf881a6dd14e28e6f2e8b93e0536b331" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-2d6c8ca1532dbafc10404fc6615a4d8fc07ccc36b37b286633296352a76b9901.json b/db/db-sqlx-maria/target/sqlx/query-2d6c8ca1532dbafc10404fc6615a4d8fc07ccc36b37b286633296352a76b9901.json new file mode 100644 index 00000000..bea83de1 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-2d6c8ca1532dbafc10404fc6615a4d8fc07ccc36b37b286633296352a76b9901.json @@ -0,0 +1,39 @@ +{ + "query": "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n AND user_id = (SELECT ID from mcaptcha_users WHERE name = ?)\n )\n ORDER BY difficulty_factor ASC;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "difficulty_factor", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 1, + "name": "visitor_threshold", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false + ] + }, + "hash": "df6de3b96afcfb7f364f98954995e506b19e80e7f88204405d970c360ad5e1a0" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-2f530bc3e7a262cee2b789be9716665caf3548fed8e57a1c76745096ce10f735.json b/db/db-sqlx-maria/target/sqlx/query-2f530bc3e7a262cee2b789be9716665caf3548fed8e57a1c76745096ce10f735.json new file mode 100644 index 00000000..7888d37f --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-2f530bc3e7a262cee2b789be9716665caf3548fed8e57a1c76745096ce10f735.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_config\n (`captcha_key`, `user_id`, `duration`, `name`)\n VALUES (?, (SELECT ID FROM mcaptcha_users WHERE name = ?), ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + }, + "hash": "d05b84966f4e70c53789221f961bf3637f404f3ba45e880115e97ed1ba5a2809" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-354bc66833932a507482b8d746667bd34fa0a4c65c2eb6a64819c5db29adb597.json b/db/db-sqlx-maria/target/sqlx/query-354bc66833932a507482b8d746667bd34fa0a4c65c2eb6a64819c5db29adb597.json new file mode 100644 index 00000000..10fa6159 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-354bc66833932a507482b8d746667bd34fa0a4c65c2eb6a64819c5db29adb597.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_levels (\n difficulty_factor, \n visitor_threshold,\n config_id) VALUES (\n ?, ?, (\n SELECT config_id FROM mcaptcha_config WHERE\n captcha_key = (?) AND user_id = (\n SELECT ID FROM mcaptcha_users WHERE name = ?\n )));", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + }, + "hash": "74d68a86f852d3d85957e94ed04e8acd8e6144744f7b13e383ebcb2bcf3360ae" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-3be506902d4793b86340640ec056b713566c9a76b1bdfe4ecb0ead0a4270ef13.json b/db/db-sqlx-maria/target/sqlx/query-3be506902d4793b86340640ec056b713566c9a76b1bdfe4ecb0ead0a4270ef13.json new file mode 100644 index 00000000..36531b00 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-3be506902d4793b86340640ec056b713566c9a76b1bdfe4ecb0ead0a4270ef13.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_config SET name = ?, duration = ?\n WHERE user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n AND captcha_key = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + }, + "hash": "3a8381eb0f0542a492d9dd51368e769e2b313e0576a1873e5c7630011e463daf" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-3df96e0a9f6657c7127453a5437061469500fc3594d71dc346cc18a87b687c2f.json b/db/db-sqlx-maria/target/sqlx/query-3df96e0a9f6657c7127453a5437061469500fc3594d71dc346cc18a87b687c2f.json new file mode 100644 index 00000000..ef7adda8 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-3df96e0a9f6657c7127453a5437061469500fc3594d71dc346cc18a87b687c2f.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT email FROM mcaptcha_users WHERE name = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "email", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4 + }, + "char_set": 224, + "max_size": 400 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + true + ] + }, + "hash": "413ea53cea8b8f114fc009bad527b054a68a94477dfcc50d860d45bbd864d4f1" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-3dffd535c14f444bb8c7e2363c74244ebed7568e412630b1bb5cffac7e075ec0.json b/db/db-sqlx-maria/target/sqlx/query-3dffd535c14f444bb8c7e2363c74244ebed7568e412630b1bb5cffac7e075ec0.json new file mode 100644 index 00000000..0d0ef560 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-3dffd535c14f444bb8c7e2363c74244ebed7568e412630b1bb5cffac7e075ec0.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_users set secret = ?\n WHERE name = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "7838ade4a48068e25c6f117ee8e38f088b867b1ab08a7dd0269b76891266ace6" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-3ee4271bfb8ca5326682a07112bf9a98ee0219356d5c438c1acd91f61baf94a3.json b/db/db-sqlx-maria/target/sqlx/query-3ee4271bfb8ca5326682a07112bf9a98ee0219356d5c438c1acd91f61baf94a3.json new file mode 100644 index 00000000..2c90413c --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-3ee4271bfb8ca5326682a07112bf9a98ee0219356d5c438c1acd91f61baf94a3.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT name from mcaptcha_users WHERE email = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "caa1638ee510ef62b86817e5d2baeaca8dfa432c23d7630c0e70737211a4680b" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-3f17c7099eecb0704b8ad7b4cb02bc85f543130f5013b7a878652eca9215d36f.json b/db/db-sqlx-maria/target/sqlx/query-3f17c7099eecb0704b8ad7b4cb02bc85f543130f5013b7a878652eca9215d36f.json new file mode 100644 index 00000000..47a43b8c --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-3f17c7099eecb0704b8ad7b4cb02bc85f543130f5013b7a878652eca9215d36f.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_users set email = ?\n WHERE name = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "9cb416de904872d66af90baa0024f382ce6f8344464c607fe6e6c2572816dfc2" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-3f70f1b4eb3494c358d1e360189c82bf29d50f376faf3696a0e6fe1a6d78d2ac.json b/db/db-sqlx-maria/target/sqlx/query-3f70f1b4eb3494c358d1e360189c82bf29d50f376faf3696a0e6fe1a6d78d2ac.json new file mode 100644 index 00000000..7735b6d7 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-3f70f1b4eb3494c358d1e360189c82bf29d50f376faf3696a0e6fe1a6d78d2ac.json @@ -0,0 +1,39 @@ +{ + "query": "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n ) ORDER BY difficulty_factor ASC;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "difficulty_factor", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 1, + "name": "visitor_threshold", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false + ] + }, + "hash": "6d43e6ceb54a0ff8a803bd96dd9134b15da01d48776ac0cf3d66a2997dadce5e" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-407a463705faf766780d7e6160ec1123e858756b824a9577eff6dbfc1b068b59.json b/db/db-sqlx-maria/target/sqlx/query-407a463705faf766780d7e6160ec1123e858756b824a9577eff6dbfc1b068b59.json new file mode 100644 index 00000000..398fe3cd --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-407a463705faf766780d7e6160ec1123e858756b824a9577eff6dbfc1b068b59.json @@ -0,0 +1,78 @@ +{ + "query": "-- gets all unread notifications a user has\nSELECT \n mcaptcha_notifications.id,\n mcaptcha_notifications.heading,\n mcaptcha_notifications.message,\n mcaptcha_notifications.received,\n mcaptcha_users.name\nFROM\n mcaptcha_notifications \nINNER JOIN \n mcaptcha_users \nON \n mcaptcha_notifications.tx = mcaptcha_users.id\nWHERE \n mcaptcha_notifications.rx = (\n SELECT \n id \n FROM \n mcaptcha_users\n WHERE\n name = ?\n )\nAND \n mcaptcha_notifications.read_notification IS NULL;\n", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 1, + "name": "heading", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4097 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 2, + "name": "message", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4097 + }, + "char_set": 224, + "max_size": 1000 + } + }, + { + "ordinal": 3, + "name": "received", + "type_info": { + "type": "Timestamp", + "flags": { + "bits": 1185 + }, + "char_set": 63, + "max_size": 19 + } + }, + { + "ordinal": 4, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false, + false, + false + ] + }, + "hash": "b9b0c63380bc0dfdea8aae092dcefceb316fe94667d74f53d53063810cdd2ba8" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-44e2a73d8051007d9765190efd63f0a3e3bbca2e093c6007f98f9f3e7b990f59.json b/db/db-sqlx-maria/target/sqlx/query-44e2a73d8051007d9765190efd63f0a3e3bbca2e093c6007f98f9f3e7b990f59.json new file mode 100644 index 00000000..bbd5c73b --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-44e2a73d8051007d9765190efd63f0a3e3bbca2e093c6007f98f9f3e7b990f59.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_notifications (\n heading, message, tx, rx, received)\n VALUES (\n ?, ?,\n (SELECT ID FROM mcaptcha_users WHERE name = ?),\n (SELECT ID FROM mcaptcha_users WHERE name = ?),\n ?\n );", + "describe": { + "columns": [], + "parameters": { + "Right": 5 + }, + "nullable": [] + }, + "hash": "89386c46668a2653a54687e65958af5cf7a8da268339a1f5a379ede47b3c6d2a" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-467d567db84c717a9af27e7dd9a97b5b630a8568a90675ea62334f99877fc49e.json b/db/db-sqlx-maria/target/sqlx/query-467d567db84c717a9af27e7dd9a97b5b630a8568a90675ea62334f99877fc49e.json new file mode 100644 index 00000000..e7c31632 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-467d567db84c717a9af27e7dd9a97b5b630a8568a90675ea62334f99877fc49e.json @@ -0,0 +1,11 @@ +{ + "query": "DELETE FROM mcaptcha_users WHERE name = (?)", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + }, + "hash": "6d1b6e5e58ca2ba285cab7b050bbdc43de1f3e46cf7d420bc95c124a1c7c9d1f" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-48bd295d14e7cd91606216abc1a9a97ead59a2b2e6d4961c05ad368deda98fb9.json b/db/db-sqlx-maria/target/sqlx/query-48bd295d14e7cd91606216abc1a9a97ead59a2b2e6d4961c05ad368deda98fb9.json new file mode 100644 index 00000000..439988df --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-48bd295d14e7cd91606216abc1a9a97ead59a2b2e6d4961c05ad368deda98fb9.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_pow_confirmed_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "34b29417f9ff3f4d5987df0ce81023b1985eb84e560602b36182f55de6cd9d83" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce.json b/db/db-sqlx-maria/target/sqlx/query-4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce.json new file mode 100644 index 00000000..06ef859b --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_pow_solved_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "e2b0b85f2afac1cbca43ce684641bf75ef070e44ce3d00404fc6151d2f4d7bcf" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-51804ba9930fef6263231c911173fd423bd6668b0450edaf6f8e5cf82f1a910f.json b/db/db-sqlx-maria/target/sqlx/query-51804ba9930fef6263231c911173fd423bd6668b0450edaf6f8e5cf82f1a910f.json new file mode 100644 index 00000000..3e57fe7a --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-51804ba9930fef6263231c911173fd423bd6668b0450edaf6f8e5cf82f1a910f.json @@ -0,0 +1,11 @@ +{ + "query": "-- mark a notification as read\nUPDATE mcaptcha_notifications\n SET read_notification = TRUE\nWHERE \n mcaptcha_notifications.id = ?\nAND\n mcaptcha_notifications.rx = (\n SELECT\n id\n FROM\n mcaptcha_users\n WHERE\n name = ?\n );\n", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "cf333541509213f11a9bf7119dcb3289bb77abf1482fc1d47e7f5bb27bdc8d97" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-5263439119ce9bb0466d1c41b561534dee5aeae341209b0cf415f17fafc569c0.json b/db/db-sqlx-maria/target/sqlx/query-5263439119ce9bb0466d1c41b561534dee5aeae341209b0cf415f17fafc569c0.json new file mode 100644 index 00000000..7ef68e56 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-5263439119ce9bb0466d1c41b561534dee5aeae341209b0cf415f17fafc569c0.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_pow_fetched_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "598a8202942771eff460faa6f09bd3fb1fc910d5fab7edb07c49dadbbaeb1cb8" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-53f4fa4344f0c383ec00aa719d68937ac3e1ba71c66f68c8d6d0252e517bc269.json b/db/db-sqlx-maria/target/sqlx/query-53f4fa4344f0c383ec00aa719d68937ac3e1ba71c66f68c8d6d0252e517bc269.json new file mode 100644 index 00000000..6eedeedb --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-53f4fa4344f0c383ec00aa719d68937ac3e1ba71c66f68c8d6d0252e517bc269.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_sitekey_user_provided_avg_traffic (\n config_id,\n avg_traffic,\n peak_sustainable_traffic,\n broke_my_site_traffic\n ) VALUES ( \n (SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n ), ?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 5 + }, + "nullable": [] + }, + "hash": "22e697114c3ed5b0156cdceab11a398f1ef3a804f482e1cd948bc615ef95fc92" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-541a99f9b1b33e11ebc6d5499b57252f90549047b3236a48cb46a85040ceb145.json b/db/db-sqlx-maria/target/sqlx/query-541a99f9b1b33e11ebc6d5499b57252f90549047b3236a48cb46a85040ceb145.json new file mode 100644 index 00000000..ef7adda8 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-541a99f9b1b33e11ebc6d5499b57252f90549047b3236a48cb46a85040ceb145.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT email FROM mcaptcha_users WHERE name = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "email", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4 + }, + "char_set": 224, + "max_size": 400 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + true + ] + }, + "hash": "413ea53cea8b8f114fc009bad527b054a68a94477dfcc50d860d45bbd864d4f1" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-55c9d90d6ae45a67b40b0c64bcc74fbfde049a7d864428ee78da111c18039587.json b/db/db-sqlx-maria/target/sqlx/query-55c9d90d6ae45a67b40b0c64bcc74fbfde049a7d864428ee78da111c18039587.json new file mode 100644 index 00000000..a72b455c --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-55c9d90d6ae45a67b40b0c64bcc74fbfde049a7d864428ee78da111c18039587.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT duration FROM mcaptcha_config \n where captcha_key= ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "duration", + "type_info": { + "type": "Long", + "flags": { + "bits": 1 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "8acbf84d4801e86221d8f6324ae50488a0986182d66b20ad414bce4e2ac18eca" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-56963dfae6a74dc79d7ef540dcf94d3190e90c1f14accc2cf45f3655e7e1c631.json b/db/db-sqlx-maria/target/sqlx/query-56963dfae6a74dc79d7ef540dcf94d3190e90c1f14accc2cf45f3655e7e1c631.json new file mode 100644 index 00000000..eab898cb --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-56963dfae6a74dc79d7ef540dcf94d3190e90c1f14accc2cf45f3655e7e1c631.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT time FROM mcaptcha_pow_fetched_stats\n WHERE \n config_id = (\n SELECT \n config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?))\n ORDER BY time DESC", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "time", + "type_info": { + "type": "Timestamp", + "flags": { + "bits": 1185 + }, + "char_set": 63, + "max_size": 19 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false + ] + }, + "hash": "daac5e937aeac2f106eb89154b431fa8bd1bd7baa95e51704fdcdf50bd970a1d" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-60f7a6daa83aec666ce22f81a8085f92a52908da647788fbd6a78411756813ce.json b/db/db-sqlx-maria/target/sqlx/query-60f7a6daa83aec666ce22f81a8085f92a52908da647788fbd6a78411756813ce.json new file mode 100644 index 00000000..e7c11b30 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-60f7a6daa83aec666ce22f81a8085f92a52908da647788fbd6a78411756813ce.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT secret FROM mcaptcha_users WHERE name = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "secret", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 200 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "dd9b4dec39405ff19af21faabb6a7c3bb3207e7e785fe15357146b88c6c27f01" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-60fd8426d12a2cf38e30f4603150386e4f877af81f91a75811c7be7b6ecc7784.json b/db/db-sqlx-maria/target/sqlx/query-60fd8426d12a2cf38e30f4603150386e4f877af81f91a75811c7be7b6ecc7784.json new file mode 100644 index 00000000..71a1d0c0 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-60fd8426d12a2cf38e30f4603150386e4f877af81f91a75811c7be7b6ecc7784.json @@ -0,0 +1,11 @@ +{ + "query": "insert into mcaptcha_users \n (name , password, email, secret) values (?, ?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + }, + "hash": "8ec8bbde0c02a99f74d12e6778f123a973283e6d56b6861b30f559768617848a" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-633e9500936890b9e8cbb5d15ae662c31b1090158fb9a3efe2b89d2aa6338930.json b/db/db-sqlx-maria/target/sqlx/query-633e9500936890b9e8cbb5d15ae662c31b1090158fb9a3efe2b89d2aa6338930.json new file mode 100644 index 00000000..7ef68e56 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-633e9500936890b9e8cbb5d15ae662c31b1090158fb9a3efe2b89d2aa6338930.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_pow_fetched_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "598a8202942771eff460faa6f09bd3fb1fc910d5fab7edb07c49dadbbaeb1cb8" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-6e84588fec629d930a606b236d648b0cb57415ca3e8466c389978262a72e61c7.json b/db/db-sqlx-maria/target/sqlx/query-6e84588fec629d930a606b236d648b0cb57415ca3e8466c389978262a72e61c7.json new file mode 100644 index 00000000..2f6cb49c --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-6e84588fec629d930a606b236d648b0cb57415ca3e8466c389978262a72e61c7.json @@ -0,0 +1,11 @@ +{ + "query": "DELETE FROM mcaptcha_levels \n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?) \n AND user_id = (\n SELECT ID from mcaptcha_users WHERE name = ?\n )\n )", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "7894dda54cd65559fe3b81bab7df8cc848e21ed5c7f5e88951bf1c98c78ed820" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-735e6994816a36a30920faa2edfca83c007c63a3807d9a5729ed87e2a2f3581b.json b/db/db-sqlx-maria/target/sqlx/query-735e6994816a36a30920faa2edfca83c007c63a3807d9a5729ed87e2a2f3581b.json new file mode 100644 index 00000000..38491ffa --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-735e6994816a36a30920faa2edfca83c007c63a3807d9a5729ed87e2a2f3581b.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_users set password = ?\n WHERE name = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "cad5b403470f26c565e74a1dca19b7dee066141dec0f708070067e34d5bf72cc" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-78980c50d503e5cb539979688a25ef4fe397a302140884873379fac67f607893.json b/db/db-sqlx-maria/target/sqlx/query-78980c50d503e5cb539979688a25ef4fe397a302140884873379fac67f607893.json new file mode 100644 index 00000000..bea83de1 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-78980c50d503e5cb539979688a25ef4fe397a302140884873379fac67f607893.json @@ -0,0 +1,39 @@ +{ + "query": "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n AND user_id = (SELECT ID from mcaptcha_users WHERE name = ?)\n )\n ORDER BY difficulty_factor ASC;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "difficulty_factor", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 1, + "name": "visitor_threshold", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false + ] + }, + "hash": "df6de3b96afcfb7f364f98954995e506b19e80e7f88204405d970c360ad5e1a0" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-78ba1313da9936a875dd30e059364a8601b51a3297a48d6309c00807ec6cdc76.json b/db/db-sqlx-maria/target/sqlx/query-78ba1313da9936a875dd30e059364a8601b51a3297a48d6309c00807ec6cdc76.json new file mode 100644 index 00000000..0d0ef560 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-78ba1313da9936a875dd30e059364a8601b51a3297a48d6309c00807ec6cdc76.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_users set secret = ?\n WHERE name = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "7838ade4a48068e25c6f117ee8e38f088b867b1ab08a7dd0269b76891266ace6" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451.json b/db/db-sqlx-maria/target/sqlx/query-7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451.json new file mode 100644 index 00000000..4a35906f --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT config_id from mcaptcha_config WHERE captcha_key = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "config_id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "a89c066db044cddfdebee6a0fd0d80a5a26dcb7ecc00a9899f5634b72ea0a952" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-7be15faa11902f118c36c79370c268599c4f2df77829aa246a51697174d3388d.json b/db/db-sqlx-maria/target/sqlx/query-7be15faa11902f118c36c79370c268599c4f2df77829aa246a51697174d3388d.json new file mode 100644 index 00000000..d3296840 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-7be15faa11902f118c36c79370c268599c4f2df77829aa246a51697174d3388d.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT config_id FROM mcaptcha_config\n WHERE\n captcha_key = ? \n AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "config_id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false + ] + }, + "hash": "66ec7df10484f8e0206f3c97afc9136021589556c38dbbed341d6574487f79f2" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-7cf69b059ca4456dab967c22caef23713c00203b47ec5670cdfa42f2dc5ac5d0.json b/db/db-sqlx-maria/target/sqlx/query-7cf69b059ca4456dab967c22caef23713c00203b47ec5670cdfa42f2dc5ac5d0.json new file mode 100644 index 00000000..06ef859b --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-7cf69b059ca4456dab967c22caef23713c00203b47ec5670cdfa42f2dc5ac5d0.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_pow_solved_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "e2b0b85f2afac1cbca43ce684641bf75ef070e44ce3d00404fc6151d2f4d7bcf" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-86a129013555a1be6c521a5d3ef60e5819517c38cb2ebb192e4328a3d5d59f15.json b/db/db-sqlx-maria/target/sqlx/query-86a129013555a1be6c521a5d3ef60e5819517c38cb2ebb192e4328a3d5d59f15.json new file mode 100644 index 00000000..4dff4f69 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-86a129013555a1be6c521a5d3ef60e5819517c38cb2ebb192e4328a3d5d59f15.json @@ -0,0 +1,39 @@ +{ + "query": "SELECT name, password FROM mcaptcha_users WHERE name = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 1, + "name": "password", + "type_info": { + "type": "Blob", + "flags": { + "bits": 4113 + }, + "char_set": 224, + "max_size": 262140 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false + ] + }, + "hash": "dd5ff10b88fa6f374e105b6bed9e34e0870ac8dd7ce36dfb09d13a1b7005b2eb" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-928572cf7f6fd3bbca526b256f438733cfd56f8a18febf237b356b7a8099afc7.json b/db/db-sqlx-maria/target/sqlx/query-928572cf7f6fd3bbca526b256f438733cfd56f8a18febf237b356b7a8099afc7.json new file mode 100644 index 00000000..adc9ba33 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-928572cf7f6fd3bbca526b256f438733cfd56f8a18febf237b356b7a8099afc7.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_users \n (name , password, secret) VALUES (?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + }, + "hash": "5d5a106981345e9f62bc2239c00cdc683d3aaaa820d63da300dc51e3f6f363d3" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-9ef46bb3ab80736fca35e69d9a86d4233bda18e6e20221baca4c933cd69c281e.json b/db/db-sqlx-maria/target/sqlx/query-9ef46bb3ab80736fca35e69d9a86d4233bda18e6e20221baca4c933cd69c281e.json new file mode 100644 index 00000000..f623126f --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-9ef46bb3ab80736fca35e69d9a86d4233bda18e6e20221baca4c933cd69c281e.json @@ -0,0 +1,39 @@ +{ + "query": "SELECT name, password FROM mcaptcha_users WHERE email = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 1, + "name": "password", + "type_info": { + "type": "Blob", + "flags": { + "bits": 4113 + }, + "char_set": 224, + "max_size": 262140 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false + ] + }, + "hash": "ed943cbf7e16536d81010255ce2f5beb207b2b9d44cb859fa9f2233405b80ae0" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-9f49b26658755c993637ca328660a90a617e4be3bbb5562d85cec43b0b994df9.json b/db/db-sqlx-maria/target/sqlx/query-9f49b26658755c993637ca328660a90a617e4be3bbb5562d85cec43b0b994df9.json new file mode 100644 index 00000000..2c90413c --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-9f49b26658755c993637ca328660a90a617e4be3bbb5562d85cec43b0b994df9.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT name from mcaptcha_users WHERE email = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "caa1638ee510ef62b86817e5d2baeaca8dfa432c23d7630c0e70737211a4680b" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-a61bb8bd8a92308a29e047ff5efcfc957fe5ea3a60c4597d3a68404fc6da24a3.json b/db/db-sqlx-maria/target/sqlx/query-a61bb8bd8a92308a29e047ff5efcfc957fe5ea3a60c4597d3a68404fc6da24a3.json new file mode 100644 index 00000000..3d445027 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-a61bb8bd8a92308a29e047ff5efcfc957fe5ea3a60c4597d3a68404fc6da24a3.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT time FROM mcaptcha_pow_confirmed_stats \n WHERE \n config_id = (\n SELECT config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?))\n ORDER BY time DESC", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "time", + "type_info": { + "type": "Timestamp", + "flags": { + "bits": 1185 + }, + "char_set": 63, + "max_size": 19 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false + ] + }, + "hash": "1367dceb151a766a901b5dd771d0b75d0bc61d2fef17a94a90c8ffa0065e2c44" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-a763de03e370b22dba0a91f52a1b6289e984cb818ba7f450db2896e2b9ec10f6.json b/db/db-sqlx-maria/target/sqlx/query-a763de03e370b22dba0a91f52a1b6289e984cb818ba7f450db2896e2b9ec10f6.json new file mode 100644 index 00000000..10fa6159 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-a763de03e370b22dba0a91f52a1b6289e984cb818ba7f450db2896e2b9ec10f6.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_levels (\n difficulty_factor, \n visitor_threshold,\n config_id) VALUES (\n ?, ?, (\n SELECT config_id FROM mcaptcha_config WHERE\n captcha_key = (?) AND user_id = (\n SELECT ID FROM mcaptcha_users WHERE name = ?\n )));", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + }, + "hash": "74d68a86f852d3d85957e94ed04e8acd8e6144744f7b13e383ebcb2bcf3360ae" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-a7909e64e6f78e56ab2965e6789e4ddde828871e0ac862405f93a99d67d4b399.json b/db/db-sqlx-maria/target/sqlx/query-a7909e64e6f78e56ab2965e6789e4ddde828871e0ac862405f93a99d67d4b399.json new file mode 100644 index 00000000..4a35906f --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-a7909e64e6f78e56ab2965e6789e4ddde828871e0ac862405f93a99d67d4b399.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT config_id from mcaptcha_config WHERE captcha_key = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "config_id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "a89c066db044cddfdebee6a0fd0d80a5a26dcb7ecc00a9899f5634b72ea0a952" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-a9fab3b549f30955ad83e58d5810558263f591a6ff7ee5ca33086407ff0bb2a1.json b/db/db-sqlx-maria/target/sqlx/query-a9fab3b549f30955ad83e58d5810558263f591a6ff7ee5ca33086407ff0bb2a1.json new file mode 100644 index 00000000..ae0f35c8 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-a9fab3b549f30955ad83e58d5810558263f591a6ff7ee5ca33086407ff0bb2a1.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT name from mcaptcha_users WHERE name = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "e6569a6064d0e07abea4c0bd4686cdfdaac64f0109ac40efaed06a744a2eaf5e" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-af1f242ece4bfd6bca900dc7276b369f3ff261c2a5865c50e759ab48564cc747.json b/db/db-sqlx-maria/target/sqlx/query-af1f242ece4bfd6bca900dc7276b369f3ff261c2a5865c50e759ab48564cc747.json new file mode 100644 index 00000000..4a35906f --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-af1f242ece4bfd6bca900dc7276b369f3ff261c2a5865c50e759ab48564cc747.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT config_id from mcaptcha_config WHERE captcha_key = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "config_id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "a89c066db044cddfdebee6a0fd0d80a5a26dcb7ecc00a9899f5634b72ea0a952" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-b3fb7d1ab20ed1da96c37320a3029a9b027003c1646bbe4b477a4c7d078e81c7.json b/db/db-sqlx-maria/target/sqlx/query-b3fb7d1ab20ed1da96c37320a3029a9b027003c1646bbe4b477a4c7d078e81c7.json new file mode 100644 index 00000000..4cd7af03 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-b3fb7d1ab20ed1da96c37320a3029a9b027003c1646bbe4b477a4c7d078e81c7.json @@ -0,0 +1,11 @@ +{ + "query": "DELETE FROM mcaptcha_sitekey_user_provided_avg_traffic\n WHERE config_id = (\n SELECT config_id \n FROM \n mcaptcha_config \n WHERE\n captcha_key = ?\n AND \n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n );", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "fc717ff0827ccfaa1cc61a71cc7f71c348ebb03d35895c54b011c03121ad2385" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-bb135562b9e6935caf2808ff62906191e268a584b44a71372fce33f573631188.json b/db/db-sqlx-maria/target/sqlx/query-bb135562b9e6935caf2808ff62906191e268a584b44a71372fce33f573631188.json new file mode 100644 index 00000000..398fe3cd --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-bb135562b9e6935caf2808ff62906191e268a584b44a71372fce33f573631188.json @@ -0,0 +1,78 @@ +{ + "query": "-- gets all unread notifications a user has\nSELECT \n mcaptcha_notifications.id,\n mcaptcha_notifications.heading,\n mcaptcha_notifications.message,\n mcaptcha_notifications.received,\n mcaptcha_users.name\nFROM\n mcaptcha_notifications \nINNER JOIN \n mcaptcha_users \nON \n mcaptcha_notifications.tx = mcaptcha_users.id\nWHERE \n mcaptcha_notifications.rx = (\n SELECT \n id \n FROM \n mcaptcha_users\n WHERE\n name = ?\n )\nAND \n mcaptcha_notifications.read_notification IS NULL;\n", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 1, + "name": "heading", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4097 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 2, + "name": "message", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4097 + }, + "char_set": 224, + "max_size": 1000 + } + }, + { + "ordinal": 3, + "name": "received", + "type_info": { + "type": "Timestamp", + "flags": { + "bits": 1185 + }, + "char_set": 63, + "max_size": 19 + } + }, + { + "ordinal": 4, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false, + false, + false + ] + }, + "hash": "b9b0c63380bc0dfdea8aae092dcefceb316fe94667d74f53d53063810cdd2ba8" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-bc5686451a0e666e35a0a1e679ac3722388f08b7c400480be0e6e2f6113bf577.json b/db/db-sqlx-maria/target/sqlx/query-bc5686451a0e666e35a0a1e679ac3722388f08b7c400480be0e6e2f6113bf577.json new file mode 100644 index 00000000..e7c11b30 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-bc5686451a0e666e35a0a1e679ac3722388f08b7c400480be0e6e2f6113bf577.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT secret FROM mcaptcha_users WHERE name = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "secret", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 200 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "dd9b4dec39405ff19af21faabb6a7c3bb3207e7e785fe15357146b88c6c27f01" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-bf6bb8f3a360aaebd08164bb576b4144e568a3189c632ef6579cb0a91e9e616c.json b/db/db-sqlx-maria/target/sqlx/query-bf6bb8f3a360aaebd08164bb576b4144e568a3189c632ef6579cb0a91e9e616c.json new file mode 100644 index 00000000..ae0f35c8 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-bf6bb8f3a360aaebd08164bb576b4144e568a3189c632ef6579cb0a91e9e616c.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT name from mcaptcha_users WHERE name = ?", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "e6569a6064d0e07abea4c0bd4686cdfdaac64f0109ac40efaed06a744a2eaf5e" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-c44fcc84e3b3bfd28256bbe744b63194f14332bfa214424791f0feb00d33e557.json b/db/db-sqlx-maria/target/sqlx/query-c44fcc84e3b3bfd28256bbe744b63194f14332bfa214424791f0feb00d33e557.json new file mode 100644 index 00000000..e7c31632 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-c44fcc84e3b3bfd28256bbe744b63194f14332bfa214424791f0feb00d33e557.json @@ -0,0 +1,11 @@ +{ + "query": "DELETE FROM mcaptcha_users WHERE name = (?)", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + }, + "hash": "6d1b6e5e58ca2ba285cab7b050bbdc43de1f3e46cf7d420bc95c124a1c7c9d1f" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-c461d8b1a2f096f198671b03044b04023db1b35d5910dee5141d8d4e587c7af5.json b/db/db-sqlx-maria/target/sqlx/query-c461d8b1a2f096f198671b03044b04023db1b35d5910dee5141d8d4e587c7af5.json new file mode 100644 index 00000000..3ce256c1 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-c461d8b1a2f096f198671b03044b04023db1b35d5910dee5141d8d4e587c7af5.json @@ -0,0 +1,11 @@ +{ + "query": "DELETE FROM mcaptcha_config where captcha_key= (?)\n AND\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "b95e5a60a202cb646d5e76df8c7395e4bf881a6dd14e28e6f2e8b93e0536b331" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-c4cd25aed14d4c9cb82708e4f03766d3e1141fc20f5c96a1018800a3290296d6.json b/db/db-sqlx-maria/target/sqlx/query-c4cd25aed14d4c9cb82708e4f03766d3e1141fc20f5c96a1018800a3290296d6.json new file mode 100644 index 00000000..50b60154 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-c4cd25aed14d4c9cb82708e4f03766d3e1141fc20f5c96a1018800a3290296d6.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT time FROM mcaptcha_pow_solved_stats \n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?)) \n ORDER BY time DESC", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "time", + "type_info": { + "type": "Timestamp", + "flags": { + "bits": 1185 + }, + "char_set": 63, + "max_size": 19 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false + ] + }, + "hash": "d4b92e8099cd29cfdb99aadeeada739bb6858667fc65f528ec484e98a9da21bc" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-c591ad61297589795bc02d2a53ec999c405110412ab5e38a5c56fa436cff0380.json b/db/db-sqlx-maria/target/sqlx/query-c591ad61297589795bc02d2a53ec999c405110412ab5e38a5c56fa436cff0380.json new file mode 100644 index 00000000..d7f0b154 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-c591ad61297589795bc02d2a53ec999c405110412ab5e38a5c56fa436cff0380.json @@ -0,0 +1,52 @@ +{ + "query": "SELECT \n avg_traffic, \n peak_sustainable_traffic, \n broke_my_site_traffic \n FROM \n mcaptcha_sitekey_user_provided_avg_traffic \n WHERE \n config_id = (\n SELECT \n config_id \n FROM \n mcaptcha_config \n WHERE \n captcha_key = ? \n AND user_id = (\n SELECT \n id \n FROM \n mcaptcha_users \n WHERE \n NAME = ?\n )\n )\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "avg_traffic", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 1, + "name": "peak_sustainable_traffic", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 2, + "name": "broke_my_site_traffic", + "type_info": { + "type": "Long", + "flags": { + "bits": 0 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false, + true + ] + }, + "hash": "e91116ebce127833488130cf1060e0817e5677f39588632452b8d621688c405a" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-c5b964ca5335f4705faf40958937e1adda06e444a81631795045ca04e6a6cec2.json b/db/db-sqlx-maria/target/sqlx/query-c5b964ca5335f4705faf40958937e1adda06e444a81631795045ca04e6a6cec2.json new file mode 100644 index 00000000..439988df --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-c5b964ca5335f4705faf40958937e1adda06e444a81631795045ca04e6a6cec2.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_pow_confirmed_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "34b29417f9ff3f4d5987df0ce81023b1985eb84e560602b36182f55de6cd9d83" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-d1c7fa245d2c00624c8a7b89a53637b91073b4539ced05a9106a93019ec784e8.json b/db/db-sqlx-maria/target/sqlx/query-d1c7fa245d2c00624c8a7b89a53637b91073b4539ced05a9106a93019ec784e8.json new file mode 100644 index 00000000..a8b603e2 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-d1c7fa245d2c00624c8a7b89a53637b91073b4539ced05a9106a93019ec784e8.json @@ -0,0 +1,65 @@ +{ + "query": "SELECT `config_id`, `duration`, `name`, `captcha_key` from mcaptcha_config WHERE\n `captcha_key` = ? AND\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "config_id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 1, + "name": "duration", + "type_info": { + "type": "Long", + "flags": { + "bits": 1 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 2, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4097 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 3, + "name": "captcha_key", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "9c435148ed5655e79dd1e73e3566ce23b7c6d38edcedbb988c95813c5da893ed" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-d32fd2b7bf06d7ad6075dae7eb398f92584295f8b2ecb0f5b76012ab966f509d.json b/db/db-sqlx-maria/target/sqlx/query-d32fd2b7bf06d7ad6075dae7eb398f92584295f8b2ecb0f5b76012ab966f509d.json new file mode 100644 index 00000000..d7f0b154 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-d32fd2b7bf06d7ad6075dae7eb398f92584295f8b2ecb0f5b76012ab966f509d.json @@ -0,0 +1,52 @@ +{ + "query": "SELECT \n avg_traffic, \n peak_sustainable_traffic, \n broke_my_site_traffic \n FROM \n mcaptcha_sitekey_user_provided_avg_traffic \n WHERE \n config_id = (\n SELECT \n config_id \n FROM \n mcaptcha_config \n WHERE \n captcha_key = ? \n AND user_id = (\n SELECT \n id \n FROM \n mcaptcha_users \n WHERE \n NAME = ?\n )\n )\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "avg_traffic", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 1, + "name": "peak_sustainable_traffic", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 2, + "name": "broke_my_site_traffic", + "type_info": { + "type": "Long", + "flags": { + "bits": 0 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false, + true + ] + }, + "hash": "e91116ebce127833488130cf1060e0817e5677f39588632452b8d621688c405a" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-d360b3e9a2961af1c9e5d46204e6a891cb007544a9642c052abd402dac6cb8ec.json b/db/db-sqlx-maria/target/sqlx/query-d360b3e9a2961af1c9e5d46204e6a891cb007544a9642c052abd402dac6cb8ec.json new file mode 100644 index 00000000..3e57fe7a --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-d360b3e9a2961af1c9e5d46204e6a891cb007544a9642c052abd402dac6cb8ec.json @@ -0,0 +1,11 @@ +{ + "query": "-- mark a notification as read\nUPDATE mcaptcha_notifications\n SET read_notification = TRUE\nWHERE \n mcaptcha_notifications.id = ?\nAND\n mcaptcha_notifications.rx = (\n SELECT\n id\n FROM\n mcaptcha_users\n WHERE\n name = ?\n );\n", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "cf333541509213f11a9bf7119dcb3289bb77abf1482fc1d47e7f5bb27bdc8d97" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-db49c386d6c41527c8957407855f7c6343b0842519206f22776892f2bedfefe0.json b/db/db-sqlx-maria/target/sqlx/query-db49c386d6c41527c8957407855f7c6343b0842519206f22776892f2bedfefe0.json new file mode 100644 index 00000000..eab898cb --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-db49c386d6c41527c8957407855f7c6343b0842519206f22776892f2bedfefe0.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT time FROM mcaptcha_pow_fetched_stats\n WHERE \n config_id = (\n SELECT \n config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?))\n ORDER BY time DESC", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "time", + "type_info": { + "type": "Timestamp", + "flags": { + "bits": 1185 + }, + "char_set": 63, + "max_size": 19 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false + ] + }, + "hash": "daac5e937aeac2f106eb89154b431fa8bd1bd7baa95e51704fdcdf50bd970a1d" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-ed3940a731e26246c0673efb0b453be30736f16ea79cac6a4e6c6b7c9da6d29f.json b/db/db-sqlx-maria/target/sqlx/query-ed3940a731e26246c0673efb0b453be30736f16ea79cac6a4e6c6b7c9da6d29f.json new file mode 100644 index 00000000..71a1d0c0 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-ed3940a731e26246c0673efb0b453be30736f16ea79cac6a4e6c6b7c9da6d29f.json @@ -0,0 +1,11 @@ +{ + "query": "insert into mcaptcha_users \n (name , password, email, secret) values (?, ?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + }, + "hash": "8ec8bbde0c02a99f74d12e6778f123a973283e6d56b6861b30f559768617848a" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-ee4d7c4bf7fd15862d037901ccce90f23643cb44f7497d690604dd2a0991589f.json b/db/db-sqlx-maria/target/sqlx/query-ee4d7c4bf7fd15862d037901ccce90f23643cb44f7497d690604dd2a0991589f.json new file mode 100644 index 00000000..06ef859b --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-ee4d7c4bf7fd15862d037901ccce90f23643cb44f7497d690604dd2a0991589f.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_pow_solved_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "e2b0b85f2afac1cbca43ce684641bf75ef070e44ce3d00404fc6151d2f4d7bcf" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-ee6c36642dadc0f16accf3c811f2ff5a4104bda7f1cc572d94423abc03958b90.json b/db/db-sqlx-maria/target/sqlx/query-ee6c36642dadc0f16accf3c811f2ff5a4104bda7f1cc572d94423abc03958b90.json new file mode 100644 index 00000000..1591379a --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-ee6c36642dadc0f16accf3c811f2ff5a4104bda7f1cc572d94423abc03958b90.json @@ -0,0 +1,65 @@ +{ + "query": "SELECT captcha_key, name, config_id, duration FROM mcaptcha_config WHERE\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "captcha_key", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4101 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 1, + "name": "name", + "type_info": { + "type": "VarString", + "flags": { + "bits": 4097 + }, + "char_set": 224, + "max_size": 400 + } + }, + { + "ordinal": 2, + "name": "config_id", + "type_info": { + "type": "Long", + "flags": { + "bits": 515 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 3, + "name": "duration", + "type_info": { + "type": "Long", + "flags": { + "bits": 1 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "3812693a9ae4402d900bcbf680981e6194073bd1937af11a77daa3776fb4c873" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-f596ac4c528425d9d6f1817044e047c318a55f1fddfc8dd14030c0c52af50e42.json b/db/db-sqlx-maria/target/sqlx/query-f596ac4c528425d9d6f1817044e047c318a55f1fddfc8dd14030c0c52af50e42.json new file mode 100644 index 00000000..50b60154 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-f596ac4c528425d9d6f1817044e047c318a55f1fddfc8dd14030c0c52af50e42.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT time FROM mcaptcha_pow_solved_stats \n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?)) \n ORDER BY time DESC", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "time", + "type_info": { + "type": "Timestamp", + "flags": { + "bits": 1185 + }, + "char_set": 63, + "max_size": 19 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false + ] + }, + "hash": "d4b92e8099cd29cfdb99aadeeada739bb6858667fc65f528ec484e98a9da21bc" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-f5f676a244252a17d991edec26d0901b792c689f4140a3902a77f8ba651b39b9.json b/db/db-sqlx-maria/target/sqlx/query-f5f676a244252a17d991edec26d0901b792c689f4140a3902a77f8ba651b39b9.json new file mode 100644 index 00000000..c2701567 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-f5f676a244252a17d991edec26d0901b792c689f4140a3902a77f8ba651b39b9.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_users set name = ?\n WHERE name = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "676a9f1761c3b63cf16d7d4dd6261507cc7707feb32d458f4b946ed9caa53721" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-f7191dffbe0aefa3e2237f2f8422eee60f35ff66746b1506ca7bcaeeb48c9d1e.json b/db/db-sqlx-maria/target/sqlx/query-f7191dffbe0aefa3e2237f2f8422eee60f35ff66746b1506ca7bcaeeb48c9d1e.json new file mode 100644 index 00000000..7735b6d7 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-f7191dffbe0aefa3e2237f2f8422eee60f35ff66746b1506ca7bcaeeb48c9d1e.json @@ -0,0 +1,39 @@ +{ + "query": "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n ) ORDER BY difficulty_factor ASC;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "difficulty_factor", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + }, + { + "ordinal": 1, + "name": "visitor_threshold", + "type_info": { + "type": "Long", + "flags": { + "bits": 4097 + }, + "char_set": 63, + "max_size": 11 + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false + ] + }, + "hash": "6d43e6ceb54a0ff8a803bd96dd9134b15da01d48776ac0cf3d66a2997dadce5e" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-f7702b80d48eb02faf6746e20a7e47880a7bf97a9604bc2c484770403fb8b61b.json b/db/db-sqlx-maria/target/sqlx/query-f7702b80d48eb02faf6746e20a7e47880a7bf97a9604bc2c484770403fb8b61b.json new file mode 100644 index 00000000..3d445027 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-f7702b80d48eb02faf6746e20a7e47880a7bf97a9604bc2c484770403fb8b61b.json @@ -0,0 +1,26 @@ +{ + "query": "SELECT time FROM mcaptcha_pow_confirmed_stats \n WHERE \n config_id = (\n SELECT config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?))\n ORDER BY time DESC", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "time", + "type_info": { + "type": "Timestamp", + "flags": { + "bits": 1185 + }, + "char_set": 63, + "max_size": 19 + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false + ] + }, + "hash": "1367dceb151a766a901b5dd771d0b75d0bc61d2fef17a94a90c8ffa0065e2c44" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-f7d1eb93c369848694f9ef05e96bc72cd1f8a4533d62023db89f01ee7f5eded7.json b/db/db-sqlx-maria/target/sqlx/query-f7d1eb93c369848694f9ef05e96bc72cd1f8a4533d62023db89f01ee7f5eded7.json new file mode 100644 index 00000000..6eedeedb --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-f7d1eb93c369848694f9ef05e96bc72cd1f8a4533d62023db89f01ee7f5eded7.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_sitekey_user_provided_avg_traffic (\n config_id,\n avg_traffic,\n peak_sustainable_traffic,\n broke_my_site_traffic\n ) VALUES ( \n (SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n ), ?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 5 + }, + "nullable": [] + }, + "hash": "22e697114c3ed5b0156cdceab11a398f1ef3a804f482e1cd948bc615ef95fc92" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-f8c062c3ef71e34f8e26d90e73b7333c3c7b8c00bafe283c3804698a284e9983.json b/db/db-sqlx-maria/target/sqlx/query-f8c062c3ef71e34f8e26d90e73b7333c3c7b8c00bafe283c3804698a284e9983.json new file mode 100644 index 00000000..36531b00 --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-f8c062c3ef71e34f8e26d90e73b7333c3c7b8c00bafe283c3804698a284e9983.json @@ -0,0 +1,11 @@ +{ + "query": "UPDATE mcaptcha_config SET name = ?, duration = ?\n WHERE user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n AND captcha_key = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + }, + "hash": "3a8381eb0f0542a492d9dd51368e769e2b313e0576a1873e5c7630011e463daf" +} \ No newline at end of file diff --git a/db/db-sqlx-maria/target/sqlx/query-fe44a63a8130f8372c08afc94dbdbe10dbc002ad1b0c04039cb7d53c32c5d919.json b/db/db-sqlx-maria/target/sqlx/query-fe44a63a8130f8372c08afc94dbdbe10dbc002ad1b0c04039cb7d53c32c5d919.json new file mode 100644 index 00000000..7888d37f --- /dev/null +++ b/db/db-sqlx-maria/target/sqlx/query-fe44a63a8130f8372c08afc94dbdbe10dbc002ad1b0c04039cb7d53c32c5d919.json @@ -0,0 +1,11 @@ +{ + "query": "INSERT INTO mcaptcha_config\n (`captcha_key`, `user_id`, `duration`, `name`)\n VALUES (?, (SELECT ID FROM mcaptcha_users WHERE name = ?), ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + }, + "hash": "d05b84966f4e70c53789221f961bf3637f404f3ba45e880115e97ed1ba5a2809" +} \ No newline at end of file