DEV Community

Cover image for Getting Started on Elixir and Ecto Part 2
Kenzy Limon
Kenzy Limon

Posted on

Getting Started on Elixir and Ecto Part 2

Database Setup and Connection

  • NOTE: config/config.exs credentials should be correct to be able to make a successful database connection.
Run this command : mix ecto.create
Expected response : The database for Taskers.Repo has been created.
Enter fullscreen mode Exit fullscreen mode
  • Generate a migration file for our task table, this is a single step in the process of constructing your database.
Run this command : mix ecto.gen.migration create_tasks

This command will create a migration file in priv/repo/migrations.
Enter fullscreen mode Exit fullscreen mode

When defining the schema, Data Types need to be clearly stated. Types are split into two categories, Primitive types, and Custom types. We will cover the primitive type since its the most used one, in the next section.

NOTE: The naming convention for tables in Ecto databases is to use a pluralized name.

To create tasks table in our database
Run this command : mix ecto.migrate

To undo the changes in the migration incase of misstakes
Run this command : mix ecto.rollback
Enter fullscreen mode Exit fullscreen mode

Top comments (0)