Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DB migration for SQLite. Backup secondary tables to avoid losing data #527

Commits on Mar 8, 2024

  1. fix: [torrust#526] DB migration for SQLite. Backup secondary tables

    The table `torrust_torrents` has 8 secondary tables that reference it
    with a foreign key:
    
    ```sql
    FOREIGN KEY("torrent_id") REFERENCES "torrust_torrents"("torrent_id") ON DELETE CASCADE,
    ```
    
    The migration fixed in this commit creates a new table in order to alter
    it and drops the old one. However, when you drop the old table, SQLite
    uses an implicit DELETE query for the `torrust_torrents` table which
    triggers a DELETE ON CASCADE, deleting all the related records in
    secondary tables.
    
    The secondary tables are:
    
    - torrust_torrent_files
    - torrust_torrent_announce_urls
    - torrust_torrent_info
    - torrust_torrent_tracker_stats
    - torrust_torrent_tag_links
    - torrust_torrent_info_hashes
    - torrust_torrent_http_seeds
    - torrust_torrent_nodes
    
    These tables store the torrent file fiel together with the master
    `torrust_torrents`.
    josecelano committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    bd935b3 View commit details
    Browse the repository at this point in the history
  2. fix: linter errors

    josecelano committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    094ab8a View commit details
    Browse the repository at this point in the history