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,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Seed\AbstractSeed;
|
||||
|
||||
/**
|
||||
* Seed script for default reference data.
|
||||
*
|
||||
* Populates initial categories and tags. Safe to re-run (idempotent).
|
||||
*/
|
||||
final class DefaultDataSeed extends AbstractSeed
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// Seed default categories
|
||||
$categories = [
|
||||
[
|
||||
'name' => 'Aircraft',
|
||||
'description' => 'Planes, helicopters, and drones',
|
||||
],
|
||||
[
|
||||
'name' => 'Automotive',
|
||||
'description' => 'Cars, trucks, and vehicles',
|
||||
],
|
||||
[
|
||||
'name' => 'Characters',
|
||||
'description' => 'Humanoid and creature models',
|
||||
],
|
||||
[
|
||||
'name' => 'Props',
|
||||
'description' => 'Objects and accessories',
|
||||
],
|
||||
[
|
||||
'name' => 'Terrain',
|
||||
'description' => 'Landscapes, buildings, and scenery',
|
||||
],
|
||||
[
|
||||
'name' => 'Tools',
|
||||
'description' => 'Functional items and gadgets',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$exists = $this->getAdapter()->fetchRow(
|
||||
"SELECT id FROM categories WHERE name = '"
|
||||
. $category['name'] . "'"
|
||||
);
|
||||
if (!$exists) {
|
||||
$this->getAdapter()->execute(
|
||||
"INSERT INTO categories (name, description) VALUES ('"
|
||||
. $category['name'] . "', '"
|
||||
. $category['description'] . "')"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Seed default tags
|
||||
$tags = [
|
||||
['name' => 'wip'],
|
||||
['name' => 'completed'],
|
||||
['name' => 'high-poly'],
|
||||
['name' => 'low-poly'],
|
||||
['name' => 'print-ready'],
|
||||
['name' => 'needs-supports'],
|
||||
['name' => 'articulated'],
|
||||
['name' => 'modular'],
|
||||
['name' => 'multi-part'],
|
||||
['name' => 'single-piece'],
|
||||
];
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$exists = $this->getAdapter()->fetchRow(
|
||||
"SELECT id FROM tags WHERE name = '" . $tag['name'] . "'"
|
||||
);
|
||||
if (!$exists) {
|
||||
$this->getAdapter()->execute(
|
||||
"INSERT INTO tags (name) VALUES ('" . $tag['name'] . "')"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user