Skip to content
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

[FR-206] Change validation code from Integer to String #382

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) COLLATE utf8mb4_0900_ai_ci NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the validation_code missing a UNIQUE constraint?

`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
Loading