feat: add uuid for medias
This commit is contained in:
@@ -68,6 +68,7 @@ CREATE INDEX idx_user_balance_histories_tenant_id ON user_balance_histories (ten
|
||||
CREATE TABLE
|
||||
medias (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
uuid uuid NOT NULL,
|
||||
tenant_id INT8 NOT NULL,
|
||||
title VARCHAR(198) NOT NULL,
|
||||
description VARCHAR(198) NOT NULL,
|
||||
|
||||
@@ -8,11 +8,13 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Medias struct {
|
||||
ID int64 `sql:"primary_key" json:"id"`
|
||||
UUID uuid.UUID `json:"uuid"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
|
||||
@@ -18,6 +18,7 @@ type mediasTable struct {
|
||||
|
||||
// Columns
|
||||
ID postgres.ColumnInteger
|
||||
UUID postgres.ColumnString
|
||||
TenantID postgres.ColumnInteger
|
||||
Title postgres.ColumnString
|
||||
Description postgres.ColumnString
|
||||
@@ -67,6 +68,7 @@ func newMediasTable(schemaName, tableName, alias string) *MediasTable {
|
||||
func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
|
||||
var (
|
||||
IDColumn = postgres.IntegerColumn("id")
|
||||
UUIDColumn = postgres.StringColumn("uuid")
|
||||
TenantIDColumn = postgres.IntegerColumn("tenant_id")
|
||||
TitleColumn = postgres.StringColumn("title")
|
||||
DescriptionColumn = postgres.StringColumn("description")
|
||||
@@ -75,8 +77,8 @@ func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
|
||||
PublishColumn = postgres.BoolColumn("publish")
|
||||
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||
allColumns = postgres.ColumnList{IDColumn, TenantIDColumn, TitleColumn, DescriptionColumn, PriceColumn, DiscountColumn, PublishColumn, CreatedAtColumn, UpdatedAtColumn}
|
||||
mutableColumns = postgres.ColumnList{TenantIDColumn, TitleColumn, DescriptionColumn, PriceColumn, DiscountColumn, PublishColumn, CreatedAtColumn, UpdatedAtColumn}
|
||||
allColumns = postgres.ColumnList{IDColumn, UUIDColumn, TenantIDColumn, TitleColumn, DescriptionColumn, PriceColumn, DiscountColumn, PublishColumn, CreatedAtColumn, UpdatedAtColumn}
|
||||
mutableColumns = postgres.ColumnList{UUIDColumn, TenantIDColumn, TitleColumn, DescriptionColumn, PriceColumn, DiscountColumn, PublishColumn, CreatedAtColumn, UpdatedAtColumn}
|
||||
)
|
||||
|
||||
return mediasTable{
|
||||
@@ -84,6 +86,7 @@ func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
|
||||
|
||||
//Columns
|
||||
ID: IDColumn,
|
||||
UUID: UUIDColumn,
|
||||
TenantID: TenantIDColumn,
|
||||
Title: TitleColumn,
|
||||
Description: DescriptionColumn,
|
||||
|
||||
@@ -9,6 +9,7 @@ require (
|
||||
github.com/gofiber/fiber/v3 v3.0.0-beta.3
|
||||
github.com/gofrs/uuid v4.4.0+incompatible
|
||||
github.com/golang-jwt/jwt/v4 v4.5.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/imroc/req/v3 v3.48.0
|
||||
github.com/jinzhu/copier v0.4.0
|
||||
github.com/juju/go4 v0.0.0-20160222163258-40d72ab9641a
|
||||
@@ -38,7 +39,6 @@ require (
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||
github.com/gofiber/utils/v2 v2.0.0-beta.4 // indirect
|
||||
github.com/google/pprof v0.0.0-20240910150728-a0b0bb1d4134 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"backend/pkg/pg"
|
||||
|
||||
. "github.com/go-jet/jet/v2/postgres"
|
||||
"github.com/google/uuid"
|
||||
"github.com/samber/lo"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
@@ -77,6 +78,7 @@ func TestService_List(t *testing.T) {
|
||||
Convey("insert medias data", func() {
|
||||
items := []model.Medias{
|
||||
{
|
||||
UUID: uuid.New(),
|
||||
TenantID: 1,
|
||||
Title: "title1",
|
||||
Description: "hello",
|
||||
@@ -84,6 +86,7 @@ func TestService_List(t *testing.T) {
|
||||
Publish: true,
|
||||
},
|
||||
{
|
||||
UUID: uuid.New(),
|
||||
TenantID: 1,
|
||||
Title: "title2",
|
||||
Description: "hello",
|
||||
@@ -91,6 +94,7 @@ func TestService_List(t *testing.T) {
|
||||
Publish: true,
|
||||
},
|
||||
{
|
||||
UUID: uuid.New(),
|
||||
TenantID: 1,
|
||||
Title: "title3",
|
||||
Description: "hello",
|
||||
@@ -101,6 +105,7 @@ func TestService_List(t *testing.T) {
|
||||
|
||||
tbl := table.Medias
|
||||
stmt := tbl.INSERT(
|
||||
tbl.UUID,
|
||||
tbl.TenantID,
|
||||
tbl.Title,
|
||||
tbl.Description,
|
||||
|
||||
Reference in New Issue
Block a user