updating installation
This commit is contained in:
parent
6d026cb61f
commit
c6c300fdbb
@ -64,7 +64,7 @@ require_once __DIR__ . '/../includes/functions.php';
|
||||
// 2. Create migrations table if not exists
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS migrations (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
migration VARCHAR(255) UNIQUE NOT NULL,
|
||||
migration_name VARCHAR(255) UNIQUE NOT NULL,
|
||||
applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)");
|
||||
|
||||
@ -74,7 +74,7 @@ require_once __DIR__ . '/../includes/functions.php';
|
||||
sort($migrations);
|
||||
|
||||
// Get applied migrations
|
||||
$stmt = $pdo->query("SELECT migration FROM migrations");
|
||||
$stmt = $pdo->query("SELECT migration_name FROM migrations");
|
||||
$applied = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
foreach ($migrations as $migration_path) {
|
||||
@ -86,7 +86,7 @@ require_once __DIR__ . '/../includes/functions.php';
|
||||
// We will wrap each in a try-catch or just execute and catch specific duplicate column errors
|
||||
try {
|
||||
$pdo->exec($sql);
|
||||
$stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)");
|
||||
$stmt = $pdo->prepare("INSERT INTO migrations (migration_name) VALUES (?)");
|
||||
$stmt->execute([$migration_name]);
|
||||
} catch (PDOException $e) {
|
||||
// If it's "Duplicate column name" or "Duplicate key name", we might want to skip and mark as applied
|
||||
@ -94,7 +94,7 @@ require_once __DIR__ . '/../includes/functions.php';
|
||||
if (strpos($e->getMessage(), 'Duplicate column name') !== false ||
|
||||
strpos($e->getMessage(), 'Duplicate key name') !== false ||
|
||||
strpos($e->getMessage(), 'already exists') !== false) {
|
||||
$stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)");
|
||||
$stmt = $pdo->prepare("INSERT INTO migrations (migration_name) VALUES (?)");
|
||||
$stmt->execute([$migration_name]);
|
||||
} else {
|
||||
throw $e;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user