26 lines
907 B
PHP
26 lines
907 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class AddTestsTable extends AbstractMigration {
|
|
|
|
public function change(): void {
|
|
$table = $this->table('tests');
|
|
$table->addColumn('title', 'string', ['null' => false])
|
|
->addColumn('description', 'string')
|
|
->addColumn('component_id', 'integer', ['null' => false])
|
|
->addForeignKey('component_id', 'components', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
|
->addTimestamps()
|
|
->create();
|
|
|
|
$table = $this->table('test_benchmark');
|
|
$table->addColumn('test_id', 'integer', ['null' => false])
|
|
->addColumn('benchmark_id', 'integer', ['null' => false])
|
|
->addForeignKey('test_id', 'tests', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
|
->addForeignKey('benchmark_id', 'benchmarks', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
|
|
->create();
|
|
}
|
|
|
|
}
|