forked from golang-migrate/migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More examples in Mongo (golang-migrate#268)
* adding/removing a new field in the schema * example of updating field value from other fields * added new line at end of files Co-authored-by: Dale Hui <[email protected]>
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
database/mongodb/examples/migrations/003_add_new_field.down.json
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
{ | ||
"update": "users", | ||
"updates": [ | ||
{ | ||
"q": {}, | ||
"u": { | ||
"$unset": { | ||
"status": "" | ||
} | ||
}, | ||
"multi": true | ||
} | ||
] | ||
} | ||
] |
16 changes: 16 additions & 0 deletions
16
database/mongodb/examples/migrations/003_add_new_field.up.json
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
{ | ||
"update": "users", | ||
"updates": [ | ||
{ | ||
"q": {}, | ||
"u": { | ||
"$set": { | ||
"status": "active" | ||
} | ||
}, | ||
"multi": true | ||
} | ||
] | ||
} | ||
] |
14 changes: 14 additions & 0 deletions
14
database/mongodb/examples/migrations/004_replace_field_value_from_another_field.down.json
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"update": "users", | ||
"updates": [ | ||
{ | ||
"q": {}, | ||
"u": { | ||
"fullname": "" | ||
}, | ||
"multi": true | ||
} | ||
] | ||
} | ||
] |
23 changes: 23 additions & 0 deletions
23
database/mongodb/examples/migrations/004_replace_field_value_from_another_field.up.json
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[ | ||
{ | ||
"aggregate": "users", | ||
"pipeline": [ | ||
{ | ||
"$project": { | ||
"_id": 1, | ||
"firstname": 1, | ||
"lastname": 1, | ||
"username": 1, | ||
"password": 1, | ||
"email": 1, | ||
"active": 1, | ||
"fullname": { "$concat": ["$firstname", " ", "$lastname"] } | ||
} | ||
}, | ||
{ | ||
"$out": "users" | ||
} | ||
], | ||
"cursor": {} | ||
} | ||
] |