diff --git a/Cargo.lock b/Cargo.lock index 9ba8f60..ea1665c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2581,7 +2581,7 @@ dependencies = [ [[package]] name = "rustpad" -version = "0.2.38" +version = "0.2.39" dependencies = [ "argon2", "aws-config", diff --git a/Cargo.toml b/Cargo.toml index 14a127b..53f89a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/migrations/mysql/0030_document_utf8mb4.sql b/migrations/mysql/0030_document_utf8mb4.sql new file mode 100644 index 0000000..7608cdc --- /dev/null +++ b/migrations/mysql/0030_document_utf8mb4.sql @@ -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; diff --git a/migrations/postgres/0030_document_utf8mb4.sql b/migrations/postgres/0030_document_utf8mb4.sql new file mode 100644 index 0000000..8555157 --- /dev/null +++ b/migrations/postgres/0030_document_utf8mb4.sql @@ -0,0 +1,2 @@ +-- PostgreSQL text values are already stored as UTF-8. +SELECT 1; diff --git a/migrations/sqlite/0030_document_utf8mb4.sql b/migrations/sqlite/0030_document_utf8mb4.sql new file mode 100644 index 0000000..6407c77 --- /dev/null +++ b/migrations/sqlite/0030_document_utf8mb4.sql @@ -0,0 +1,2 @@ +-- SQLite TEXT values already support full Unicode. +SELECT 1; diff --git a/src/database.rs b/src/database.rs index eb2f663..e165bf5 100644 --- a/src/database.rs +++ b/src/database.rs @@ -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)) diff --git a/static/css/styles.css b/static/css/styles.css index e823d68..155f0f3 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -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; }