31 lines
1.3 KiB
PHP
31 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
/**
|
|
* Schema: models as logical catalog items.
|
|
*
|
|
* Each model belongs to a folder and represents a logical 3D model consisting
|
|
* of one or more files (STL parts, images, documents). Models have metadata
|
|
* including categories, tags, notes, and optional source URL.
|
|
*/
|
|
final class CreateModels extends AbstractMigration
|
|
{
|
|
public function change(): void
|
|
{
|
|
$this->table('models', ['id' => 'id', 'primary_key' => 'id'])
|
|
->addColumn('folder_id', 'integer', ['null' => false, 'signed' => false])
|
|
->addColumn('name', 'string', ['limit' => 255])
|
|
->addColumn('notes', 'text', ['null' => true])
|
|
->addColumn('source_url', 'string', ['limit' => 2048, 'null' => true])
|
|
->addColumn('added_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'timezone' => true])
|
|
->addColumn('updated_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'timezone' => true])
|
|
->addForeignKey('folder_id', 'folders', 'id', ['delete' => 'RESTRICT', 'update' => 'NO_ACTION'])
|
|
->addIndex(['folder_id', 'name'], ['unique' => true, 'name' => 'idx_models_folder_name'])
|
|
->addIndex(['added_at'], ['name' => 'idx_models_added_at'])
|
|
->create();
|
|
}
|
|
}
|