Week 4 (June 18 – June 25, 2017)

One more week passed and we reached more close to our first evaluation (June 26, 2017 – June 30, 2017). This post is in continuation to my previous posts and here I will let you know my work progress in this week and some instructions to avoid issues which I faced.

Work :

As mentioned earlier, my initial task is to refactor the database and so, I need to create migrations for all the tables (dropping necessary tables which are not in use, and columns) .  In the last post I mentioned that I had completely refactored the patient and users table, and working on the forms. Now all forms are complete and they have their respective migration file, with some additions and removal of columns from the existing structure. Each form table is related with patient, encounter and users table. Also it is necessary to have your work documented, so added documentation for it along with directory structure.

My next target is to complete the table structure soon and move towards API part.

General Instructions :

Whenever we create something, we face some issues and overcome them, and same is the case here. Few points to remember here is :

  • Laravel assumes database to be created in your respective database-server (here it is MySql) and then creates connection to it. So if you want to have artisan command  to create your database, then you need to create one. To create command :
  1. Make command using artisan. (php artisan make:command <command_name>)
  2. A <command_name>.php file is created in App\Console\Commands directory.
  3. Include command signature and business logic for that command. (You can also include arguments.)
  4. Register your command in Kernel.php located in App\Console directory, inside $commands.

For more information about creating commands follow the official docs. To see the code look at this link.

  • It is very necessary to have the migration created in order i.e, create the base table first and then its corresponding related tables. If we fail to do so, then we can have troubles while creating relationships. It is so because each migration file is prefixed with its time stamp, and they are created in same order when we execute php artisan migrate  command. One work around is to manually change the time stamp of migration file, but this is not recommended as it defeats the purpose of using migrations.

This is all for now. I will update more about my work in my next post.

 

Leave a comment