Skip to content

Conversation

@josecelano
Copy link
Member

The table torrust_torrents has 8 secondary tables that reference it with a foreign key:

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.

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 josecelano requested review from da2ce7 and mario-nt March 8, 2024 15:14
@josecelano josecelano self-assigned this Mar 8, 2024
@josecelano josecelano added the Bug Incorrect Behavior label Mar 8, 2024
@josecelano josecelano added this to the v3.0.0 milestone Mar 8, 2024
@josecelano
Copy link
Member Author

ACK 094ab8a

Copy link
Contributor

@mario-nt mario-nt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Incorrect Behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DB Migration 20240305120015_torrust_add_independent_root_hash_field.sql truncates data for torrent secondary tables

2 participants