-
Notifications
You must be signed in to change notification settings - Fork 188
feat: add mongoDB changset example #10914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Sonichigo
wants to merge
2
commits into
harness:main
Choose a base branch
from
Sonichigo:dbops-1327
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+182
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
182 changes: 182 additions & 0 deletions
182
.../database-devops/use-database-devops/get-started/get-started-with-changelogs.md
This file contains hidden or 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,182 @@ | ||
--- | ||
title: Get Started with Changelogs | ||
description: Learn how to define changelogs for SQL and MongoDB in Harness Database DevOps. | ||
sidebar_position: 3 | ||
sidebar_label: Get Started with Changelogs | ||
hide_table_of_contents: true | ||
--- | ||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
# Get Started with Changelogs | ||
|
||
Harness Database DevOps supports changelogs in various formats to manage schema changes across environments. Below are examples of SQL and MongoDB changelogs to help you get started quickly. | ||
|
||
## Example Changelogs | ||
|
||
<Tabs> | ||
<TabItem value="sql" label="SQL Changelog" default> | ||
|
||
```yaml | ||
databaseChangeLog: | ||
- changeSet: | ||
id: product-table-v2 | ||
author: john-doe | ||
labels: products-api | ||
comment: Creating product table for REST API | ||
changes: | ||
- createTable: | ||
tableName: product | ||
columns: | ||
- column: | ||
name: id | ||
type: SERIAL | ||
constraints: | ||
primaryKey: true | ||
- column: | ||
name: name | ||
type: VARCHAR(100) | ||
constraints: | ||
nullable: false | ||
- column: | ||
name: price | ||
type: NUMERIC(10,2) | ||
defaultValue: 0.00 | ||
constraints: | ||
nullable: false | ||
rollback: | ||
- dropTable: | ||
tableName: product | ||
- changeSet: | ||
id: product-table-indexes-v2 | ||
author: john-doe | ||
labels: products-api | ||
comment: Adding indexes for the products table | ||
changes: | ||
- createIndex: | ||
tableName: product | ||
columns: | ||
- column: | ||
name: name | ||
indexName: idx_products_name | ||
rollback: | ||
- dropIndex: | ||
indexName: idx_products_name | ||
tableName: product | ||
- changeSet: | ||
id: product-sample-data-initial | ||
author: john-doe | ||
labels: products-api-v2 | ||
comment: Inserting initial sample data for non-production environments | ||
changes: | ||
- insert: | ||
tableName: product | ||
columns: | ||
- column: | ||
name: name | ||
value: "Wireless Bluetooth Headphones" | ||
- column: | ||
name: price | ||
value: 89.99 | ||
- insert: | ||
tableName: product | ||
columns: | ||
- column: | ||
name: name | ||
value: "USB-C Charging Cable" | ||
- column: | ||
name: price | ||
value: 15.99 | ||
rollback: | ||
- delete: | ||
tableName: product | ||
where: name in ('Wireless Bluetooth Headphones', 'USB-C Charging Cable') | ||
- changeSet: | ||
id: product-sample-data-accessories | ||
author: john-doe | ||
labels: products-api | ||
comment: Inserting accessories sample data for non-production environments | ||
changes: | ||
- insert: | ||
tableName: product | ||
columns: | ||
- column: | ||
name: name | ||
value: "Wireless Mouse Pad" | ||
- column: | ||
name: price | ||
value: 12.50 | ||
- insert: | ||
tableName: product | ||
columns: | ||
- column: | ||
name: name | ||
value: "Ergonomic Laptop Stand" | ||
- column: | ||
name: price | ||
value: 65.99 | ||
rollback: | ||
- delete: | ||
tableName: product | ||
where: name in ('Wireless Mouse Pad', 'Ergonomic Laptop Stand') | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="mongodb" label="MongoDB Changelog"> | ||
|
||
```yaml | ||
databaseChangeLog: | ||
- changeSet: | ||
id: devteam:1 | ||
author: john-doe | ||
comment: Create users collection | ||
changes: | ||
- createCollection: | ||
collectionName: users | ||
options: '{"validator": {"$jsonSchema": {"bsonType": "object", "required": ["name", "email"], "properties": {"name": {"bsonType": "string", "description": "User''s full name"}, "email": {"bsonType": "string", "description": "User''s email address"}, "status": {"bsonType": "string", "enum": ["active", "inactive", "pending"], "description": "Account status"}}}}, "validationAction": "warn", "validationLevel": "strict"}' | ||
- changeSet: | ||
id: devteam:2 | ||
author: john-doe | ||
comment: Add unique index on email | ||
changes: | ||
- createIndex: | ||
collectionName: users | ||
keys: '{email: 1}' | ||
options: '{unique: true, name: "idx_email_unique"}' | ||
- changeSet: | ||
id: devteam:3 | ||
author: john-doe | ||
ignore: false | ||
context: production | ||
comment: Add compound index for user queries | ||
changes: | ||
- createIndex: | ||
collectionName: users | ||
keys: '{status: 1, createdAt: -1}' | ||
options: '{name: "idx_status_created", background: true}' | ||
- changeSet: | ||
id: devteam:4-base | ||
author: john-doe | ||
ignore: false | ||
changes: | ||
- createCollection: | ||
collectionName: orders | ||
- changeSet: | ||
id: devteam:4-index | ||
author: john-doe | ||
ignore: false | ||
changes: | ||
- createIndex: | ||
collectionName: orders | ||
keys: '{"userId": 1, "status": 1, "orderDate": -1, "totalAmount": 1}' | ||
options: '{name: "orders_user_status_idx"}' | ||
- changeSet: | ||
id: devteam:5 | ||
author: john-doe | ||
comment: Create products collection | ||
changes: | ||
- createCollection: | ||
collectionName: products | ||
``` | ||
</TabItem> | ||
</Tabs> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.