Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
perf(DATABASE): Drop Table files
Browse files Browse the repository at this point in the history
Since we store the torrent structure in the column of table `torrents`,
There is no need to have another table to store the file list of torrent.

Signed-off-by: Rhilip <rhilipruan@gmail.com>
  • Loading branch information
Rhilip committed Jun 7, 2019
1 parent 096333b commit c3e329d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
5 changes: 1 addition & 4 deletions apps/models/form/TorrentUploadForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function isValidTorrent()
}
if (!count($ffa)) throw new ParseErrorException('std_filename_errors');
$ffe = implode("/", $ffa);
$this->torrent_list[] = ['filename' => $ffe, 'size' => $ll, 'torrent_id' => &$this->id];
$this->torrent_list[] = ['filename' => $ffe, 'size' => $ll];
}
$this->torrent_type = 'multi';
}
Expand Down Expand Up @@ -187,9 +187,6 @@ public function flush()
])->execute();
$this->id = app()->pdo->getLastInsertId();

// Insert files table
app()->pdo->batchInsert('files', $this->torrent_list)->execute();

$this->setBuff();

// Save this torrent
Expand Down
30 changes: 1 addition & 29 deletions migration/ridpt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jun 07, 2019 at 12:27 AM
-- Generation Time: Jun 07, 2019 at 08:00 AM
-- Server version: 8.0.16
-- PHP Version: 7.3.6

Expand Down Expand Up @@ -183,28 +183,6 @@ CREATE TABLE IF NOT EXISTS `cheaters` (

-- --------------------------------------------------------

--
-- Table structure for table `files`
--

DROP TABLE IF EXISTS `files`;
CREATE TABLE IF NOT EXISTS `files` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`torrent_id` int(10) UNSIGNED NOT NULL,
`filename` varchar(255) NOT NULL DEFAULT '',
`size` bigint(20) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `torrent_id` (`torrent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- RELATIONSHIPS FOR TABLE `files`:
-- `torrent_id`
-- `torrents` -> `id`
--

-- --------------------------------------------------------

--
-- Table structure for table `invite`
--
Expand Down Expand Up @@ -788,12 +766,6 @@ ALTER TABLE `bookmarks`
ADD CONSTRAINT `FK_bookmarks_torrents_id` FOREIGN KEY (`tid`) REFERENCES `torrents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `FK_bookmarks_users_id` FOREIGN KEY (`uid`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `files`
--
ALTER TABLE `files`
ADD CONSTRAINT `FK_files_torrents_id` FOREIGN KEY (`torrent_id`) REFERENCES `torrents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `invite`
--
Expand Down

0 comments on commit c3e329d

Please sign in to comment.