From 5387802dc8dcc8a9acbd40551188db4dc8bec4d7 Mon Sep 17 00:00:00 2001 From: ken Date: Tue, 6 Nov 2018 11:02:31 +0300 Subject: [PATCH] migrations table clean up --- app/ImplementingPartner.php | 7 ++ .../2014_10_12_000000_create_users_table.php | 14 ++++ .../2016_09_01_130828_pt_setup_tables.php | 31 ++++++- ...16_11_21_114226_create_bulk_sms_tables.php | 1 + .../2017_06_21_064353_update_users_table.php | 40 --------- ..._143645_enrolments_table_status_column.php | 37 --------- ...2017_09_06_105832_date_user_registered.php | 37 --------- ...017_09_14_105907_participant_rejection.php | 39 --------- ...3_08_125705_update_name_on_users_table.php | 37 --------- ...59_create_implementing_partners_tables.php | 7 +- .../2018_03_26_160605_update_pt_table.php | 35 -------- database/seeds/DatabaseSeeder.php | 3 +- database/seeds/PTSeeder.php | 83 +++++++++++++++++-- 13 files changed, 133 insertions(+), 238 deletions(-) delete mode 100644 database/migrations/2017_06_21_064353_update_users_table.php delete mode 100644 database/migrations/2017_08_24_143645_enrolments_table_status_column.php delete mode 100644 database/migrations/2017_09_06_105832_date_user_registered.php delete mode 100644 database/migrations/2017_09_14_105907_participant_rejection.php delete mode 100644 database/migrations/2018_03_08_125705_update_name_on_users_table.php delete mode 100644 database/migrations/2018_03_26_160605_update_pt_table.php diff --git a/app/ImplementingPartner.php b/app/ImplementingPartner.php index 22a46d54..8d820fcc 100644 --- a/app/ImplementingPartner.php +++ b/app/ImplementingPartner.php @@ -11,6 +11,13 @@ class ImplementingPartner extends Model use SoftDeletes; protected $dates = ['deleted_at']; + /** + * The database table used by the model. + * + * @var string + */ + protected $table = 'implementing_partners'; + public function agency() { return $this->belongsTo('App\Agency'); diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index c50caf04..9fd0e210 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -15,6 +15,9 @@ public function up() Schema::create('users', function (Blueprint $table) { $table->increments('id')->unsigned(); $table->string('name'); + $table->string('last_name', 100)->nullable(); + $table->string('middle_name', 100)->nullable();// not mandatory + $table->string('first_name', 100)->nullable(); $table->tinyInteger("gender")->default(0); $table->string('email')->nullable(); $table->string('phone')->nullable(); @@ -23,6 +26,17 @@ public function up() $table->string('password', 60); $table->string("image", 100)->nullable(); $table->integer('uid')->nullable(); + $table->string('sms_code')->nullable(); + $table->boolean('phone_verified')->default(false); + $table->string('email_verification_code')->nullable(); + $table->boolean('email_verified')->default(false); + // $table->string("remember_token", 100)->nullable(); + $table->date('date_registered')->nullable(); + $table->tinyInteger('status')->nullable(); + $table->string('reason', 25)->nullable(); + $table->date('status_date')->nullable(); + $table->integer('implementing_partner_id')->unsigned(); + $table->rememberToken(); $table->softDeletes(); diff --git a/database/migrations/2016_09_01_130828_pt_setup_tables.php b/database/migrations/2016_09_01_130828_pt_setup_tables.php index 8a9c9e31..d1384773 100644 --- a/database/migrations/2016_09_01_130828_pt_setup_tables.php +++ b/database/migrations/2016_09_01_130828_pt_setup_tables.php @@ -44,6 +44,7 @@ public function up() $table->string('name'); $table->string('description', 100)->nullable(); $table->date('start_date'); + $table->date('enrollment_date'); $table->date('end_date'); $table->integer('user_id')->unsigned(); $table->foreign('user_id')->references('id')->on('users'); @@ -122,7 +123,7 @@ public function up() $table->increments('id')->unsigned(); $table->integer('user_id')->unsigned(); $table->integer('round_id')->unsigned(); - // $table->tinyInteger('status')->default(0); + $table->tinyInteger('status')->default(0); $table->softDeletes(); $table->timestamps(); @@ -149,6 +150,10 @@ public function up() $table->tinyInteger('incomplete_results')->default(0); $table->string('comment', 250)->nullable(); $table->integer('verified_by')->nullable(); + $table->integer('approved_by')->nullable(); + $table->string('approved_comment', 250)->nullable(); + $table->integer('download_status')->nullable(); + $table->date('date_approved'); $table->foreign('enrolment_id')->references('id')->on('enrolments'); $table->softDeletes(); $table->timestamps(); @@ -167,6 +172,26 @@ public function up() $table->softDeletes(); $table->timestamps(); }); + + //Evaluated results used in audit trail + Schema::create('evaluated_results', function(Blueprint $table) + { + $table->increments('id')->unsigned(); + $table->integer('pt_id')->unsigned(); + $table->integer('participant_id')->unsigned(); + $table->string('reason_for_change'); + $table->string('results'); + $table->integer('user_id')->unsigned(); + $table->softDeletes(); + $table->timestamps(); + + }); + + Schema::create('tmp_resultset', function(Blueprint $table) + { + $table->integer('pt_id')->unsigned(); + $table->text('answers'); + }); } /** @@ -186,6 +211,8 @@ public function down() Schema::dropIfExists('lots'); Schema::dropIfExists('rounds'); Schema::dropIfExists('materials'); - Schema::dropIfExists('programs'); + Schema::dropIfExists('programs'); + Schema::dropIfExists('evaluated_results'); + Schema::dropIfExists('tmp_resultset'); } } \ No newline at end of file diff --git a/database/migrations/2016_11_21_114226_create_bulk_sms_tables.php b/database/migrations/2016_11_21_114226_create_bulk_sms_tables.php index d8b35883..51de5d19 100644 --- a/database/migrations/2016_11_21_114226_create_bulk_sms_tables.php +++ b/database/migrations/2016_11_21_114226_create_bulk_sms_tables.php @@ -28,6 +28,7 @@ public function up() $table->increments('id')->unsigned(); $table->tinyInteger('template'); $table->string('message'); + $table->string('description'); $table->softDeletes(); $table->timestamps(); }); diff --git a/database/migrations/2017_06_21_064353_update_users_table.php b/database/migrations/2017_06_21_064353_update_users_table.php deleted file mode 100644 index 8756ba02..00000000 --- a/database/migrations/2017_06_21_064353_update_users_table.php +++ /dev/null @@ -1,40 +0,0 @@ -string('sms_code')->nullable()->after('uid'); - $table->boolean('phone_verified')->default(false)->after('sms_code'); - $table->string('email_verification_code')->nullable()->after('phone_verified'); - $table->boolean('email_verified')->default(false)->after('email_verification_code'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // drop columns - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('email_verified'); - $table->dropColumn('email_verification_code'); - $table->dropColumn('phone_verified'); - $table->dropColumn('sms_code'); - }); - } -} diff --git a/database/migrations/2017_08_24_143645_enrolments_table_status_column.php b/database/migrations/2017_08_24_143645_enrolments_table_status_column.php deleted file mode 100644 index 5e8e56fe..00000000 --- a/database/migrations/2017_08_24_143645_enrolments_table_status_column.php +++ /dev/null @@ -1,37 +0,0 @@ -tinyInteger('status')->default(0)->after('round_id'); - }); - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // drop columns - Schema::table('enrolments', function (Blueprint $table) { - $table->dropColumn('status'); - - }); - } -} diff --git a/database/migrations/2017_09_06_105832_date_user_registered.php b/database/migrations/2017_09_06_105832_date_user_registered.php deleted file mode 100644 index 742163fe..00000000 --- a/database/migrations/2017_09_06_105832_date_user_registered.php +++ /dev/null @@ -1,37 +0,0 @@ -date('date_registered')->nullable()->after('updated_at'); - }); - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // drop columns - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('date_registered'); - - }); - } -} diff --git a/database/migrations/2017_09_14_105907_participant_rejection.php b/database/migrations/2017_09_14_105907_participant_rejection.php deleted file mode 100644 index 9fc09d24..00000000 --- a/database/migrations/2017_09_14_105907_participant_rejection.php +++ /dev/null @@ -1,39 +0,0 @@ -tinyInteger('status')->nullable()->after('date_registered'); - $table->string('reason', 25)->nullable()->after('status'); - $table->date('status_date')->nullable()->after('reason'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // drop columns - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('status'); - $table->dropColumn('reason'); - $table->dropColumn('status_date'); - }); - } -} diff --git a/database/migrations/2018_03_08_125705_update_name_on_users_table.php b/database/migrations/2018_03_08_125705_update_name_on_users_table.php deleted file mode 100644 index 0eeb0f09..00000000 --- a/database/migrations/2018_03_08_125705_update_name_on_users_table.php +++ /dev/null @@ -1,37 +0,0 @@ -string('last_name', 100)->nullable()->after('name'); - $table->string('middle_name', 100)->nullable()->after('name');// not mandatory - $table->string('first_name', 100)->nullable()->after('name'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('first_name'); - $table->dropColumn('middle_name'); - $table->dropColumn('last_name'); - }); - } -} diff --git a/database/migrations/2018_03_19_071459_create_implementing_partners_tables.php b/database/migrations/2018_03_19_071459_create_implementing_partners_tables.php index f0fcbd9a..4f145b22 100644 --- a/database/migrations/2018_03_19_071459_create_implementing_partners_tables.php +++ b/database/migrations/2018_03_19_071459_create_implementing_partners_tables.php @@ -33,7 +33,7 @@ public function up() $table->integer('county_id')->unsigned(); }); - Schema::table('users', function (Blueprint $table) { + /* Schema::table('users', function (Blueprint $table) { $table->integer('implementing_partner_id')->unsigned()->nullable(); }); @@ -42,7 +42,7 @@ public function up() echo "agencies seeded!\n"; \DB::unprepared(file_get_contents(base_path() . "/database/seeds/implementing_partners.sql")); echo "implementing partners seeded!\n"; - \DB::enableQueryLog(); + \DB::enableQueryLog();*/ } /** @@ -52,8 +52,7 @@ public function up() */ public function down() { - Schema::drop('implementing_partner_user'); - Schema::drop('implementing_partner_county'); + Schema::drop('county_implementing_partner'); Schema::drop('implementing_partners'); Schema::drop('agencies'); } diff --git a/database/migrations/2018_03_26_160605_update_pt_table.php b/database/migrations/2018_03_26_160605_update_pt_table.php deleted file mode 100644 index e6c4ad51..00000000 --- a/database/migrations/2018_03_26_160605_update_pt_table.php +++ /dev/null @@ -1,35 +0,0 @@ -integer('approved_by')->nullable()->after('verified_by'); - $table->string('approved_comment', 250)->nullable()->after('verified_by'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('pt', function (Blueprint $table) { - $table->dropColumn('approved_by'); - $table->dropColumn('approved_comment'); - }); - } -} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 27004ff4..82fad1bf 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -15,7 +15,8 @@ public function run() Model::unguard(); $this->call(PTSeeder::class); - + $this->call(DesignationSeeder::class); + Model::reguard(); } } \ No newline at end of file diff --git a/database/seeds/PTSeeder.php b/database/seeds/PTSeeder.php index 6be68826..739d4431 100644 --- a/database/seeds/PTSeeder.php +++ b/database/seeds/PTSeeder.php @@ -14,7 +14,8 @@ use App\Notification; use App\Questionnaire; use App\Nonperformance; - +use App\ImplementingPartner; +use App\Agency; // Carbon - for use with dates use Jenssegers\Date\Date as Carbon; @@ -154,7 +155,13 @@ public function run() array("name" => "export-report", "display_name" => "Can export report"), array("name" => "print-results", "display_name" => "Can print result"), array("name" => "view-evaluated-results", "display_name" => " Can view evaluated results"), - array("name" => "upload-participants", "display_name" => "Can upload participants worksheet") + array("name" => "upload-participants", "display_name" => "Can upload participants worksheet"), + array("name" => "reports-catalog", "display_name" => "Can view reports"), + array("name" => "read-general-report", "display_name" => "Can view general report"), + array("name" => "read-participant-registration-counts-report", "display_name" => "Can view participant registration count report"), + array("name" => "import-results", "display_name" => "Can import PT results from CSV file.") + + ); foreach ($permissions as $permission) { Permission::create($permission); @@ -261,10 +268,14 @@ public function run() /* Notifications table */ $notifications = array( - array("template" => Notification::ENROLMENT, "message" => "Dear PT Participant, you have been enrolled into [round] of PT. If you are not participating, contact your County or Sub-County Coordinator"), - array("template" => Notification::PANEL_DISPATCH, "message" => "Dear PT Participant, NPHL has dispatched your PT Panel for [round]. If not received within 7 days, contact your County or Sub-County Coordinator"), - array("template" => Notification::RESULTS_RECEIVED, "message" => "Dear PT Participant, NPHL has received your PT Results for [round]. You will get your feedback shortly."), - array("template" => Notification::FEEDBACK_RELEASE, "message" => "Dear PT Participant, NPHL has released your PT Feedback for [round]. If not received within 7 days, contact your County or Sub-County Coordinator"), + array("template" => Notification::ENROLMENT, "message" => "Dear PT Participant, you have been enrolled into [round] of PT. If you are not participating, contact your County or Sub-County Coordinator", "description" => "Enrollment Message"), + array("template" => Notification::PANEL_DISPATCH, "message" => "Dear PT Participant, NPHL has dispatched your PT Panel for [round]. If not received within 7 days, contact your County or Sub-County Coordinator", "description" => "Panels Dispatch"), + array("template" => Notification::RESULTS_RECEIVED, "message" => "Dear PT Participant, NPHL has received your PT Results for [round]. You will get your feedback shortly.", "description" => "Results Submitted"), + array("template" => Notification::FEEDBACK_RELEASE, "message" => "Dear PT Participant, NPHL has released your PT Feedback for [round]. If not received within 7 days, contact your County or Sub-County Coordinator", "description" => " Results Feedback"), + array("template" => Notification::ACTIVATION_CODE, "message" => "Your Verification Code is:", "description" => " Phone Verification Code"), + array("template" => Notification::USER_ENABLED, "message" => "Dear [user->name], your Sub-county Coordinator has approved your request to participate in PT. Your tester ID is {user->tester id}. Use the link sent to your email to get started.", "description" => " Enabled Account"), + array("template" => Notification::USER_REGISTRATION, "message" => "Dear [user->name], your PT system account has been created. Use the link sent to your email address to get started.", "description" => "Account Created"), + array("template" => Notification::ROUND_CREATION, "message" => "Dear County/Sub County Coordinator, NPHL has created Round [round->name]. You have until {round->enrollment_date} to enroll participants into this round.", "description" => "Round Created"), ); foreach ($notifications as $notification) { @@ -327,5 +338,65 @@ public function run() Nonperformance::create($reason); } $this->command->info('Non-performance table seeded'); + + /*Implementing partners table*/ + $partners = array( + array("name" => "AMREF Africa", "agency_id" => "1" ), + array("name" => "EDARP", "agency_id" => "1" ), + array("name" => "EGPAF", "agency_id" => "1" ), + array("name" => "FHI 360", "agency_id" => "1" ), + array("name" => "Global Implentation Solutions (GIS)", "agency_id" => "1" ), + array("name" => "UMB - Boresha Maabara", "agency_id" => "1" ), + array("name" => "AMREF Nairobi Kitui", "agency_id" => "1" ), + array("name" => "Bomu Hospital Affiliated Sites", "agency_id" => "1" ), + array("name" => "CHAK CHAP Uzima", "agency_id" => "1" ), + array("name" => "CHS Naishi", "agency_id" => "1" ), + array("name" => "CHS Shinda", "agency_id" => "1" ), + array("name" => "CHS Tegemeza Plus", "agency_id" => "1" ), + array("name" => "Columbia STARS", "agency_id" => "1" ), + array("name" => "Coptic Hospitals", "agency_id" => "1" ), + array("name" => "EGPAF Timiza", "agency_id" => "1" ), + array("name" => "HWWK Nairobi Eastern", "agency_id" => "1" ), + array("name" => "IRDO Tuungane 3", "agency_id" => "1" ), + array("name" => "KCCB KARP", "agency_id" => "1" ), + array("name" => "Kenya Disciplined Services ZUIA", "agency_id" => "1" ), + array("name" => "Kenya Prison Services", "agency_id" => "1" ), + array("name" => "LVCT Daraja", "agency_id" => "1" ), + array("name" => "LVCT Steps", "agency_id" => "1" ), + array("name" => "Ngima for Sure", "agency_id" => "1" ), + array("name" => "UCSF Clinical Kisumu", "agency_id" => "1" ), + array("name" => "UMB PACT Kamili", "agency_id" => "1" ), + array("name" => "UMB Timiza", "agency_id" => "1" ), + array("name" => "UON COE Niche", "agency_id" => "1" ), + array("name" => "UON CRISSP Plus", "agency_id" => "1" ), + array("name" => "Kisumu West (Placeholder)", "agency_id" => "2" ), + array("name" => "South Rift Valley (Placeholder)", "agency_id" => "2" ), + array("name" => "APHIAPlus Rift Valley", "agency_id" => "3" ), + array("name" => "AMPATHplus", "agency_id" => "3" ), + array("name" => "APHIAPlus Pwani", "agency_id" => "3" ), + array("name" => "APHIAPlus Rift Valley", "agency_id" => "3" ), + array("name" => "APHIAplus Central/Eastern", "agency_id" => "3" ), + array("name" => "APHIAplus Imarisha", "agency_id" => "3" ), + array("name" => "APHIAplus Nyanza/Western", "agency_id" => "3" ), + array("name" => "Afya Jijini", "agency_id" => "3" ), + array("name" => "Integrated Program for both HIV infected and affected children and their households", "agency_id" => "3" ) + ); + + foreach ($partners as $partner) { + + ImplementingPartner::create($partner); + } + $this->command->info('Implementing_partners table seeded'); + /*Agencies table*/ + $agencies = array( + array("name" => "CDC"), + array("name" => "DOD"), + array("name" => "USAID") + ); + foreach ($agencies as $agency) + { + Agency::create($agency); + } + $this->command->info('Agencies table seeded'); } }