-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmigrate
More file actions
50 lines (37 loc) · 997 Bytes
/
migrate
File metadata and controls
50 lines (37 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
require_once './vendor/autoload.php';
require_once './eagle/database/Connection.php';
$conn = new Connection();
if (isset($argv[1]) && $argv[1] != 'migrate')
{
$file = './eagle/database/migrations/' . $argv[1] . '.php';
require_once $file;
$class = basename($file, '.php');
$obj = new $class;
$obj->up();
echo $class . " Done\n";
}
else if (isset($argv[1]) && $argv[1] == 'migrate')
{
//echo "Are you sure you want to migrate? [y/n]";
//$answer = trim(fgets(STDIN));
//if ($answer == 'y' || $answer == 'Y')
//{
foreach (glob('./eagle/database/migrations/*.php') as $file)
{
require_once $file;
$class = basename($file, '.php');
$obj = new $class;
$obj->up();
echo $class . " Done\n";
}
//}
}
//echo "\nWould you like to seed the database? [y/n]";
//$answer = trim(fgets(STDIN));
//if ($answer == 'y' || $answer == 'Y')
if (isset($argv[2]) && $argv[2] == 'seed')
{
require_once './eagle/database/seeders/Seeder.php';
echo "Finished seeding";
}