TP-55555 | Release handler

This commit is contained in:
Lokesh Dugar
2024-07-27 17:02:42 +05:30
parent a580510742
commit d95a639e93
4 changed files with 21 additions and 16 deletions

View File

@@ -9,3 +9,8 @@ func InitProjectRepository(dbClient *gorm.DB) *gorm.DB {
dbClient.AutoMigrate(&db.Project{})
return dbClient
}
func InitReleaseRepository(dbClient *gorm.DB) *gorm.DB {
dbClient.AutoMigrate(&db.Release{})
return dbClient
}

View File

@@ -28,6 +28,7 @@ type Handler struct {
type Repositories struct {
ProjectRepository *gorm.DB
ReleaseRepository *gorm.DB
}
func InitDependencies() *Dependencies {
@@ -53,6 +54,7 @@ func initServices() *Service {
func initRepositories(dbClient *gorm.DB) *Repositories {
return &Repositories{
ProjectRepository: database.InitProjectRepository(dbClient),
ReleaseRepository: database.InitReleaseRepository(dbClient),
}
}

View File

@@ -1,16 +0,0 @@
package db
import (
"github.com/google/uuid"
"gorm.io/gorm"
)
type Release struct {
gorm.Model
ReleaseId uuid.UUID `gorm:"primaryKey"`
ProjectReferenceId string
ReleaseVersion string `gorm:"unique"`
SourceMapUrl string // TODO: Check id required
ProjectID string
Project Project `gorm:"foreignKey:ProjectID"`
}

14
models/db/release.go Normal file
View File

@@ -0,0 +1,14 @@
package db
import (
"github.com/google/uuid"
"gorm.io/gorm"
)
type Release struct {
gorm.Model
ReleaseId uuid.UUID `gorm:"primaryKey"`
ReleaseVersion string `gorm:"unique"`
ProjectReferenceId string
Project Project `gorm:"foreignKey:ProjectReferenceId;references:ProjectReferenceId;"`
}