Organize scattered PHP files into scripts/ and tests/ directories

This commit is contained in:
2025-11-12 08:34:20 +01:00
parent 0622f40004
commit 8f072292c1
28 changed files with 10 additions and 10 deletions

1
scripts/add_col.php Executable file
View File

@@ -0,0 +1 @@
<?php $db = new PDO("sqlite:collections.sqlite"); $db->exec("ALTER TABLE items ADD COLUMN id_code TEXT"); echo "done";

1
scripts/add_col2.php Executable file
View File

@@ -0,0 +1 @@
<?php $db = new PDO("sqlite:collections.sqlite"); $db->exec("ALTER TABLE items ADD COLUMN image TEXT"); echo "done";

1
scripts/add_col3.php Executable file
View File

@@ -0,0 +1 @@
<?php $db = new PDO("sqlite:collections.sqlite"); $db->exec("ALTER TABLE items ADD COLUMN location TEXT"); echo "done";

8
scripts/add_columns.php Executable file
View File

@@ -0,0 +1,8 @@
<?php
require '../vendor/autoload.php';
require '../config.php';
= new PDO('sqlite:' . DB_PATH);
->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try {
->exec('ALTER TABLE items ADD COLUMN id_code TEXT');
echo id_code

7
scripts/check_items.php Executable file
View File

@@ -0,0 +1,7 @@
<?php
require '../vendor/autoload.php';
require '../config.php';
= App\Database\Database::getInstance();
= ->query('SELECT id, name FROM items');
= ->fetchAll(PDO::FETCH_ASSOC);
print_r();

24
scripts/fix_db.php Executable file
View File

@@ -0,0 +1,24 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../config.php';
use App\Database;
use App\Models\Category;
$db = Database::getInstance();
$categories = Category::getAll($db);
foreach ($categories as $cat) {
$path = Category::getFullPath($db, $cat['id']);
if (strpos($path, '[Circular]') !== false) {
echo "Circular reference found for category {$cat['id']}: {$cat['name']}\n";
// Reset parent_id to null
$stmt = $db->prepare('UPDATE categories SET parent_id = NULL WHERE id = :id');
$stmt->execute([':id' => $cat['id']]);
echo "Fixed by setting parent_id to NULL\n";
}
}
echo "Done checking and fixing circular references.\n";

9
scripts/migrate_db.php Executable file
View File

@@ -0,0 +1,9 @@
<?php
require '../vendor/autoload.php';
require '../config.php';
use AppDatabaseDatabase;
$db = App\Database\Database::getInstance();
$db->exec('ALTER TABLE items ADD COLUMN id_code TEXT UNIQUE');
$db->exec('ALTER TABLE items ADD COLUMN image TEXT');
$db->exec('ALTER TABLE items ADD COLUMN location TEXT');
echo 'Columns added to items table.\n';