Conversation
rahulgarg03
suggested changes
Mar 1, 2025
| @@ -0,0 +1,16 @@ | |||
| package controllers | |||
There was a problem hiding this comment.
have a look at folder structure it is neither layered nor modular
| ) | ||
|
|
||
| type User struct { | ||
| ID uint `gorm:"primarykey"` |
There was a problem hiding this comment.
Explore other alternatives of ID other than unit and check which is to use here
There was a problem hiding this comment.
Also what about created at deleted at check how gorm use them
Comment on lines
+24
to
+28
| Email string `json:"email" gorm:"unique; not null"` | ||
| FirstName string `json:"first_name"` | ||
| LastName string `json:"last_name"` | ||
| DateOfBirth time.Time `json:"date_of_birth"` | ||
| Gender Gender `json:"gender"` |
| if err != nil { | ||
| return err | ||
| } | ||
| return db.Migrator().CreateTable(&users.User{}) |
There was a problem hiding this comment.
is it the correct approach to use the same model. What if a new field add in the model in future?
Comment on lines
+30
to
+37
| DBHost: viper.GetString("DB_HOST"), | ||
| DBPort: viper.GetInt("DB_PORT"), | ||
| DBUser: viper.GetString("DB_USER"), | ||
| DBPassword: viper.GetString("DB_PASSWORD"), | ||
| DBName: viper.GetString("DB_NAME"), | ||
| DBSSLMode: viper.GetString("DB_SSL"), | ||
| ServerPort: viper.GetString("SERVER_PORT"), | ||
| } |
Comment on lines
+16
to
+23
| _, err := tx.Exec(` | ||
| ALTER TABLE users | ||
| DROP COLUMN gender, | ||
| DROP COLUMN marital_status; | ||
|
|
||
| ALTER TABLE users | ||
| ADD COLUMN gender gender, | ||
| ADD COLUMN marital_status marital_status; |
Owner
Author
There was a problem hiding this comment.
in db, type of gender and marital_status columns were saved as text, i wanted to make it enum.
rahulgarg03
reviewed
Mar 1, 2025
rahulgarg03
reviewed
Mar 1, 2025
| var AppConfig Config | ||
|
|
||
| func LoadConfig() { | ||
| viper.SetConfigFile(".env") |
rahulgarg03
suggested changes
Mar 1, 2025
|
|
||
| type OfficeDetail struct { | ||
| ID uint `gorm:"primarykey"` | ||
| UserID uint `json:"user_id" gorm:"not null;index"` |
There was a problem hiding this comment.
you are not making foreign key relationship
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.