Draft
Conversation
Add CHECK constraint to ensure the `completed` column in the `torrents` table is always >= 1, preventing invalid zero values. This change reflects the semantic meaning that a torrent entry should only exist once it has been completed at least once. Changes: - Add migration scripts for both SQLite and MySQL to: - Delete any existing rows with completed = 0 - Add CHECK constraint (completed >= 1) - Change default value from 0 to 1 - Update hardcoded table creation SQL in database drivers to include the new constraint and default value - Document the new constraint in migrations README with complete table schema reference for all 4 tracker tables - Update module documentation to clarify permanent keys support The migration handles SQLite's limitation by recreating the table, while MySQL can add the constraint directly (requires MySQL 8.0.16+).
Migrate the `whitelist` table to `whitelist_v1` with optimized storage and indexing. This change removes the unnecessary auto-increment `id` column and uses `info_hash` directly as the PRIMARY KEY, improving both storage efficiency and query performance. Database-specific optimizations: - **SQLite**: Use `WITHOUT ROWID` optimization since info_hash is already a suitable primary key (40-char hex string). This eliminates the hidden rowid column and reduces storage overhead. - **MySQL**: Store info_hash as `BINARY(20)` instead of `VARCHAR(40)`, reducing storage from 40 bytes to 20 bytes per entry and improving index performance. Changes: - Add migration scripts for both SQLite and MySQL to: - Create new `whitelist_v1` table with optimized schema - Migrate existing data (converting hex to binary for MySQL) - Drop old `whitelist` table - Update hardcoded table creation SQL in database drivers to match new schema - Update all whitelist queries to use `whitelist_v1` table name - Update MySQL driver to use binary storage with `UNHEX()`/bytes() for info_hash operations - Document the new schema in migrations README with storage format details for both databases The migration preserves all existing whitelist data while improving storage efficiency and query performance for whitelist lookups.
Rename the `torrents` table to `completed_v1` with improved storage efficiency and semantic clarity. This change removes the unnecessary auto-increment `id` column, uses `info_hash` directly as the PRIMARY KEY, and renames the `completed` column to `count` for better clarity. Database-specific optimizations: - **SQLite**: Use `WITHOUT ROWID` optimization since info_hash is already a suitable primary key (40-char hex string). This eliminates the hidden rowid column and reduces storage overhead. - **MySQL**: Store info_hash as `BINARY(20)` instead of `VARCHAR(40)`, reducing storage from 40 bytes to 20 bytes per entry and improving index performance. Changes: - Add migration scripts for both SQLite and MySQL to: - Create new `completed_v1` table with optimized schema - Migrate existing data (converting hex to binary for MySQL) - Drop old `torrents` table - Update hardcoded table creation SQL in database drivers to match new schema - Update all torrent download queries to use `completed_v1` table name and `count` column name - Update MySQL driver to use binary storage with `UNHEX()`/bytes() for info_hash operations - Document the new schema in migrations README with storage format details for both databases The migration preserves all existing torrent download data while improving storage efficiency and query performance. The new table name `completed_v1` better reflects its purpose of tracking download completion counts.
7 tasks
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.
@josecelano a simple demo of what a basic update of the sql tables would look like
I can confirm that the torrents table only includes torrents that have at least one download.