> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Deployments

Deploying applications to Fly can be as simple as running:

```bash theme={null}
fly deploy
```

When the application successfully deploys, you can quickly open it in the browser by running:

```bash theme={null}
fly apps open
```

If all goes well, you should see a running application in your web browser. You can also view a history of deployments by running:

<CodeGroup>
  ```bash cmd theme={null}
  fly releases
  ```

  ```output output theme={null}
  VERSION STABLE  TYPE  STATUS    DESCRIPTION                             USER                  DATE
  v55     true    scale succeeded Scale VM count: ["web, 6"]              brad@fly.io           2022-08-10T17:05:57Z
  v54     true    scale dead      Scale VM count: ["web, 0"]              brad@fly.io           2022-08-10T16:43:13Z
  v53     true    scale succeeded Scale VM count: ["web, 6"]              brad@fly.io           2022-08-10T16:42:51Z
  v52     true    scale succeeded Scale VM count: ["web, 6"]              brad@fly.io           2022-08-10T16:40:57Z
  v51     true    scale succeeded Scale VM count: ["web, 3"]              kurt@fly.io           2022-08-08T20:14:08Z
  v50     true    scale succeeded Scale VM count: ["web, 3"]              kurt@fly.io           2022-08-08T19:55:23Z
  ```
</CodeGroup>

## Troubleshooting a deployment

If a deployment fails, you'll see an error message in the console. If the error is a Rails stack trace, it will be truncated. To view the entire error message run:

```bash theme={null}
fly logs
```

You may need to open another terminal window and deploy again while running `fly logs` to see the full error message.

## Running migrations

For Postgresql, migrations are configured to automatically run after each
deployment via the following task in your application's `fly.toml`:

```toml theme={null}
[deploy]
  release_command = './bin/rails db:prepare'
```

Sqlite3 migrations are done by the `bin/docker-entrypoint` script.

To disable automatic migrations for deploys, remove `db:prepare` lines from these files. Then, to manually run migrations after a deployment, run:

```bash theme={null}
fly ssh console -C "/rails/bin/rails db:migrate"
```

## Run ad-hoc tasks after deploying

Sometimes after a deployment you'll need to run a script or migration in production. That can be accomplished with the Fly SSH console by running:

<CodeGroup>
  ```bash cmd theme={null}
  fly ssh console
  ```

  ```output output theme={null}
  Connecting to top1.nearest.of.my-rails-app.internal... complete
  ```
</CodeGroup>

<CodeGroup>
  ```bash cmd theme={null}
  ls
  ```

  ```output output theme={null}
  Dockerfile      README.md       config          lib             test
  Gemfile         Rakefile        config.ru       log             tmp
  Gemfile.lock    app             db              public          vendor
  Procfile.dev    bin             fly.toml        storage
  ```
</CodeGroup>

<CodeGroup>
  ```bash cmd theme={null}
  bundle exec ruby my-hello-world-script.rb
  ```

  ```output output theme={null}
  hello world
  ```
</CodeGroup>
