Skip to content

Commit aeb2768

Browse files
authored
Merge branch 'development' into feature/ldap-auth
2 parents e324976 + 346004b commit aeb2768

File tree

32 files changed

+2535
-842
lines changed

32 files changed

+2535
-842
lines changed

.github/workflows/go.yml

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -276,44 +276,44 @@ jobs:
276276
path: coverage_reports/*.cov
277277

278278
# Job for uploading coverage to external services (CodeClimate)
279-
upload_coverage:
280-
name: Upload Coverage📊
281-
runs-on: ubuntu-latest
282-
# This job only needs example and pkg test results, not submodules
283-
needs: [Example-Unit-Testing, PKG-Unit-Testing]
284-
# Only run this job on pushes to the development branch
285-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development'}}
286-
steps:
287-
- name: Check out code into the Go module directory
288-
uses: actions/checkout@v4
289-
290-
# Download coverage artifacts
291-
- name: Download Coverage Report
292-
uses: actions/download-artifact@v4
293-
with:
294-
path: artifacts
295-
296-
# Merge coverage from example and pkg tests only
297-
- name: Merge Coverage Files
298-
working-directory: artifacts
299-
run: |
300-
echo "mode: set" > merged_profile.cov
301-
tail -n +2 ./Example-Test-Report/profile.cov >> merged_profile.cov
302-
tail -n +2 ./PKG-Coverage-Report/profile.cov >> merged_profile.cov
303-
304-
# Generate and print total coverage percentage
305-
echo "Total Coverage:"
306-
go tool cover -func=merged_profile.cov | tail -n 1
307-
shell: bash
308-
309-
# Upload merged coverage to CodeClimate for analysis
310-
- name: Upload
311-
uses: paambaati/[email protected]
312-
env:
313-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
314-
with:
315-
coverageLocations: artifacts/merged_profile.cov:gocov
316-
prefix: gofr.dev
279+
# upload_coverage:
280+
# name: Upload Coverage📊
281+
# runs-on: ubuntu-latest
282+
# # This job only needs example and pkg test results, not submodules
283+
# needs: [Example-Unit-Testing, PKG-Unit-Testing]
284+
# # Only run this job on pushes to the development branch
285+
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development'}}
286+
# steps:
287+
# - name: Check out code into the Go module directory
288+
# uses: actions/checkout@v4
289+
#
290+
# # Download coverage artifacts
291+
# - name: Download Coverage Report
292+
# uses: actions/download-artifact@v4
293+
# with:
294+
# path: artifacts
295+
#
296+
# # Merge coverage from example and pkg tests only
297+
# - name: Merge Coverage Files
298+
# working-directory: artifacts
299+
# run: |
300+
# echo "mode: set" > merged_profile.cov
301+
# tail -n +2 ./Example-Test-Report/profile.cov >> merged_profile.cov
302+
# tail -n +2 ./PKG-Coverage-Report/profile.cov >> merged_profile.cov
303+
#
304+
# # Generate and print total coverage percentage
305+
# echo "Total Coverage:"
306+
# go tool cover -func=merged_profile.cov | tail -n 1
307+
# shell: bash
308+
#
309+
# # Upload merged coverage to CodeClimate for analysis
310+
# - name: Upload
311+
# uses: paambaati/[email protected]
312+
# env:
313+
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
314+
# with:
315+
# coverageLocations: artifacts/merged_profile.cov:gocov
316+
# prefix: gofr.dev
317317

318318
# Job for code quality checks
319319
code_quality:

docs/advanced-guide/handling-data-migrations/page.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,41 @@ func createTableEmployeeCassandra() migration.Migrate {
238238
}
239239
```
240240

241+
## Migrations in ElasticSearch
242+
243+
GoFr allows Elasticsearch document migrations, focusing on **single document** and **bulk operations**.
244+
245+
### Single Document Migration
246+
247+
```go
248+
func addSingleProduct() migration.Migrate {
249+
return migration.Migrate{
250+
UP: func(d migration.Datasource) error {
251+
product := map[string]any{
252+
"title": "Laptop",
253+
"price": 999.99,
254+
"category": "electronics",
255+
}
256+
257+
return d.Elasticsearch.IndexDocument( context.Background(), "products", "1", product, ) }, }
258+
}
259+
```
260+
261+
### Bulk Operation Migration
262+
263+
```go
264+
func bulkProducts() migration.Migrate {
265+
return migration.Migrate{
266+
UP: func(d migration.Datasource) error {
267+
operations := []map[string]any{
268+
{"index": map[string]any{"_index": "products", "_id": "1"}},
269+
{"title": "Phone", "price": 699.99, "category": "electronics"},
270+
{"index": map[string]any{"_index": "products", "_id": "2"}},
271+
{"title": "Mug", "price": 12.99, "category": "kitchen"},
272+
}
273+
274+
_, err := d.Elasticsearch.Bulk(context.Background(), operations) return err },}
275+
}
276+
```
277+
241278
> ##### Check out the example to add and run migrations in GoFr: [Visit GitHub](https://github.com/gofr-dev/gofr/blob/main/examples/using-migrations/main.go)

0 commit comments

Comments
 (0)