From 4e2825ffe2ce6f7fd962130a9f5e24cab27e1572 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 17 Nov 2025 11:38:41 -0600 Subject: [PATCH] Ensure manticore tables and mysql client --- BUILD.md | 4 ++-- CloudronManifest.json | 4 ++-- Dockerfile | 2 +- manticore/block.sql | 24 ++++++++++++++++++++++++ manticore/doc.sql | 14 ++++++++++++++ run-affine.sh | 24 ++++++++++++++++++++++++ 6 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 manticore/block.sql create mode 100644 manticore/doc.sql diff --git a/BUILD.md b/BUILD.md index 8594d57..8771db4 100644 --- a/BUILD.md +++ b/BUILD.md @@ -13,14 +13,14 @@ cloudron build \ --set-build-service builder.docker.due.ren \ --build-service-token e3265de06b1d0e7bb38400539012a8433a74c2c96a17955e \ --set-repository andreasdueren/affine-cloudron \ - --tag 0.25.5-2 + --tag 0.25.5-3 ``` ## Deployment Steps 1. Remove any previous dev install of AFFiNE on the Cloudron (always reinstall from scratch). 2. Install the freshly built image: ```bash -cloudron install --location affine.due.ren --image andreasdueren/affine-cloudron:0.25.5-2 +cloudron install --location affine.due.ren --image andreasdueren/affine-cloudron:0.25.5-3 ``` 3. When prompted, confirm the app info and wait for Cloudron to report success (abort after ~30 seconds if installation stalls or errors to avoid hanging sessions). 4. Visit `https://affine.due.ren` (or the chosen location) and sign in using Cloudron SSO. diff --git a/CloudronManifest.json b/CloudronManifest.json index 883fe8b..4074001 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,9 +5,9 @@ "description": "Next-gen knowledge base that blends docs, whiteboards, and databases for self-hosted teams.", "website": "https://affine.pro", "contactEmail": "support@affine.pro", - "version": "0.25.5-2", + "version": "0.25.5-3", "upstreamVersion": "0.25.5", - "changelog": "Add copilot.env.example sample and env overrides", + "changelog": "Ensure Manticore tables exist and ship copilot env sample", "icon": "file://icon.png", "manifestVersion": 2, "minBoxVersion": "7.0.0", diff --git a/Dockerfile b/Dockerfile index f84fea2..0cd36a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ ENV APP_CODE_DIR=/app/code \ RUN mkdir -p "$APP_CODE_DIR" "$APP_DATA_DIR" "$APP_RUNTIME_DIR" "$APP_TMP_DIR" && \ apt-get update && \ - apt-get install -y --no-install-recommends jq python3 ca-certificates curl openssl libjemalloc2 postgresql-client && \ + apt-get install -y --no-install-recommends jq python3 ca-certificates curl openssl libjemalloc2 postgresql-client mysql-client && \ rm -rf /var/lib/apt/lists/* RUN curl -fsSL https://repo.manticoresearch.com/GPG-KEY-manticore > /tmp/manticore.key && \ diff --git a/manticore/block.sql b/manticore/block.sql new file mode 100644 index 0000000..b365e07 --- /dev/null +++ b/manticore/block.sql @@ -0,0 +1,24 @@ +CREATE TABLE IF NOT EXISTS block ( + workspace_id string attribute, + doc_id string attribute, + block_id string attribute, + content text, + flavour string attribute, + flavour_indexed string attribute indexed, + blob string attribute indexed, + ref_doc_id string attribute indexed, + ref string stored, + parent_flavour string attribute, + parent_flavour_indexed string attribute indexed, + parent_block_id string attribute, + parent_block_id_indexed string attribute indexed, + additional string stored, + markdown_preview string stored, + created_by_user_id string attribute, + updated_by_user_id string attribute, + created_at timestamp, + updated_at timestamp +) +morphology = 'jieba_chinese, lemmatize_en_all, lemmatize_de_all, lemmatize_ru_all, libstemmer_ar, libstemmer_ca, stem_cz, libstemmer_da, libstemmer_nl, libstemmer_fi, libstemmer_fr, libstemmer_el, libstemmer_hi, libstemmer_hu, libstemmer_id, libstemmer_ga, libstemmer_it, libstemmer_lt, libstemmer_ne, libstemmer_no, libstemmer_pt, libstemmer_ro, libstemmer_es, libstemmer_sv, libstemmer_ta, libstemmer_tr' +charset_table = 'non_cjk, cjk' +index_field_lengths = '1'; diff --git a/manticore/doc.sql b/manticore/doc.sql new file mode 100644 index 0000000..80da600 --- /dev/null +++ b/manticore/doc.sql @@ -0,0 +1,14 @@ +CREATE TABLE IF NOT EXISTS doc ( + workspace_id string attribute, + doc_id string attribute, + title text, + summary string stored, + journal string stored, + created_by_user_id string attribute, + updated_by_user_id string attribute, + created_at timestamp, + updated_at timestamp +) +morphology = 'jieba_chinese, lemmatize_en_all, lemmatize_de_all, lemmatize_ru_all, libstemmer_ar, libstemmer_ca, stem_cz, libstemmer_da, libstemmer_nl, libstemmer_fi, libstemmer_fr, libstemmer_el, libstemmer_hi, libstemmer_hu, libstemmer_id, libstemmer_ga, libstemmer_it, libstemmer_lt, libstemmer_ne, libstemmer_no, libstemmer_pt, libstemmer_ro, libstemmer_es, libstemmer_sv, libstemmer_ta, libstemmer_tr' +charset_table = 'non_cjk, cjk' +index_field_lengths = '1'; diff --git a/run-affine.sh b/run-affine.sh index ec26836..9180ace 100644 --- a/run-affine.sh +++ b/run-affine.sh @@ -140,6 +140,29 @@ PY fi } +seed_manticore_tables() { + local sql_dir="$APP_DIR/manticore" + if [ ! -d "$sql_dir" ]; then + return + fi + if ! command -v mysql >/dev/null 2>&1; then + log "mysql client not found; cannot seed Manticore tables" + return + fi + local mysql_cmd=(mysql -h 127.0.0.1 -P 9306) + for table in doc block; do + local sql_file="$sql_dir/${table}.sql" + if [ ! -f "$sql_file" ]; then + continue + fi + if "${mysql_cmd[@]}" < "$sql_file" >/dev/null 2>&1; then + log "Ensured Manticore table ${table}" + else + log "WARNING: Failed to apply ${sql_file} to Manticore" + fi + done +} + patch_upload_limits() { local target="$APP_DIR/dist/main.js" if [ ! -f "$target" ]; then @@ -270,6 +293,7 @@ NODE log "Running AFFiNE pre-deployment migrations" ensure_runtime_envs wait_for_indexer +seed_manticore_tables node ./scripts/self-host-predeploy.js patch_upload_limits grant_team_plan_features