Started work to re-work database; add new models for benchmarks and components
This commit is contained in:
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddResultsTable extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* 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('results');
|
||||
$table->addColumn('component', 'string', ['null' => false])
|
||||
->addColumn('benchmark', 'string', ['null' => false])
|
||||
->addColumn('type', 'string', ['null' => false, 'default' => 'fps'])
|
||||
->addColumn('average', 'integer', ['null' => false])
|
||||
->addColumn('minimum', 'integer')
|
||||
->addColumn('maximum', 'integer')
|
||||
->addTimestamps()
|
||||
->addIndex(['component', 'benchmark', 'type'])
|
||||
->create();
|
||||
}
|
||||
}
|
35
db/migrations/20230921024609_add_initial_tables.php
Normal file
35
db/migrations/20230921024609_add_initial_tables.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddInitialTables extends AbstractMigration {
|
||||
|
||||
public function change(): void {
|
||||
// hardware components
|
||||
$components_table = $this->table('components');
|
||||
$components_table->addColumn('name', 'string', ['null' => false])
|
||||
->addColumn('type', 'string', ['null' => false])
|
||||
->addTimestamps()
|
||||
->addIndex(['name', 'type'])
|
||||
->create();
|
||||
|
||||
// benchmarks
|
||||
$benchmarks_table = $this->table('benchmarks');
|
||||
$benchmarks_table->addColumn('name', 'string', ['null' => false])
|
||||
->addColumn('description', 'string')
|
||||
->addColumn('scoring', 'string', ['null' => false])
|
||||
->addTimestamps()
|
||||
->addIndex(['name', 'scoring'])
|
||||
->create();
|
||||
|
||||
// benchmark test results
|
||||
$table = $this->table('results');
|
||||
$table->addColumn('average', 'integer', ['null' => false])
|
||||
->addColumn('minimum', 'integer')
|
||||
->addColumn('maximum', 'integer')
|
||||
->addTimestamps()
|
||||
->create();
|
||||
}
|
||||
|
||||
}
|
@ -19,10 +19,12 @@ final class AddTestsTable extends AbstractMigration
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('tests');
|
||||
$table->addColumn('name', 'string', ['null' => false])
|
||||
->addColumn('description', 'text', ['null' => false])
|
||||
$table->addColumn('date_tag', 'string', ['null' => false])
|
||||
->addColumn('benchmark_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'])
|
||||
->addTimestamps()
|
||||
->addIndex(['name'])
|
||||
->create();
|
||||
|
||||
$results = $this->table('results');
|
Reference in New Issue
Block a user