recreate project
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AllowCompetitionWinnerRankTies extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
if (!$db->tableExists('competition_winners')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($db->indexExists('competition_winners', 'competition_id_class_section_id_rank')) {
|
||||
$db->query('DROP INDEX competition_id_class_section_id_rank ON competition_winners');
|
||||
}
|
||||
|
||||
if (!$db->indexExists('competition_winners', 'competition_id_class_section_id_rank')) {
|
||||
$db->query(
|
||||
'CREATE INDEX competition_id_class_section_id_rank ON competition_winners (competition_id, class_section_id, rank)'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
if (!$db->tableExists('competition_winners')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($db->indexExists('competition_winners', 'competition_id_class_section_id_rank')) {
|
||||
$db->query('DROP INDEX competition_id_class_section_id_rank ON competition_winners');
|
||||
}
|
||||
|
||||
$db->query(
|
||||
'ALTER TABLE competition_winners ADD UNIQUE KEY competition_id_class_section_id_rank (competition_id, class_section_id, rank)'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user