Skip to content

Commit 14ba46f

Browse files
authored
Merge pull request #21 from mongodb-developer/edit-mapping-rules
Edit mapping rules
2 parents d5d6c69 + 69b3ce4 commit 14ba46f

38 files changed

+219
-173
lines changed

docs/20-prerequisites/10-postgres.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
66

77
# 👐 PostgreSQL Database
88

9-
In this lab you will be migrating data from a PostgreSQL relational database. You have a few options to set up this database. __Choose one option for your PostgreSQL database__.
9+
In this lab you will be migrating data from a PostgreSQL relational database. You have a few options to set up this database. __Choose just one option for your PostgreSQL database__.
1010

1111
## 👐 Option 1: Use a pre-configured database
1212

1313
If you are participating in an instructor-led lab, they may have already set up this database for you. Ask your instructor for the connection URI and credentials.
1414

1515
:::info
16-
In an intructor-led lab you will use the provisioned PostgreSQL database, no need to do anything else
16+
In an intructor-led lab you will use the provisioned PostgreSQL database, no need to do anything else.
1717
:::
1818

1919
## 🦸 Option 2: Load the schema and data into your own PostgreSQL server
2020

2121
If you already have a PostgreSQL server set up, you can import the schema and data used in this lab. Download the file
2222
[1-library-schema-and-data.sql](https://github.com/mongodb-developer/relational-migrator-lab/blob/main/docker/sample-postgres-library/init/1-library-schema-and-data.sql)
23-
file and load it using psql or [pgAdmin](https://www.pgadmin.org/download/).
23+
and load it using [psql](https://www.postgresql.org/docs/10/app-psql.html) or [pgAdmin](https://www.pgadmin.org/download/).
2424

2525
## 🦸 Option 3: Run a PostgreSQL container using Docker
2626

2727
If you don't have an existing PostgreSQL server but have Docker installed, you can easily load a container pre-configured with
2828
PostgreSQL and the sample database:
2929

3030
1. Clone or download the code from this lab's [Github repo](https://github.com/mongodb-developer/relational-migrator-lab).
31-
2. Open a terminal window and navigate to the repo root
31+
2. Open a terminal window and navigate to the repo root.
3232
3. Build the Docker image by running the command:
33-
```
33+
```sh
3434
docker build -f ./docker/sample-postgres-library/Dockerfile -t sample-postgres-library .
3535
```
3636
4. Start the Docker container by running the command:
@@ -40,8 +40,8 @@ docker run -p 5432:5432 sample-postgres-library
4040
The PostgreSQL server can be accessed at localhost:5432 with a username of `postgres` and a password of `postgres`.
4141

4242
## 🦸 Option 4: Load an SQL file
43-
Choose this option if you just want a quick hands-on experience and you don't need to run actual migration.
43+
Choose this option if you just want a quick hands-on experience and you don't need to run an actual migration.
4444
Download the file [library-schema.sql](https://github.com/mongodb-developer/relational-migrator-lab/blob/main/resource/library-schema.sql)
45-
and upload this file to the Relational Migrator later, at the **create a project** step.
45+
and upload this file to the Relational Migrator later, at the [create a project](/docs/category/-create-a-project) step.
4646

4747
This is just the schema of the database, without actual data, so, you will not be able to perform an actual migration since you do not have a source database. But you can model the schema and play around with the Relational Migrator.

docs/220-Generate code/10-generate-app-code.mdx renamed to docs/210-Generate code/10-generate-app-code.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import Screenshot from "@site/src/components/Screenshot";
22

33
# 👐 Generate app code
44

5-
Relational Migrator allows you to generate application code in a variety of languges, dervied from your MongoDB schema definition.
6-
While this code is not production-ready, it can save developers significant time compared to creating entity classes by hand.
5+
The Relational Migrator allows you to generate application code in a variety of languages, derived from your MongoDB schema definition.
6+
While this code is not a full-blown app, it can save developers significant time compared to creating entity classes by hand.
77

88
- At the top, switch to Code Generation tab
9-
- Under Language, select `C#`
9+
- Under Language, select `C#` (or your preferred language)
1010
- Under Template, select `Persistence Layer`
1111
- Click each of the collections in the list. Notice the tabs containing entity classes and CRUD helpers for each collection or embedded object.
1212
- Under Language, select `JSON'
1313
- Under Template, select `Sample Documents`. Notice how you can view examples of how data in each collection will be structured.
14-
- Under Template, select `JSON Schema (MongoDB)`. Notice how you can view and download JSON Schema validators which could be used to enforce schema compliance.
14+
- Under Template, select `JSON Schema (MongoDB)`. Notice how you can view and download JSON [Schema validators](https://mongodb-developer.github.io/intro-lab/docs/category/schema-validation) which could be used to enforce schema compliance.
1515

16-
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/generate-app-code.png" alt="Screenshot of the connect modal" />
16+
<Screenshot url="http://127.0.0.1:8278" src="img/generate-app-code.png" alt="Code generation tab" />
1717

docs/220-Generate code/20-convert-queries.mdx renamed to docs/210-Generate code/20-convert-queries.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ import Screenshot from "@site/src/components/Screenshot";
33
# 👐 Convert SQL queries
44

55
Relational Migrator can help convert SQL queries to MongoDB Query Language, wrapped
6-
in your choice of programming langauge. This feature uses Artifical Intelligence and requires an Atlas account and internet connectivity.
6+
in your choice of programming langauge. This feature uses Artifical Intelligence and requires an <Link to="http://mongodb.com/try">Atlas account</Link> and internet connectivity.
77

88
- At the top, switch to Code Generation tab
99
- Click Query Converter
10-
- Sign into with your MongoDB Atlas account
10+
- Sign into your MongoDB Atlas account
1111
- Accept the Query Converter licence terms
1212
- Click `Paste SQL query`
1313
- In the empty query, type `SELECT * FROM books WHERE "bookOfTheMonth" = true AND pages > 500`
1414
- Leave the language as JavaScript and click Convert.
1515

1616
After a while, the equivalent MongoDB query will be shown at the right of the page.
1717

18-
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/convert-sql-queries.png" alt="Screenshot of the connect modal" />
18+
<Screenshot url="http://127.0.0.1:8278" src="img/convert-sql-queries.png" alt="Screenshot of the connect modal" />
1919

docs/220-Generate code/30-convert-sprocs.mdx renamed to docs/210-Generate code/30-convert-sprocs.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ import Screenshot from "@site/src/components/Screenshot";
55
Relational Migrator can import and convert views and stored procedures to MongoDB Query Language, wrapped
66
in your choice of programming langauge. This feature uses Artifical Intelligence and requires an Atlas account and internet connectivity.
77

8-
- If needed, open Query Converter and sign in with your Atlas account
9-
- Click Manage database objects
10-
- Enter the details for your PostgreSQL server and click Connect
11-
- Check all discovered Views and Stored Procedures and click Save
8+
- If needed, open Query Converter and sign in with your Atlas account.
9+
- Click on the `Add` button, the `Import from database`.
10+
- Check all Views and Stored Procedures and click `Save`.
1211
- Click one of the imported views or stored procedures
1312
- Select your preferred programming language and click Convert.
1413

1514
After a while, the equivalent MongoDB query will be shown at the right of the page. Try some other queries and langauges!
1615

17-
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/convert-sprocs.png" alt="Screenshot of the connect modal" />
16+
<Screenshot url="http://127.0.0.1:8278" src="img/convert-sprocs.png" alt="Screenshot of the connect modal" />
1817

docs/220-Generate code/40-testing-queries.mdx renamed to docs/210-Generate code/40-testing-queries.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ Relation Migrator allows you to go a step further, and verify the converted quer
1313
2. If you source data resides in the `public` schema in your PostgreSQL database, you may skip this step. Otherwise, you will need to add your source data schema into PostgreSQL's search path in order for the queries execute properly.
1414

1515
Go to **Manage Connections**:
16-
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/testing-queries-001.png" alt="Screenshot to manage connection" />
16+
<Screenshot url="http://127.0.0.1:8278" src="img/testing-queries-001.png" alt="Screenshot to manage connection" />
1717

1818
Edit your **JDBC URI** to include the search path. For example, if your source schema is `library`, add `options=-c%20search_path%3Dlibrary` as a query parameter to your URI:
1919

20-
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/testing-queries-002.png" alt="Screenshot to add search path" />
20+
<Screenshot url="http://127.0.0.1:8278" src="img/testing-queries-002.png" alt="Screenshot to add search path" />
2121

2222
Click **Save** and you can use the browser's **back button** to navigate back to the Query Converter page.
2323

2424
3. After which, you may expand the test query panel to begin executing your source query or converted query.
2525

26-
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/testing-queries-003.png" alt="Screenshot to expand query test panel" />
26+
<Screenshot url="http://127.0.0.1:8278" src="img/testing-queries-003.png" alt="Screenshot to expand query test panel" />
2727

2828
## Executing queries for comparison
2929

3030
1. Select the source query you want to test on the left pane. As an example, we will select the `get_books_by_genre` stored procedure.
3131
2. Convert the query to a MongoDB query if you have not done so, but note that the converted query may not always be correct.
3232
3. If it is a stored procedure, you will need to replace the placeholder parameter with a test value. In this example, we will replace it with `'Literature'`.
33-
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/testing-queries-004.png" alt="Screenshot to show placeholder replacement" />
33+
<Screenshot url="http://127.0.0.1:8278" src="img/testing-queries-004.png" alt="Screenshot to show placeholder replacement" />
3434
4. Click **RUN SOURCE QUERY** and **RUN CONVERTED QUERY** to execute the queries and compare the results.
35-
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/testing-queries-005.png" alt="Screenshot to show result comparison" />
35+
<Screenshot url="http://127.0.0.1:8278" src="img/testing-queries-005.png" alt="Screenshot to show result comparison" />
3636
5. If the query results are different, check your MongoDB query. In this example, your MongoDB query should look like:
3737
```js
3838
async function get_books_by_genre(db, genre_param) {

docs/210-Migrate Data/10-migration.mdx

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Screenshot from "@site/src/components/Screenshot";
2+
3+
# 👐 Run a Snapshot Migration Job
4+
5+
- At the top, switch to Data Migration tab
6+
7+
<Screenshot url="http://127.0.0.1:8278" src="img/210-image-001.png" alt="Screenshot of the connect modal" />
8+
9+
- Click create sync job
10+
- Specify source DB connection details
11+
- The details will be populated from when you created the project.
12+
13+
<Screenshot url="http://127.0.0.1:8278" src="img/210-image-002.png" alt="Screenshot of the connect modal" />
14+
15+
- Specify MongoDB connection details
16+
- Enter the URI, database, username and password for your MongoDB cluster
17+
- If you are using Atlas, you can retrieve the details from the [Atlas portal](https://cloud.mongodb.com)
18+
19+
<Screenshot url="http://127.0.0.1:8278" src="img/210-image-003.png" alt="Screenshot of the connect modal" />
20+
21+
- Specify migration options
22+
- Choose the `Drop destination collections before migration` option
23+
24+
<Screenshot url="http://127.0.0.1:8278" src="img/210-image-004.png" alt="Screenshot of the connect modal" />
25+
26+
- Read migration summary to confirm details
27+
- Run Start
28+
- Monitor the progress of the job
29+
30+
<Screenshot url="http://127.0.0.1:8278" src="img/210-image-005.png" alt="Screenshot of the connect modal" />

docs/210-Migrate Data/20-view-migrated-data.mdx renamed to docs/220-Migrate Data/20-view-migrated-data.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ MongoDB Compass, or MongoDB Atlas. This topic assumes you have migrated your dat
1111
- Select the database you migrated data to
1212
- Select each of the collections and view the documents, confirming they conform to the schema you created.
1313

14-
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/view-migrated-data-atlas.png" alt="Screenshot of the connect modal" />
14+
<Screenshot url="http://127.0.0.1:8278" src="img/view-migrated-data-atlas.png" alt="Screenshot of the connect modal" />

docs/30-schema-in-postgresql.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Screenshot from "@site/src/components/Screenshot";
22

33
# 📘 Schema in PostgreSQL
44

5-
The following screenshot shows an entity-relationship diagram of the relational database we wish to migrate. This is a library management app that stores information about books, where a book can have many authors, an author can write many books, and users can borrow books and leave reviews. You can have many copies of the same book (issue_details) and those are what users borrow and return. A library user can have many addresses.
5+
The following screenshot shows an entity-relationship diagram of the relational database we wish to migrate. This is a library management app that stores information about books, where a book can have many authors, an author can write many books, and users can borrow books and leave reviews. You can have many copies of the same book and those are what users borrow and return. All this is registered in the `operations` collection. A library user can have many addresses.
66

77
This is the sample schema we use during our [Developer Days's Intro Lab](https://mongodb-developer.github.io/intro-lab/docs/importing-data/intro).
88

0 commit comments

Comments
 (0)