Repository navigation
Feat/63 sql build tables #70
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
base: main
Are you sure you want to change the base?
Changes from all commits
7e2b0be
e8309e1
475761a
922d888
2ab129f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| -- defaults to innoDB in case future changes to mySQL | ||
| CREATE TABLE IF NOT EXISTS `User` ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. table name will need to be "Account" due to reserved key words |
||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `username` VARCHAR(255), | ||
| `passwordHash` VARCHAR(255), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the size needed for this depends on our algorithm, I haven't been able to find an exact number. All of this to say it may have to change someday |
||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `PermissionType` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `name` VARCHAR(255), | ||
| PRIMARY KEY (`id`), | ||
| UNIQUE KEY `UK_PermissionType_name` (`name`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `Permission` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `permissionTypeId` INT, | ||
| PRIMARY KEY (`id`), | ||
| KEY `IDX_Permission_permissionTypeId` (`permissionTypeId`), | ||
| CONSTRAINT `FK_Permission_permissionType` | ||
| FOREIGN KEY (`permissionTypeId`) REFERENCES `PermissionType` (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `UserPermission` ( | ||
| `userId` INT NOT NULL, | ||
| `permissionId` INT NOT NULL, | ||
| PRIMARY KEY (`userId`, `permissionId`), | ||
| KEY `IDX_UserPermission_permissionId` (`permissionId`), | ||
| CONSTRAINT `FK_UserPermission_user` | ||
| FOREIGN KEY (`userId`) REFERENCES `User` (`id`), | ||
| CONSTRAINT `FK_UserPermission_permission` | ||
| FOREIGN KEY (`permissionId`) REFERENCES `Permission` (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `Tag` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `label` VARCHAR(255), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't allow tags this long. How about 100 char? |
||
| PRIMARY KEY (`id`), | ||
| UNIQUE KEY `UK_Tag_label` (`label`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `Sticker` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `name` VARCHAR(255), | ||
| `length` DOUBLE NOT NULL, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The m,n in the ERD is important because it specifies the exact size of double we expect and creates a max and min cap on value. I set the range for this field at 5 total digits with up to 2 points precision, which gives a range of -999.99 to 999.99 |
||
| `width` DOUBLE NOT NULL, | ||
| `desc` VARCHAR(255), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest increasing this to 500char |
||
| `svgPath` VARCHAR(255), | ||
| `active` TINYINT(1) NOT NULL, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `StickerSheets` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `filePath` VARCHAR(255), | ||
| `stickerIdsJSON` LONGTEXT, | ||
| `stickerIds` LONGTEXT, | ||
|
Comment on lines
+57
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only the JSON field needs to exist, the other is for java only and holds the deserialized json transformed into a map |
||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `PlacedOrder` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `customerId` INT, | ||
| `placementTimestamp` TIMESTAMP(6), | ||
| `status` VARCHAR(255), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe mysql supports enums. If it doesn't, this can still be shrunk to like 50char or less |
||
| `addressJSON` LONGTEXT, | ||
| `note` VARCHAR(255), | ||
| `address` LONGTEXT, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment above about JSON fields |
||
| PRIMARY KEY (`id`), | ||
| KEY `IDX_PlacedOrder_customerId` (`customerId`), | ||
| CONSTRAINT `FK_PlacedOrder_customer` | ||
| FOREIGN KEY (`customerId`) REFERENCES `User` (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `OrderItems` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `orderId` INT, | ||
| `sheetId` INT, | ||
| `quantity` INT NOT NULL, | ||
| PRIMARY KEY (`id`), | ||
| KEY `IDX_OrderItems_orderId` (`orderId`), | ||
| KEY `IDX_OrderItems_sheetId` (`sheetId`), | ||
| CONSTRAINT `FK_OrderItems_order` | ||
| FOREIGN KEY (`orderId`) REFERENCES `PlacedOrder` (`id`), | ||
| CONSTRAINT `FK_OrderItems_sheet` | ||
| FOREIGN KEY (`sheetId`) REFERENCES `StickerSheets` (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `OrderItemsStatus` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `orderItemsId` INT, | ||
| `complete` TINYINT(1) NOT NULL, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe you can set a default value of false |
||
| PRIMARY KEY (`id`), | ||
| UNIQUE KEY `UK_OrderItemsStatus_orderItemsId` (`orderItemsId`), | ||
| CONSTRAINT `FK_OrderItemsStatus_orderItem` | ||
| FOREIGN KEY (`orderItemsId`) REFERENCES `OrderItems` (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `OrderUpdates` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `orderId` INT, | ||
| `timestamp` TIMESTAMP(6), | ||
| `orderType` VARCHAR(255), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above about enums |
||
| PRIMARY KEY (`id`), | ||
| KEY `IDX_OrderUpdates_orderId` (`orderId`), | ||
| CONSTRAINT `FK_OrderUpdates_order` | ||
| FOREIGN KEY (`orderId`) REFERENCES `PlacedOrder` (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `Collection` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `name` VARCHAR(255), | ||
| PRIMARY KEY (`id`), | ||
| UNIQUE KEY `UK_Collection_name` (`name`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `CollectionItems` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `stickerId` INT, | ||
| `collectionId` INT, | ||
| PRIMARY KEY (`id`), | ||
| KEY `IDX_CollectionItems_stickerId` (`stickerId`), | ||
| KEY `IDX_CollectionItems_collectionId` (`collectionId`), | ||
| CONSTRAINT `FK_CollectionItems_sticker` | ||
| FOREIGN KEY (`stickerId`) REFERENCES `Sticker` (`id`), | ||
| CONSTRAINT `FK_CollectionItems_collection` | ||
| FOREIGN KEY (`collectionId`) REFERENCES `Collection` (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `TagItems` ( | ||
| `id` INT NOT NULL AUTO_INCREMENT, | ||
| `tagId` INT, | ||
| `stickerId` INT, | ||
| PRIMARY KEY (`id`), | ||
| KEY `IDX_TagItems_tagId` (`tagId`), | ||
| KEY `IDX_TagItems_stickerId` (`stickerId`), | ||
| CONSTRAINT `TAG_ID_FK` | ||
| FOREIGN KEY (`tagId`) REFERENCES `Tag` (`id`), | ||
| CONSTRAINT `STICKER_ID_FK` | ||
| FOREIGN KEY (`stickerId`) REFERENCES `Sticker` (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing StagingItems table