Changed database structure a bit; fixed code style problems in the old migrations
This commit is contained in:
parent
33c9bf5cb5
commit
bd4c79a6fc
@ -22,14 +22,6 @@ final class AddInitialTables extends AbstractMigration {
|
|||||||
->addTimestamps()
|
->addTimestamps()
|
||||||
->addIndex(['name', 'scoring'])
|
->addIndex(['name', 'scoring'])
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
// benchmark test results
|
|
||||||
$table = $this->table('results');
|
|
||||||
$table->addColumn('average', 'integer', ['null' => false])
|
|
||||||
->addColumn('minimum', 'integer')
|
|
||||||
->addColumn('maximum', 'integer')
|
|
||||||
->addTimestamps()
|
|
||||||
->create();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,34 +3,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
use Phinx\Migration\AbstractMigration;
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
final class AddTestsTable extends AbstractMigration
|
final class AddTestsTable extends AbstractMigration {
|
||||||
{
|
|
||||||
/**
|
public function change(): void {
|
||||||
* Change Method.
|
|
||||||
*
|
|
||||||
* Write your reversible migrations using this method.
|
|
||||||
*
|
|
||||||
* More information on writing migrations is available here:
|
|
||||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
|
||||||
*
|
|
||||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
|
||||||
* with the Table class.
|
|
||||||
*/
|
|
||||||
public function change()
|
|
||||||
{
|
|
||||||
$table = $this->table('tests');
|
$table = $this->table('tests');
|
||||||
$table->addColumn('title', 'string', ['null' => false])
|
$table->addColumn('title', 'string', ['null' => false])
|
||||||
->addColumn('description', 'string')
|
->addColumn('description', 'string')
|
||||||
->addColumn('benchmark_id', 'integer', ['null' => false])
|
|
||||||
->addColumn('component_id', 'integer', ['null' => false])
|
->addColumn('component_id', 'integer', ['null' => false])
|
||||||
->addForeignKey('benchmark_id', 'benchmarks', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
|
||||||
->addForeignKey('component_id', 'components', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
->addForeignKey('component_id', 'components', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
||||||
->addTimestamps()
|
->addTimestamps()
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
$results = $this->table('results');
|
|
||||||
$results->addColumn('test_id', 'integer', ['null' => false])
|
|
||||||
->addForeignKey('test_id', 'tests', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
|
||||||
->update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
24
db/migrations/20240603081359_add_results_table.php
Normal file
24
db/migrations/20240603081359_add_results_table.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class AddResultsTable extends AbstractMigration {
|
||||||
|
|
||||||
|
public function change(): void {
|
||||||
|
// benchmark test results
|
||||||
|
$table = $this->table('results');
|
||||||
|
$table->addColumn('average', 'integer', ['null' => false])
|
||||||
|
->addColumn('minimum', 'integer')
|
||||||
|
->addColumn('maximum', 'integer')
|
||||||
|
->addColumn('test_id', 'integer', ['null' => false])
|
||||||
|
->addColumn('component_id', 'integer', ['null' => false])
|
||||||
|
->addColumn('benchmark_id', 'integer', ['null' => false])
|
||||||
|
->addForeignKey('test_id', 'tests', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
||||||
|
->addForeignKey('component_id', 'components', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
||||||
|
->addForeignKey('benchmark_id', 'benchmarks', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
||||||
|
->addTimestamps()
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user