Created
July 9, 2014 15:41
-
-
Save Reizinixc/5dc6c2935637289617ac to your computer and use it in GitHub Desktop.
Set all migration files was migrated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$host = '127.0.0.1'; | |
$dbname = 'database'; | |
$username = 'root'; | |
$password = ''; | |
$migrationPath = '../app/database/migrations/'; | |
$migrationFiles = array_diff(scandir($migrationPath), ['.', '..', '.gitkeep']); | |
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); | |
$stmt = $pdo->prepare("INSERT INTO migrations VALUES (:migration, :batch)"); | |
$pdo->query("DELETE FROM migrations"); | |
foreach ($migrationFiles as $file) { | |
echo $stmt->execute(['migration' => pathinfo($file, PATHINFO_FILENAME), 'batch' => 0]) ? '.' : 'F'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment