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.
- 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.
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
Top comments (0)