85 lines
2.4 KiB
PHP
85 lines
2.4 KiB
PHP
<?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'] . "')"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|