# Deployment

## Staging

- URL: `https://staging.simple.edu.vn`
- Project root: `/home/webdemoo/staging.simple.edu.vn`
- Web root: `/home/webdemoo/staging.simple.edu.vn/public_html`
- FTP account root: `/home/webdemoo/staging.simple.edu.vn`

Copy `.vscode/sftp.example.json` to `.vscode/sftp.json` and
`sftp-config.example.json` to `sftp-config.json`, then add the local password.
Both real files are ignored because they contain credentials.

`npm run deploy:files -- <relative-file>` uploads selected files only. Database
migrations are never applied automatically by file upload; follow
`database/RELEASE_WORKFLOW.md`.

## Isolate uploads for an existing tenant

Deploy the upload-isolation code while `uploads_isolated` remains disabled.
On the server, preview the legacy file copy:

```bash
php bin/tenant-migrate-uploads.php --host=staging.simple.edu.vn
```

If the host and file counts are correct, execute the checksum-verified copy:

```bash
php bin/tenant-migrate-uploads.php \
  --host=staging.simple.edu.vn \
  --execute
```

Then set `uploads_isolated` to `true` in
`config/autoload/multitenant.local.php`. Test the logo, avatars, rich-text
images, file upload/download and image replacement. The migration keeps legacy
files for rollback; do not delete them until the release has been stable.

## Production

Production tenants must share one published application source. Each tenant
keeps its own business database, selected through the platform registry. Do not
copy the application into one source directory per tenant.
