• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Jagepard / Rudra-Cli / 15920986328

27 Jun 2025 07:42AM UTC coverage: 4.771% (-95.2%) from 100.0%
15920986328

push

github

web-flow
Merge pull request #29 from Jagepard/wip

adds commands

0 of 479 new or added lines in 20 files covered. (0.0%)

24 of 503 relevant lines covered (4.77%)

0.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Command/CreateMigrationCommand.php
1
<?php
2

3
namespace Rudra\Cli\Command;
4

5
use App\Ship\Utils\FileCreator;
6
use Rudra\Container\Facades\Rudra;
7
use Rudra\Cli\Command\ConsoleFacade as Cli;
8

9
class CreateMigrationCommand extends FileCreator
10
{
11
    /**
12
     * Creates a file with Migration data
13
     * -----------------------------
14
     * Создает файл с данными Migration
15
     */
NEW
16
    public function actionIndex(): void
×
17
    {
NEW
18
        Cli::printer("Enter table name: ", "magneta");
×
NEW
19
        $table = str_replace(PHP_EOL, "", Cli::reader());
×
20

NEW
21
        Cli::printer("Enter container (empty for Ship): ", "magneta");
×
NEW
22
        $container = ucfirst(str_replace(PHP_EOL, "", Cli::reader()));
×
23

NEW
24
        $date      = date("_dmYHis");
×
NEW
25
        $className = ucfirst($table) . $date;
×
26

NEW
27
        if (!empty($container)) {
×
NEW
28
            if (!is_dir(Rudra::config()->get('app.path') . "/app/Containers/$container/")) {
×
NEW
29
                Cli::printer("⚠️  Container '$container' does not exist" . PHP_EOL, "light_yellow");
×
NEW
30
                return;
×
31
            }
32

NEW
33
            $namespace = 'App\Containers\\' . $container . '\Migration';
×
34

NEW
35
            $this->writeFile([Rudra::config()->get('app.path') . "/app/Containers/" . $container . "/Migration/", "{$className}_migration.php"],
×
NEW
36
                $this->createMigration($className, $table, $namespace)
×
NEW
37
            );
×
38
        } else {
NEW
39
            $namespace = "App\Ship\Migration";
×
40

NEW
41
            $this->writeFile([Rudra::config()->get('app.path') . "/app/Ship/Migration/", "{$className}_migration.php"],
×
NEW
42
                $this->createMigration($className, $table, $namespace)
×
NEW
43
            );
×
44
        }
45
    }
46

47
    /**
48
     * Creates class data
49
     * ------------------
50
     * Создает данные класса
51
     *
52
     * @param string $className
53
     * @param string $table
54
     * @param string $namespace
55
     * @return string
56
     */
NEW
57
    private function createMigration(string $className, string $table, string $namespace): string
×
58
    {
NEW
59
        return <<<EOT
×
NEW
60
<?php
×
61

NEW
62
namespace $namespace;
×
63

64
use Rudra\Model\Schema;
65
use Rudra\Container\Facades\Rudra;
66

NEW
67
class {$className}_migration
×
68
{
69
    public function up(): void
70
    {
NEW
71
        Schema::create('$table', function (\$table) {
×
72
            \$table->integer('id', '', true)
73
                ->created_at()
74
                ->updated_at()
75
                ->pk('id');
76
        })->execute();
77
    }
78
}\r\n
NEW
79
EOT;
×
80
    }
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc