feat: M2 database migration runner with Phinx and initial schema
This commit is contained in:
1 parent
d3e8cf8fae
commit
93d991703c
20 files changed
+2000
-14
No files matched your search
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Schema: uploaded thumbnails.
|
||||
*
|
||||
* Thumbnails are user-uploaded images associated with models.
|
||||
* They are stored in the managed library under a thumbnails/ subdirectory
|
||||
* and tracked separately from model files.
|
||||
*/
|
||||
final class CreateThumbnails extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('thumbnails', ['id' => 'id', 'primary_key' => 'id'])
|
||||
->addColumn('model_id', 'integer', ['null' => false, 'signed' => false])
|
||||
->addColumn('managed_path', 'text', ['null' => false])
|
||||
->addColumn('hash', 'string', ['limit' => 64, 'null' => false]) // SHA-256 hex
|
||||
->addColumn('size', 'biginteger', ['null' => false, 'signed' => false])
|
||||
->addColumn('mime_type', 'string', ['limit' => 128, 'null' => false])
|
||||
->addColumn('width', 'integer', ['null' => true, 'signed' => false])
|
||||
->addColumn('height', 'integer', ['null' => true, 'signed' => false])
|
||||
->addColumn('uploaded_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'timezone' => true])
|
||||
->addForeignKey('model_id', 'models', 'id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION'])
|
||||
->addIndex(['model_id'], ['name' => 'idx_thumbnails_model_id'])
|
||||
->addIndex(['hash'], ['unique' => true, 'name' => 'idx_thumbnails_hash'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user