# Manually Run A Migration From Rails Console

A migration can be manually run from the rails console. In 99% of cases you are going to be better off using the migration CLI that Rails provides (e.g. `rails db:migrate`, `rails db:rollback`, etc.).

If you are in a hyper-specific scenario where you need to run the `up` or the `down` of a migration without the migration-table check, then you'll want to consider this approach.

First, connect to the rails console: `rails c`. Then require your migration file.

```ruby
> require "./db/migration/20200220181733_some_migration.rb"
#=> true
```

You'll now have access to the `SomeMigration` constant. Create an instance of this and then run either the `up`-side of the migration:

```ruby
> SomeMigration.new.up
#=> ... # a bunch of migration output
```

or the `down`-side of it:

```ruby
> SomeMigration.new.down
#=> ... # a bunch of migration output
```

[source](https://stackoverflow.com/a/754316/535590)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/programmy/rails/manually-run-a-migration-from-rails-console.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
