feat: Rust 2024 kernel (serenity 0.12.5+poise 0.7, sqlx 0.9, tokio 1.53) - OTHER + roles without emojis, verify auto on boot, i18n EN, welcome 40, tickets, voice temp, fmt/clippy 0, userbot inspect

This commit is contained in:
loki5512344 2026-09-09 14:15:30 +02:00
parent c3b0c2f976
commit a2b2c41654
Signed by: boba
GPG key ID: 253067914055423B
124 changed files with 1596 additions and 2896 deletions

49
src/db/migration.rs Normal file
View file

@ -0,0 +1,49 @@
use sqlx::SqlitePool;
use tracing::info;
pub async fn run(pool: &SqlitePool) -> anyhow::Result<()> {
sqlx::query(
"CREATE TABLE IF NOT EXISTS _migrations (
version INTEGER PRIMARY KEY,
name TEXT NOT NULL,
applied_at TEXT NOT NULL DEFAULT (datetime('now'))
)",
)
.execute(pool)
.await?;
let migrations = [("V1__initial", V1_INITIAL)];
for (name, sql) in migrations {
let exists: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM _migrations WHERE name = ?")
.bind(name)
.fetch_one(pool)
.await?;
if exists == 0 {
let mut tx = pool.begin().await?;
for stmt in sql.split(';').map(str::trim).filter(|s| !s.is_empty()) {
sqlx::query(stmt).execute(&mut *tx).await?;
}
sqlx::query("INSERT INTO _migrations(name) VALUES(?)")
.bind(name)
.execute(&mut *tx)
.await?;
tx.commit().await?;
info!(migration = name, "applied");
}
}
Ok(())
}
const V1_INITIAL: &str = "
CREATE TABLE IF NOT EXISTS guild_config (
guild_id TEXT PRIMARY KEY,
prefix TEXT NOT NULL DEFAULT '!',
lang TEXT NOT NULL DEFAULT 'ru'
);
CREATE TABLE IF NOT EXISTS user_stats (
user_id TEXT PRIMARY KEY,
xp INTEGER NOT NULL DEFAULT 0,
level INTEGER NOT NULL DEFAULT 0,
message_count INTEGER NOT NULL DEFAULT 0
);
";