26 lines
909 B
PHP
26 lines
909 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('tests_benchmarks');
|
|
$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();
|
|
}
|
|
|
|
}
|