Conversation
dentarg
commented
Jun 15, 2024
dentarg
commented
Jan 9, 2025
Comment on lines
+6
to
+9
| # https://github.com/Starkast/wikimum/issues/412 | ||
| # https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/connection_validator_rb.html | ||
| DB.extension(:connection_validator) | ||
| DB.pool.connection_validation_timeout = 60 * 5 |
Member
Author
There was a problem hiding this comment.
This can't make any sense when using SQLite? 🤔
Sequel's full_text_search supports PostgreSQL/MySQL/MSSQL but not SQLite, where it silently returned no results. Replace with a portable LIKE-based match that requires every term to appear in at least one searched column. Add an integration test covering title/content matches, case insensitivity, AND-of-terms behaviour, concealed-page exclusion, and the single-match redirect.
The endpoint shelled out to pg_dump, which doesn't apply to SQLite. Use SQLite's online backup API (SQLite3::Backup) to produce a consistent copy of the live database into a tempfile, then serve it as application/vnd.sqlite3. The integration test now compares the response body bytes against the UTF-8 bytes of the page title, since the response is a binary database file rather than a SQL dump.
The app now runs on SQLite only. Remove PostgreSQL-specific code, dependencies and tooling: - Drop pg and sequel_pg gems (and the corresponding vendor/cache). - Drop postgresql-client and libpq-dev from the Dockerfile. - Drop the postgres service from docker-compose; the app uses a bind-mounted ./storage directory for the SQLite file instead. - Remove the PGGSSENCMODE workaround in config/app.rb and the unused App.macos? helper. - Remove bin/cleanup_test_databases (no postgres test databases to clean up) and switch bin/download_database_backup to save .sqlite3. - Use a SQLite tempfile in test/test_database.rb instead of createdb.
The database URL is now built in code from two simpler env vars:
DATABASE_DIR (default "./storage")
DATABASE_NAME (default "wiki")
→ sqlite://${DATABASE_DIR}/${DATABASE_NAME}.db
On Fly the volume is mounted at /storage and DATABASE_DIR is set to
match. The test helper uses Dir.tmpdir as DATABASE_DIR and a random
DATABASE_NAME per process so tests go through the same code path as
production.
Replace bin/dev_db_bootstrap with a migrate step inside bin/dev. SQLite needs no createdb step, so a separate bootstrap script is overhead. bin/setup drops the corresponding step too — bin/dev now handles it on the next start.
Document DATABASE_DIR and DATABASE_NAME, drop the PostgreSQL setup instructions, and replace the Aiven preview-database notes with the Fly volume setup.
| backup_path = File.join(backup_tmpdir, rel_path) | ||
|
|
||
| send_file dump_path, type: "text/plain" | ||
| send_file backup_path, type: "application/vnd.sqlite3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PoC for #641