Add primary keys to multiple tables

I missed these keys when creating the initial schema, and it's a useful practice.
This commit is contained in:
Mike Colagrosso 2024-05-01 00:41:22 -06:00 committed by Alex Cabal
parent 032032b920
commit 79daa82bf4
5 changed files with 10 additions and 0 deletions

View file

@ -1,9 +1,11 @@
CREATE TABLE `Collections` ( CREATE TABLE `Collections` (
`CollectionId` int(10) unsigned NOT NULL AUTO_INCREMENT,
`EbookId` int(10) unsigned NOT NULL, `EbookId` int(10) unsigned NOT NULL,
`Name` varchar(255) NOT NULL, `Name` varchar(255) NOT NULL,
`UrlName` varchar(255) NOT NULL, `UrlName` varchar(255) NOT NULL,
`SequenceNumber` int(10) unsigned NULL, `SequenceNumber` int(10) unsigned NULL,
`Type` varchar(255) NULL, `Type` varchar(255) NULL,
PRIMARY KEY (`CollectionId`),
KEY `index1` (`EbookId`), KEY `index1` (`EbookId`),
KEY `index2` (`UrlName`) KEY `index2` (`UrlName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View file

@ -1,4 +1,5 @@
CREATE TABLE `Contributors` ( CREATE TABLE `Contributors` (
`ContributorId` int(10) unsigned NOT NULL AUTO_INCREMENT,
`EbookId` int(10) unsigned NOT NULL, `EbookId` int(10) unsigned NOT NULL,
`Name` varchar(255) NOT NULL, `Name` varchar(255) NOT NULL,
`UrlName` varchar(255) NOT NULL, `UrlName` varchar(255) NOT NULL,
@ -8,6 +9,7 @@ CREATE TABLE `Contributors` (
`FullName` varchar(255) NULL, `FullName` varchar(255) NULL,
`NacoafUrl` varchar(255) NULL, `NacoafUrl` varchar(255) NULL,
`SortOrder` tinyint(3) unsigned NOT NULL, `SortOrder` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`ContributorId`),
KEY `index1` (`EbookId`), KEY `index1` (`EbookId`),
KEY `index2` (`UrlName`) KEY `index2` (`UrlName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View file

@ -1,6 +1,8 @@
CREATE TABLE `EbookSources` ( CREATE TABLE `EbookSources` (
`EbookSourceId` int(10) unsigned NOT NULL AUTO_INCREMENT,
`EbookId` int(10) unsigned NOT NULL, `EbookId` int(10) unsigned NOT NULL,
`Type` enum('project_gutenberg', 'project_gutenberg_australia', 'project_gutenberg_canada', 'internet_archive', 'hathi_trust', 'wikisource', 'google_books', 'faded_page', 'other') DEFAULT 'other', `Type` enum('project_gutenberg', 'project_gutenberg_australia', 'project_gutenberg_canada', 'internet_archive', 'hathi_trust', 'wikisource', 'google_books', 'faded_page', 'other') DEFAULT 'other',
`Url` varchar(255) NOT NULL, `Url` varchar(255) NOT NULL,
PRIMARY KEY (`EbookSourceId`),
KEY `index1` (`EbookId`) KEY `index1` (`EbookId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View file

@ -1,7 +1,9 @@
CREATE TABLE `GitCommits` ( CREATE TABLE `GitCommits` (
`GitCommitId` int(10) unsigned NOT NULL AUTO_INCREMENT,
`EbookId` int(10) unsigned NOT NULL, `EbookId` int(10) unsigned NOT NULL,
`Created` datetime NOT NULL, `Created` datetime NOT NULL,
`Message` text NOT NULL, `Message` text NOT NULL,
`Hash` char(40) NOT NULL, `Hash` char(40) NOT NULL,
PRIMARY KEY (`GitCommitId`),
KEY `index1` (`EbookId`) KEY `index1` (`EbookId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View file

@ -1,5 +1,7 @@
CREATE TABLE `TocEntries` ( CREATE TABLE `TocEntries` (
`TocEntryId` int(10) unsigned NOT NULL AUTO_INCREMENT,
`EbookId` int(10) unsigned NOT NULL, `EbookId` int(10) unsigned NOT NULL,
`TocEntry` text NOT NULL, `TocEntry` text NOT NULL,
PRIMARY KEY (`TocEntryId`),
KEY `index1` (`EbookId`) KEY `index1` (`EbookId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;