colossus/db/migrations/20230923020649_add_tests_table.php
2024-06-03 09:43:33 -04:00

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();
}
}