Skip to content

Commit

Permalink
Merge pull request #382 from Kotik112/change-validation-code-type
Browse files Browse the repository at this point in the history
[FR-206] Change validation code from Integer to String
  • Loading branch information
BerglundDaniel authored Dec 12, 2023
2 parents cfdd434 + fe92576 commit a8a0116
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/src/migrations/0025_initial_gift_card.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
CREATE TABLE IF NOT EXISTS `webshop_gift_card`(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`amount` decimal(15,2) NOT NULL,
`validation_code` int(10) unsigned NOT NULL,
`validation_code` VARCHAR(16) unique COLLATE utf8mb4_0900_ai_ci NOT NULL,
`email` varchar(255) COLLATE utf8mb4_0900_ai_ci NOT NULL,
`status` enum('pending','activated','expired') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
Expand Down
5 changes: 2 additions & 3 deletions api/src/shop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,11 @@ class GiftCard(Base):
Attributes:
id (int): Unique identifier for gift card.
amount (float): the monetary value associated with the gift card.
validation_code (int): The unique code used to validate the gift card
validation_code (str): The unique hex code used to validate the gift card. Length is 16 characters.
email (str): The email address associated with the gift card. Used to send the validation code to the client.
status (enum): The status of the gift card (PENDING, ACTIVATED, EXPIRED)
created_at (datetime): the timestamp when the card was created.
"""

__tablename__ = "webshop_gift_card"

PENDING = "pending"
Expand All @@ -194,7 +193,7 @@ class GiftCard(Base):

id = Column(Integer, primary_key=True, nullable=False, autoincrement=True)
amount = Column(Numeric(precision="15,2"), nullable=False)
validation_code = Column(Integer, nullable=False)
validation_code = Column(String(16), unique=True, nullable=False)
email = Column(String(255), unique=True, nullable=False)
status = Column(Enum(PENDING, ACTIVATED, EXPIRED), nullable=False, default=PENDING)
created_at = Column(DateTime, server_default=func.now())
Expand Down

0 comments on commit a8a0116

Please sign in to comment.