Creating a tableΒΆ

To add/create a new table in the database, the following options are available:

First launch the API console:

$ hasura api-console

This will open the API console. Head to Data > Schema.

../../../_images/create-table.png

You can create tables using SQL by heading to Data > SQL section in the API console.

../../../_images/run_sql.png

Note

You should click on This is a migration option before executing the query if you want to retain the query as a database migration.

POST data.<cluster-name>.hasura-app.io/v1/query HTTP/1.1
Authorization: Bearer <auth-token> # optional if cookie is set
X-Hasura-Role: admin
Content-Type: application/json

{
    "type" : "run_sql",
    "args" : {
        "sql" : "CREATE TABLE article (
                     id SERIAL NOT NULL PRIMARY KEY,
                     title TEXT NOT NULL,
                     description TEXT
                 );"
    }
}