# Part 4 - Migrations

## Getting Started

Now that we have our authentication setup and we are comfortable with migrating our migrations, let's create a new migration where we will store our posts.

Our posts table should have a few obvious columns that we will simplify for this tutorial part. Let's walk through how we create migrations with Masonite

## Craft Command

Not surprisingly, we have a craft command to create migrations. You can read more about [Database Migrations here](/1.6/orator-orm/database-migrations.md) but we'll simplify it down to the command and explain a little bit of what's going on:

{% code title="terminal" %}

```
$ craft migration create_posts_table --create posts
```

{% endcode %}

This command simply creates the basis of a migration that will create the posts table. By convention, table names should be plural (and model names should be singular but more on this later).

This will create a migration in the `databases/migrations` folder. Let's open that up and starting on line 6 we should see look like:

{% code title="databases/migrations/2018\_01\_09\_043202\_create\_posts\_table.py" %}

```python
def up(self):
    """
    Run the migrations.
    """
    with self.schema.create('posts') as table:
        table.increments('id')
        table.timestamps()
```

{% endcode %}

Lets add a title, an author, and a body to our posts tables.

{% code title="databases/migrations/2018\_01\_09\_043202\_create\_posts\_table.py" %}

```python
def up(self):
    """
    Run the migrations.
    """
    with self.schema.create('posts') as table:
        table.increments('id')
        table.string('title')

        table.integer('author_id').unsigned()
        table.foreign('author_id').references('id').on('users')

        table.string('body')
        table.timestamps()
```

{% endcode %}

{% hint style="success" %}
This should be fairly straight forward but if you want to learn more, be sure to read the [Database Migrations](/1.6/orator-orm/database-migrations.md) documentation.
{% endhint %}

Now we can migrate this migration to create the posts table

{% code title="terminal" %}

```
$ craft migrate
```

{% endcode %}


---

# 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://docs.masoniteproject.com/1.6/creating-your-first-blog/part-4-migrations.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.
