-
Notifications
You must be signed in to change notification settings - Fork 4
employee-dev-13-BE-add-ticket-table-back #208
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?
Conversation
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.
Summary of Changes
Hello @yennanliu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request re-introduces and sets up the backend components for a ticketing system. It includes the necessary database table creation logic, updates the JPA entity and DTO for tickets with timestamp fields and appropriate column types, refactors the ticket update service method for correctness, adjusts database configuration for MySQL 8 and enhanced logging, and provides initial sample data and basic repository tests.
Highlights
- Database Initialization: Introduced a
DatabaseConfig
class that uses aCommandLineRunner
to ensure thetickets
table is created on application startup if it doesn't already exist, including defining its schema with appropriate columns and indexes. - Ticket Entity & DTO: Updated the
Ticket
entity to useLONGTEXT
for the description column definition and addedcreatedAt
andupdatedAt
fields with@CreationTimestamp
and@UpdateTimestamp
annotations for automatic timestamp management. TheTicketDto
was also updated to include these timestamp fields. - Improved Update Logic: Refactored the
updateTicket
method inTicketService
to correctly fetch the existing ticket by ID and update its fields, rather than deleting and re-saving, which preserves the original creation timestamp and entity identity. - Database Configuration: Updated
application.properties
to use theMySQL8Dialect
, enabledshow-sql
andformat_sql
for better debugging, and added trace logging for SQL parameter binding. - Sample Data: Added a
data.sql
file to initialize sample ticket statuses, tags (usingINSERT IGNORE
intooption_schema
), and sample tickets (usingINSERT IGNORE
intotickets
) on application startup. - Basic JPA Test: Added a
DatabaseConfigTest
using@DataJpaTest
to verify that theTicket
entity can be persisted and retrieved via theTicketRepository
, implicitly testing the table structure and repository setup.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request re-introduces the tickets
table and associated functionality. Key changes include adding a CommandLineRunner
for initial table creation (though alternative schema management tools are generally preferred), updating the Ticket
entity with timestamp fields and LONGTEXT
for description, adding these fields to the TicketDto
, improving the updateTicket
service method to correctly update the existing entity, configuring Hibernate for MySQL 8 and enabling SQL logging, adding sample data initialization scripts, and including a @DataJpaTest
to verify the persistence layer.
"user_id INT," + | ||
"assigned_to INT," + |
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.
String createTicketsTable = "CREATE TABLE IF NOT EXISTS tickets (" + | ||
"id INT AUTO_INCREMENT PRIMARY KEY," + | ||
"subject VARCHAR(255) NOT NULL," + | ||
"description LONGTEXT," + | ||
"user_id INT," + | ||
"assigned_to INT," + | ||
"status VARCHAR(50) DEFAULT 'PENDING'," + | ||
"tag VARCHAR(100)," + | ||
"created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP," + | ||
"updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + | ||
"INDEX idx_user_id (user_id)," + | ||
"INDEX idx_assigned_to (assigned_to)," + | ||
"INDEX idx_status (status)," + | ||
"INDEX idx_created_at (created_at)" + | ||
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"; |
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.
Using a CommandLineRunner
with raw SQL for database schema management can be less maintainable than using dedicated tools like Flyway or Liquibase, or relying solely on Hibernate's ddl-auto
feature combined with entity definitions. While CREATE TABLE IF NOT EXISTS
makes it idempotent, managing schema changes over time (e.g., adding columns, altering types) becomes more complex with this approach compared to migration scripts.
* Fixed to work with both MySQL 5 and MySQL 8 for auto table creation. | ||
*/ |
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.
No description provided.