-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from mongodb-developer/revamp-prerequisites
Revamped prerequisites, improved instructions overall
- Loading branch information
Showing
18 changed files
with
158 additions
and
108 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
--- | ||
sidebar_position: 20 | ||
--- | ||
|
||
import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
|
||
# π PostgreSQL Database | ||
|
||
In this lab you will be migrating data from a PostgreSQL relational database. You have a few options to set up this database. | ||
|
||
### Option 1: Use a pre-configured database | ||
|
||
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. | ||
|
||
### Option 2: Load the schema and data into your own PostgreSQL server | ||
|
||
If you already have a PostgreSQL server set up, you can import the schema and data used in this lab. Download the file | ||
[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) | ||
file and load it using psql or [pgAdmin](https://www.pgadmin.org/download/). | ||
|
||
### Option 3: Run a PostgreSQL container using Docker | ||
|
||
If you don't have an existing PostgreSQL server but have Docker installed, you can easily load a container pre-configured with | ||
PostgreSQL and the sample database: | ||
|
||
1. Clone or download the code from this lab's [Github repo](https://github.com/mongodb-developer/relational-migrator-lab). | ||
2. Open a terminal window and navigate to the repo root | ||
3. Build the Docker image by running the command: | ||
``` | ||
docker build -f ./docker/sample-postgres-library/Dockerfile -t sample-postgres-library . | ||
``` | ||
4. Start the Docker container by running the command: | ||
``` | ||
docker run -p 5432:5432 sample-postgres-library | ||
``` | ||
The PostgreSQL server can be accessed at localhost:5432 with a username of `postgres` and a password of `postgres`. | ||
|
||
### Option 4: Load an SQL file | ||
Choose this option if you just want a quick hands-on experience and you don't need to run actual migration. | ||
Download the file [library-schema.sql](https://github.com/mongodb-developer/relational-migrator-lab/blob/main/resource/library-schema.sql) | ||
and upload this file to the Relational Migrator later, at the **create a project** step. | ||
|
||
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. |
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,39 @@ | ||
--- | ||
sidebar_position: 20 | ||
--- | ||
|
||
import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
|
||
# π MongoDB Database | ||
|
||
As we'll be importing data from a Relational Database into MongoDB, you'll need to have a MongoDB database. You have a | ||
few options to set up this database. | ||
|
||
### Option 1: New MongoDB Atlas cluster | ||
|
||
The easiest way to run MongoDB is to use MongoDB Atlas, our cloud-hosted database offering. | ||
You can set a MongoDB Atlas account and a free forever M0 Cluster. | ||
|
||
To get yours, follow the instructions on the [Intro Lab:](https://mongodb-developer.github.io/intro-lab/docs/mongodb-atlas/what-is-mongodb) | ||
- [Create your Account](https://mongodb-developer.github.io/intro-lab/docs/mongodb-atlas/create-account) | ||
- [Deploy a Database Cluster](https://mongodb-developer.github.io/intro-lab/docs/mongodb-atlas/create-cluster) | ||
|
||
Be sure to [open up the cluster to allow connections from your local computer](https://www.mongodb.com/docs/guides/atlas/network-connections/#overview), and configure a database user with the readWriteAnyDatabase role. | ||
|
||
### Option 2: Use an existing cluster | ||
|
||
If you have an existing MongoDB Atlas, Enterprise or Community cluster, you can use it as the migration target. Make sure you | ||
know the URI for the cluster, and have a database user with the readWriteAnyDatabase role. | ||
|
||
### Option 3: Run a MongoDB container using Docker | ||
|
||
|
||
If you don't have an existing PostgreSQL server but have Docker installed, you can easily load a container pre-configured with | ||
MongoDB by running the following command: | ||
|
||
``` | ||
docker run -p 27017:27017 mongo | ||
``` | ||
|
||
This will launch an empty MongoDB community cluster on localhost:27017, suitable to use for this lab. | ||
You can connect with no username or password. Since this command does not use Docker volumes, any data will be lost when the container is stopped. |
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 @@ | ||
--- | ||
sidebar_position: 20 | ||
--- | ||
|
||
import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
|
||
# π MongoDB Relational Migrator | ||
|
||
Download and install MongoDB Relational Migrator | ||
|
||
Now you will need to go to the [MongoDB Relational Migrator downloads page](https://www.mongodb.com/try/download/relational-migrator), select your OS, download and install it. Once installed, | ||
run it and it will be running on a browser at http://127.0.0.1:8278/. | ||
|
||
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/download-relational-migrator.png" alt="Screenshot of the download page for Relational Migrator" /> |
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,7 @@ | ||
{ | ||
"label": "π Prerequisites", | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Prerare everything you need to complete this Lab." | ||
} | ||
} |
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
10 changes: 5 additions & 5 deletions
10
...-Create a Project/60-connect-database.mdx β ...50-create-project/60-connect-database.mdx
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import Screenshot from "@site/src/components/Screenshot"; | ||
|
||
# π Connect Database | ||
# π Connect to the Database | ||
|
||
## Select PostgreSQL as Database | ||
## Select PostgreSQL as Database Type | ||
|
||
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/60-image-000.png" alt="Selecting PostgreSQL as Database" /> | ||
|
||
## Enter connection details | ||
|
||
Enter the details for the PostgreSQL database you will be migrating from. | ||
|
||
- If your instructor has configured a server for you to use, ask them for the host name, username and password. | ||
- If your instructors have configured a server for you to use, ask them for the host name, username and password. It's important to click on the `SSL` tab and active SSL. | ||
- If you followed the steps to configure PostgreSQL in a docker container, the hostname will be `localhost`, username `postgres` and password `postgres`. | ||
|
||
Click Test Connection to ensure your details are correct. | ||
Click `Test Connection` to ensure your details are correct. | ||
|
||
Click Connect to proceed to the next step. | ||
Click `Connect` to proceed to the next step. | ||
|
||
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/60-image-001.png" alt="Screenshot of the connect modal" /> |
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
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
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,7 @@ | ||
{ | ||
"label": "π Create a Project", | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Create your Project in Relational Migrator." | ||
} | ||
} |
25 changes: 22 additions & 3 deletions
25
docs/80-Edit Mapping Rules/10-edit-mapping-books-book-attribute.mdx
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 |
---|---|---|
@@ -1,16 +1,35 @@ | ||
import Screenshot from "@site/src/components/Screenshot"; | ||
|
||
# π Edit mapping to books collection (from book_attribute table) | ||
# π Clean book attributes up | ||
|
||
|
||
We want to clean up the book_attributes array in our MongoDB schema. | ||
We want to clean up the book_attributes array in our MongoDB schema. We want an array of objects containing attributes, modelled a key value pairs. something like: | ||
|
||
```json | ||
{ | ||
"_id": 838383, // book id | ||
"attributes": [ | ||
{ | ||
"key": "price", | ||
"value": 11 | ||
}, | ||
{ | ||
"key": "pages", | ||
"value": 236 | ||
}, | ||
// ... | ||
] | ||
} | ||
``` | ||
|
||
- On the MongoDB diagram view, click the `books` collection | ||
- On the relational mappings list on the right, click on the edit icon of `book_attribute` embedded array mapping rule. | ||
- Change the Field name from `bookAttributes` to `attributes` | ||
- Uncheck `bookId` | ||
- Uncheck `bookId`. We just want all the attributes, which are key/value pairs. | ||
- Click `Save and close` | ||
|
||
Here we've implemented the [Attribute Pattern](https://www.mongodb.com/developer/products/mongodb/attribute-pattern/) for MongoDB. | ||
|
||
|
||
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/150-image-001.png" alt="Screenshot of the connect modal" /> | ||
|
4 changes: 2 additions & 2 deletions
4
docs/80-Edit Mapping Rules/20-edit-mapping-books-book-genre.mdx
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
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
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.