mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
feat: FilePond production hardening — extension-based validation, server-side size limits (2GB), annexe validation, drop accept attributes, FilePond file styling
This commit is contained in:
29
scripts/ensure-db.php
Normal file
29
scripts/ensure-db.php
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* ensure-db.php — Create database from schema.sql if it doesn't exist.
|
||||
*
|
||||
* Usage: php scripts/ensure-db.php [DB_PATH]
|
||||
* Default: storage/xamxam.db
|
||||
*/
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$dbPath = $argv[1] ?? ($root . '/storage/xamxam.db');
|
||||
$schemaPath = $root . '/storage/schema.sql';
|
||||
|
||||
if (file_exists($dbPath)) {
|
||||
echo "Database already exists: $dbPath\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!file_exists($schemaPath)) {
|
||||
die("Schema not found: $schemaPath\n");
|
||||
}
|
||||
|
||||
$db = new PDO('sqlite:' . $dbPath);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$sql = file_get_contents($schemaPath);
|
||||
$db->exec($sql);
|
||||
|
||||
echo "Database created from schema: $dbPath\n";
|
||||
Reference in New Issue
Block a user