feat: M2 database migration runner with Phinx and initial schema

This commit is contained in:
Keith Solomon committed 2026-10-11 18:05:23 -05:00
1 parent d3e8cf8fae
commit 93d991703c
20 files changed
+2000 -14

No files matched your search

@@ -0,0 +1,30 @@
<?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();
}
}