
# Deployment Script Documentation

## Introduction
This document explains the different tasks available in the `deployer.php` script, specifically the `export`, `import:preprod`, and `import` tasks. These tasks are used to manage deployment operations and database migrations between different environments (QA, PREPROD, and LOCAL).

## Prerequisites
- Docker (for local environment)
- SSH access configured for the destination servers
- Command-line tools like `scp` and `rsync`

## Configuration
Ensure that the hosts are properly configured in the `deployer-seeding.php` script with the correct credentials and deployment paths.

## Makefile
We generated instructions in makefile for easier usage
### `make seed_export` Task
The tech lead runs this command to export data from QA to DEV

```bash
./src/common/vendor/bin/dep export -f deploy-seeding.php role=export
```

### `make seed_import_preprod` Task
The tech lead runs this command to update the preprod environment
```bash
./src/common/vendor/bin/dep import:preprod -f deploy-seeding.php role=import
```

### `make seed_import` Task
The developer run this command to update his local environment

```bash
./src/common/vendor/bin/dep import -f deploy-seeding.php role=import
```

## Available Tasks

### `export` Task
The `export` task is used to export the database and shared files from the QA environment to the PREPROD environment.

#### Command
```bash
dep export
```

#### Steps
1. Creates an SQL export on the QA environment (`export:db`).
2. Copies the SQL export to the PREPROD environment (`export:db:copy`).
3. Syncs the shared directory from QA to PREPROD (`export:shared:rsync`).

### `import:preprod` Task
The `import:preprod` task is used to import the database into the PREPROD environment.

#### Command
```bash
dep import:preprod
```

#### Steps
1. Imports the SQL export on PREPROD (`import:db:preprod`).
2. Performs the necessary migrations (`deploy:migrate:media-manager`, `deploy:migrate:licence`).
3. Anonymizes licenses on PREPROD (`import:db:anonymize-preprod`).
4. Updates site URLs from QA to PREPROD (`import:db:url:update-sites-preprod`).

### `import` Task
The `import` task is used to import the database and shared files from the PREPROD environment to the LOCAL environment.

#### Command
```bash
dep import
```

#### Steps
1. Copies the SQL export from PREPROD to LOCAL (`import:db:copy`).
2. Imports the SQL export on LOCAL (`import:db:local`).
3. Performs the necessary migrations (`deploy:migrate:media-manager`, `deploy:migrate:licence`).
4. Anonymizes licenses on LOCAL (`import:db:anonymize-local`).
5. Syncs the shared directory from PREPROD to LOCAL (`import:shared:rsync`).
6. Updates site URLs from QA to LOCAL (`import:db:url:update-sites-local`).

## Other Tasks

### `export:db`
Creates an SQL export on QA.
```bash
dep export:db
```

### `export:db:copy`
Copies the SQL export from QA to PREPROD.
```bash
dep export:db:copy
```

### `export:shared:rsync`
Syncs the shared directory from QA to PREPROD.
```bash
dep export:shared:rsync
```

### `import:db:preprod`
Imports the SQL export on PREPROD.
```bash
dep import:db:preprod
```

### `import:db:anonymize-preprod`
Anonymizes licenses on PREPROD.
```bash
dep import:db:anonymize-preprod
```

### `import:db:copy`
Copies the SQL export from PREPROD to LOCAL.
```bash
dep import:db:copy
```

### `import:db:local`
Imports the SQL export on LOCAL.
```bash
dep import:db:local
```

### `import:db:anonymize-local`
Anonymizes licenses on LOCAL.
```bash
dep import:db:anonymize-local
```

### `import:shared:rsync`
Syncs the shared directory from PREPROD to LOCAL.
```bash
dep import:shared:rsync
```

### `import:db:url:update-sites-local`
Updates site URLs from QA to LOCAL.
```bash
dep import:db:url:update-sites-local
```

### `import:db:url:update-sites-preprod`
Updates site URLs from QA to PREPROD.
```bash
dep import:db:url:update-sites-preprod
```

### `deploy:migrate:media-manager`
Performs necessary migrations for MediaManager.
```bash
dep deploy:migrate:media-manager
```

### `deploy:migrate:licence`
Performs necessary migrations for licenses.
```bash
dep deploy:migrate:licence
```

