-
Notifications
You must be signed in to change notification settings - Fork 25
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
Refactor/aws integration #100
Merged
Merged
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3424d9f
feat:added upload middleware; added route to test file upload to s3;
Manjish 3ae61c8
feat: added cognito auth middleware
Manjish e4458d5
feat: added admin seed; changes in user model; added auto migration u…
Manjish c01e188
refactor:made auto-migrate optional
Manjish b07b345
feat:sending simple email using Amazon SES
Manjish 2de07ae
:wrench: chore: remove gcp and firebase related services
paudelgaurav 514d870
:sparkles: feat: added atlas as migation tool
paudelgaurav 02d6fd0
:wrench: chore: merge branch develop into refactor/enhancement-aws-in…
paudelgaurav b21b15e
:wrench: chore: update go version to 1.22 in workflow file
paudelgaurav 1d4db2c
:wrench: chore: running migration in github runner
paudelgaurav bfc8f90
:wrench: chore: downloading atlas in github runner
paudelgaurav da39f7b
:wrench: chore: remove env flag while applying migration
paudelgaurav c95f131
:wrench: chore: remove apply migration in runner
paudelgaurav aea044b
:wrench: chore: fix command to serve and check health
paudelgaurav ace0efd
:wrench: chore: fix command to migrate
paudelgaurav f6ec64e
:hammer: updated make file for migrating to previous version
Denes-cilwal a849067
:hammer: added port forward in env
Denes-cilwal 16da18e
Merge pull request #114 from wesionaryTEAM/refactor/enhancement-in-aw…
Denes-cilwal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package constants | ||
|
||
type UserRole string | ||
|
||
const ( | ||
RoleIsAdmin = "admin" | ||
RoleIsGeneralAdmin = "general" | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,40 @@ | ||
package models | ||
|
||
import ( | ||
"clean-architecture/domain/constants" | ||
"clean-architecture/pkg/types" | ||
"clean-architecture/pkg/utils" | ||
"database/sql" | ||
"time" | ||
|
||
"github.com/google/uuid" | ||
"gorm.io/gorm" | ||
) | ||
|
||
// User model | ||
type User struct { | ||
types.ModelBase | ||
Name string `json:"name" form:"name"` | ||
Email string `json:"email" form:"email"` | ||
Age int `json:"age" form:"age"` | ||
Birthday *time.Time `json:"time"` | ||
MemberNumber sql.NullString `json:"member_number"` | ||
ProfilePic utils.SignedURL `json:"profile_pic"` | ||
CreatedAt time.Time `json:"created_at" form:"created_at"` | ||
UpdatedAt time.Time `json:"updated_at" form:"updated_at"` | ||
gorm.Model | ||
UUID types.BinaryUUID `json:"uuid" gorm:"index;notnull"` | ||
CognitoUID *string `json:"-" gorm:"index;size:50"` | ||
FirstName string `json:"first_name" gorm:"size:255"` | ||
LastName string `json:"last_name" gorm:"size:255"` | ||
FirstNameJa string `json:"first_name_ja" gorm:"size:255"` | ||
LastNameJa string `json:"last_name_ja" gorm:"size:255"` | ||
Email string `json:"email" gorm:"notnull;index,unique;size:255"` | ||
Role constants.UserRole `json:"role" gorm:"size:25" copier:"-"` | ||
IsActive bool `json:"is_active" gorm:"default:false"` | ||
IsEmailVerified bool `json:"is_email_verified" gorm:"default:false"` | ||
IsAdmin bool `json:"-" gorm:"default:false"` | ||
ProfilePic utils.SignedURL `json:"profile_pic"` | ||
} | ||
|
||
// BeforeCreate run this before creating user | ||
func (t *User) BeforeCreate(_ *gorm.DB) error { | ||
id, err := uuid.NewRandom() | ||
t.ID = types.BinaryUUID(id) | ||
return err | ||
func (u *User) BeforeCreate(tx *gorm.DB) error { | ||
if u.UUID.String() == (types.BinaryUUID{}).String() { | ||
id, err := uuid.NewRandom() | ||
u.UUID = types.BinaryUUID(id) | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (*User) TableName() string { | ||
return "users" | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
@Manjish Let's remove this as auto migrate invocation and stick to writing migration for schema.
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.
will be fixed by #114