diff --git a/CHANGELOG.md b/CHANGELOG.md index a484ba80..6e53f20e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.5.0-beta.1](https://github.com/LerianStudio/midaz/compare/v1.4.0...v1.5.0-beta.1) (2024-06-04) + + +### Bug Fixes + +* bring back omitempty on metadata in field _id because cant generate automatic id without :bug: ([d68be08](https://github.com/LerianStudio/midaz/commit/d68be08765d57c7c01d4a9b1f0466070007839c2)) + ## [1.4.0](https://github.com/LerianStudio/midaz/compare/v1.3.0...v1.4.0) (2024-06-04) ## [1.4.0-beta.1](https://github.com/LerianStudio/midaz/compare/v1.3.0...v1.4.0-beta.1) (2024-06-04) diff --git a/components/ledger/internal/app/command/create-ledger.go b/components/ledger/internal/app/command/create-ledger.go index 019c7c19..815bf097 100644 --- a/components/ledger/internal/app/command/create-ledger.go +++ b/components/ledger/internal/app/command/create-ledger.go @@ -29,6 +29,8 @@ func (uc *UseCase) CreateLedger(ctx context.Context, organizationID string, cli OrganizationID: organizationID, Name: cli.Name, Status: status, + CreatedAt: time.Now(), + UpdatedAt: time.Now(), } led, err := uc.LedgerRepo.Create(ctx, ledger) diff --git a/components/ledger/internal/domain/metadata/metadata.go b/components/ledger/internal/domain/metadata/metadata.go index 546af017..b92faa34 100644 --- a/components/ledger/internal/domain/metadata/metadata.go +++ b/components/ledger/internal/domain/metadata/metadata.go @@ -11,7 +11,7 @@ import ( // MetadataMongoDBModel represents the metadata into mongodb context type MetadataMongoDBModel struct { - ID primitive.ObjectID `bson:"_id"` + ID primitive.ObjectID `bson:"_id,omitempty"` EntityID string `bson:"entity_id"` EntityName string `bson:"entity_name"` Data JSON `bson:"metadata"` diff --git a/components/ledger/migrations/000005_create_portfolio_table.up.sql b/components/ledger/migrations/000005_create_portfolio_table.up.sql index 54a33704..266b62f1 100644 --- a/components/ledger/migrations/000005_create_portfolio_table.up.sql +++ b/components/ledger/migrations/000005_create_portfolio_table.up.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS portfolio ( id UUID PRIMARY KEY NOT NULL DEFAULT (uuid_generate_v4()), name TEXT, - entity_id UUID NOT NULL, + entity_id TEXT NOT NULL, ledger_id UUID NOT NULL, organization_id UUID NOT NULL, status TEXT NOT NULL, diff --git a/postman/MIDAZ.postman_collection.json b/postman/MIDAZ.postman_collection.json index d5d72317..7823d182 100644 --- a/postman/MIDAZ.postman_collection.json +++ b/postman/MIDAZ.postman_collection.json @@ -19,9 +19,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"organization_id antes: \" + postman.getEnvironmentVariable(\"organization_id\"));", + " console.log(\"organization_id before: \" + postman.getEnvironmentVariable(\"organization_id\"));", " postman.setEnvironmentVariable(\"organization_id\", jsonData.id);", - " console.log(\"organization_id depois: \" + postman.getEnvironmentVariable(\"organization_id\"));", + " console.log(\"organization_id after: \" + postman.getEnvironmentVariable(\"organization_id\"));", "}" ], "type": "text/javascript", @@ -139,17 +139,17 @@ { "key": "metadata.chave", "value": "teste", - "description": "com, pesquisa no mongodb, sem, pesquisa no postgresql." + "description": "Search on MongoDB" }, { "key": "limit", "value": "6", - "description": "default 10" + "description": "Default 10" }, { "key": "page", "value": "1", - "description": "default 1" + "description": "Default 1" } ] } @@ -244,9 +244,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"ledger_id antes: \" + postman.getEnvironmentVariable(\"ledger_id\"));", + " console.log(\"ledger_id before: \" + postman.getEnvironmentVariable(\"ledger_id\"));", " postman.setEnvironmentVariable(\"ledger_id\", jsonData.id);", - " console.log(\"ledger_id depois: \" + postman.getEnvironmentVariable(\"ledger_id\"));", + " console.log(\"ledger_id after: \" + postman.getEnvironmentVariable(\"ledger_id\"));", "}" ], "type": "text/javascript", @@ -354,15 +354,18 @@ "query": [ { "key": "metadata.chave", - "value": "teste" + "value": "teste", + "description": "Search on MongoDB" }, { "key": "limit", - "value": "5" + "value": "5", + "description": "Default 10" }, { "key": "page", - "value": "1" + "value": "1", + "description": "Default 1" } ] } @@ -449,9 +452,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"instrument_id antes: \" + postman.getEnvironmentVariable(\"instrument_id\"));", + " console.log(\"instrument_id before: \" + postman.getEnvironmentVariable(\"instrument_id\"));", " postman.setEnvironmentVariable(\"instrument_id\", jsonData.id);", - " console.log(\"instrument_id depois: \" + postman.getEnvironmentVariable(\"instrument_id\"));", + " console.log(\"instrument_id after: \" + postman.getEnvironmentVariable(\"instrument_id\"));", "}" ], "type": "text/javascript", @@ -553,15 +556,18 @@ "query": [ { "key": "metadata.chave", - "value": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlf" + "value": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlf", + "description": "Search on MongoDB" }, { "key": "limit", - "value": "2" + "value": "2", + "description": "Default 10" }, { "key": "page", - "value": "1" + "value": "1", + "description": "Default 1" } ] } @@ -639,9 +645,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"portfolio_id antes: \" + postman.getEnvironmentVariable(\"portfolio_id\"));", + " console.log(\"portfolio_id before: \" + postman.getEnvironmentVariable(\"portfolio_id\"));", " postman.setEnvironmentVariable(\"portfolio_id\", jsonData.id);", - " console.log(\"portfolio_id depois: \" + postman.getEnvironmentVariable(\"portfolio_id\"));", + " console.log(\"portfolio_id after: \" + postman.getEnvironmentVariable(\"portfolio_id\"));", "}" ], "type": "text/javascript", @@ -743,15 +749,18 @@ "query": [ { "key": "metadata.chave", - "value": "teste" + "value": "teste", + "description": "Search on MongoDB" }, { "key": "limit", - "value": "2" + "value": "2", + "description": "Default 10" }, { "key": "page", - "value": "1" + "value": "1", + "description": "Default 1" } ] } @@ -829,9 +838,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"product_id antes: \" + postman.getEnvironmentVariable(\"product_id\"));", + " console.log(\"product_id before: \" + postman.getEnvironmentVariable(\"product_id\"));", " postman.setEnvironmentVariable(\"product_id\", jsonData.id);", - " console.log(\"product_id depois: \" + postman.getEnvironmentVariable(\"product_id\"));", + " console.log(\"product_id after: \" + postman.getEnvironmentVariable(\"product_id\"));", "}" ], "type": "text/javascript", @@ -925,7 +934,7 @@ "formdata": [] }, "url": { - "raw": "{{url}}/v1/organizations/{{organization_id}}/ledgers/{{ledger_id}}/products?metadata.chave=teste&limit=5&page=1", + "raw": "{{url}}/v1/organizations/{{organization_id}}/ledgers/{{ledger_id}}/products?metadata.chave=metadata_chave&limit=5&page=1", "host": [ "{{url}}" ], @@ -940,15 +949,18 @@ "query": [ { "key": "metadata.chave", - "value": "teste" + "value": "metadata_chave", + "description": "Search on MongoDB" }, { "key": "limit", - "value": "5" + "value": "5", + "description": "Default 10" }, { "key": "page", - "value": "1" + "value": "1", + "description": "Default 1" } ] } @@ -1026,9 +1038,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"account_id antes: \" + postman.getEnvironmentVariable(\"account_id\"));", + " console.log(\"account_id before: \" + postman.getEnvironmentVariable(\"account_id\"));", " postman.setEnvironmentVariable(\"account_id\", jsonData.id);", - " console.log(\"account_id depois: \" + postman.getEnvironmentVariable(\"account_id\"));", + " console.log(\"account_id after: \" + postman.getEnvironmentVariable(\"account_id\"));", "}" ], "type": "text/javascript", @@ -1136,15 +1148,18 @@ "query": [ { "key": "metadata.chave", - "value": "xuxa" + "value": "xuxa", + "description": "Search on MongoDB" }, { "key": "limit", - "value": "2" + "value": "2", + "description": "Default 10" }, { "key": "page", - "value": "1" + "value": "1", + "description": "Default 1" } ] }