Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
80 changes: 80 additions & 0 deletions docs/10-dev-env/1-dev-env-setup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import Screenshot from "@site/src/components/Screenshot";

# 👐 Setup

## GitHub Codespaces

You will be working in GitHub Codespaces throughout this lab. A codespace is a cloud-hosted, containerized development environment that comes pre-configured with all the tools you need to run this lab.

Navigate to [this](https://github.com/codespaces/new/mongodb-developer/rm-lab?quickstart=1) link. You will be prompted to sign into GitHub if you haven't already. Once signed in, click the **Create new codespace** button to create a new codespace.

<Screenshot url="https://github.com/codespaces" src="img/10-dev-env/1-create-codespace.png" alt="Start a codespace" />

Let it run for a few minutes as it prepares a Docker container with all the required libraries and a MongoDB cluster.

**That's it! You're ready for the lab!**

:::caution
During the lab, we will use GitHub Codespaces. The following instructions are here just in case you can't use Codespaces or if you really, really, really want a local installation.
:::


<details>
<summary>🦹 __Run this lab locally__</summary>
#
# 1. 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 A: 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 B: 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 C: Run a MongoDB container using Docker


If you don't have an existing MongoDB 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.


# 2. MongoDB Relational Migrator

Download and install MongoDB Relational Migrator.

- Go to the [MongoDB Relational Migrator downloads page](https://www.mongodb.com/try/download/relational-migrator), select your OS and download it
- Install the MongoDB Relational Migrator
- Start it
- It should open a browser at the address 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" />

---

There are more advanced ways to install the MongoDB Relational Migrator. You can check them out in [the installation docs page](https://www.mongodb.com/docs/relational-migrator/installation/). These won't be covered during this Lab.

</details>




52 changes: 52 additions & 0 deletions docs/10-dev-env/10-postgres.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
sidebar_position: 20
---

import useBaseUrl from '@docusaurus/useBaseUrl';

# PostgreSQL Database

In this lab you will be migrating data from a PostgreSQL relational database.

## 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.

:::caution
In an intructor-led lab you will use the provisioned PostgreSQL database, no need to do anything else.
:::

<details>
<summary>🦹 __Other database options__</summary>

## 🦸 Option A: 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)
and load it using [psql](https://www.postgresql.org/docs/10/app-psql.html) or [pgAdmin](https://www.pgadmin.org/download/).

## 🦸 Option B: 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:
```sh
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 C: Load a SQL file
Choose this option if you just want a quick hands-on experience and you don't need to run an 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](/docs/category/-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.

</details>
8 changes: 8 additions & 0 deletions docs/10-dev-env/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Dev Environment",
"position": 10,
"link": {
"type": "generated-index",
"description": "Setup the dev environment and prerequisites"
}
}
47 changes: 0 additions & 47 deletions docs/20-prerequisites/10-postgres.mdx

This file was deleted.

43 changes: 0 additions & 43 deletions docs/20-prerequisites/20-mongodb.mdx

This file was deleted.

22 changes: 0 additions & 22 deletions docs/20-prerequisites/30-relational-migrator.mdx

This file was deleted.

7 changes: 0 additions & 7 deletions docs/20-prerequisites/_category_.json

This file was deleted.

3 changes: 1 addition & 2 deletions docs/50-create-project/50-create-new-project.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import Screenshot from "@site/src/components/Screenshot";

# 👐 Creating a New Project

Ensure the Relational Migrator is installed and running (usually at http://127.0.0.1:8278/).

Ensure the Relational Migrator is installed and running (in your codespace or locally at http://127.0.0.1:8278/).


## Click on New Project
Expand Down
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const config = {
title: `${title}`,
tagline: `${tagLine}`,
url: `https://${workshopName}.github.io`,
baseUrl: `/${workshopName}/`,
baseUrl: `/`,
projectName: `${organizationName}.github.io`,
organizationName: `${organizationName}`,
trailingSlash: false,
Expand Down
Loading