fix in mysql

This commit is contained in:
Mateusz Gruszczyński
2026-08-05 10:29:31 +02:00
parent a9911da9a3
commit 73286d921b
7 changed files with 27 additions and 7 deletions
Generated
+1 -1
View File
@@ -2581,7 +2581,7 @@ dependencies = [
[[package]]
name = "rustpad"
version = "0.2.38"
version = "0.2.39"
dependencies = [
"argon2",
"aws-config",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "rustpad"
version = "0.2.38"
version = "0.2.39"
edition = "2024"
rust-version = "1.94"
description = "Collaborative Markdown notepad built with Axum, WebSockets and SQLite, PostgreSQL and MySQL"
@@ -0,0 +1,8 @@
-- Existing MySQL databases may have inherited utf8mb3 from the database default.
-- Convert all persisted document text to utf8mb4 so emoji and other 4-byte
-- Unicode characters can be stored in both current documents and revisions.
ALTER TABLE pads CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE revisions CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE workspaces CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE notes CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE note_revisions CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
@@ -0,0 +1,2 @@
-- PostgreSQL text values are already stored as UTF-8.
SELECT 1;
@@ -0,0 +1,2 @@
-- SQLite TEXT values already support full Unicode.
SELECT 1;
+12 -4
View File
@@ -29,10 +29,18 @@ impl Database {
sqlx::any::install_default_drivers();
let kind = DatabaseKind::from_url(url)?;
debug!(?kind, max_connections, "initializing database pool");
let pool = AnyPoolOptions::new()
.max_connections(max_connections)
.connect(url)
.await?;
let mut options = AnyPoolOptions::new().max_connections(max_connections);
if kind == DatabaseKind::MySql {
options = options.after_connect(|connection, _metadata| {
Box::pin(async move {
sqlx::query("SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci")
.execute(connection)
.await?;
Ok(())
})
});
}
let pool = options.connect(url).await?;
if kind == DatabaseKind::Sqlite {
debug!("applying SQLite connection pragmas");
sqlx::query(queries::get(kind, queries::SQLITE_FOREIGN_KEYS_ON))
+1 -1
View File
@@ -3746,7 +3746,7 @@ dialog::backdrop {
.markdown-details>summary {
padding: .55em .8em;
color: var(--text);
font-weight: 650;
font-weight: 400;
cursor: pointer;
user-select: none;
}