Skip to content

Commit d24a69e

Browse files
update
1 parent 05e2988 commit d24a69e

13 files changed

+173
-119
lines changed

src/Console/Commands/DBCommand.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,16 @@ public function wipe()
163163

164164
$this->forceChecker();
165165

166-
// prompt for confirmation before proceeding
167-
$confirm = $this->confirm('Proceed with db:wipe?');
168-
169-
// ask once
170-
if (!$confirm && $this->isConsole()) {
171-
$this->warning("Command aborted.");
172-
return 0;
166+
// only prompt for confirmation when `response != 0`
167+
if(!($response == '0')){
168+
// prompt for confirmation before proceeding
169+
$confirm = $this->confirm('Proceed with db:wipe?');
170+
171+
// ask once
172+
if (!$confirm && $this->isConsole()) {
173+
$this->warning("Command aborted.");
174+
return 0;
175+
}
173176
}
174177

175178
$tables = $this->getTables();

src/Console/Commands/MigrationCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public function fresh()
4141
$force = $this->force();
4242
$seed = $this->option('seed');
4343

44+
$this->forceChecker();
45+
4446
if($force){
4547
Artisan::call('db:wipe --force --drop-types --drop-views --response=0');
4648
}
@@ -66,7 +68,7 @@ public function fresh()
6668
*/
6769
public function refresh()
6870
{
69-
return Artisan::call('migrate:fresh --force --drop-types --drop-views');
71+
return Artisan::call('migrate:fresh --force');
7072
}
7173

7274
/**

src/Dummy/dummyJobsMigration.dum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ return new class extends Migration
1212
*/
1313
public function up(): void
1414
{
15-
Schema::create('{{TABLE}}', function (Blueprint $table) {
15+
Schema::create('{{ table }}', function (Blueprint $table) {
1616
$table->id();
1717
$table->string('queue')->index();
1818
$table->longText('payload');
@@ -29,7 +29,7 @@ return new class extends Migration
2929
*/
3030
public function drop($force = false): void
3131
{
32-
Schema::dropTable('{{TABLE}}', $force);
32+
Schema::dropTable('{{ table }}', $force);
3333
}
3434

3535
};

src/Dummy/dummyMigration.dum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ return new class extends Migration
1212
*/
1313
public function up(): void
1414
{
15-
Schema::create('{{TABLE}}', function (Blueprint $table) {
15+
Schema::create('{{ table }}', function (Blueprint $table) {
1616
$table->id();
1717
$table->timestamps();
1818
});
@@ -24,7 +24,7 @@ return new class extends Migration
2424
*/
2525
public function drop($force = false): void
2626
{
27-
Schema::dropTable('{{TABLE}}', $force);
27+
Schema::dropTable('{{ table }}', $force);
2828
}
2929

3030
};

src/Dummy/dummyScheme.dum

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ return new class extends Migration
1111
*/
1212
public function up(): void
1313
{
14-
Schema::create('{{TABLE}}', function (Blueprint $table) {
15-
{{BODY}}
14+
Schema::create('{{ table }}', function (Blueprint $table) {
15+
{{ body }}
1616
});
1717
}
1818

@@ -22,6 +22,6 @@ return new class extends Migration
2222
*/
2323
public function drop($force = false): void
2424
{
25-
Schema::dropTable('{{TABLE}}', $force);
25+
Schema::dropTable('{{ table }}', $force);
2626
}
2727
};

src/Dummy/dummySchemeLaravel.dum

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ return new class extends Migration
1111
*/
1212
public function up(): void
1313
{
14-
Schema::create('{{TABLE}}', function (Blueprint $table) {
15-
{{BODY}}
14+
Schema::create('{{ table }}', function (Blueprint $table) {
15+
{{ body }}
1616
});
1717
}
1818

@@ -21,6 +21,6 @@ return new class extends Migration
2121
*/
2222
public function drop(): void
2323
{
24-
Schema::dropIfExists('{{TABLE}}');
24+
Schema::dropIfExists('{{ table }}');
2525
}
2626
};

src/Dummy/dummySessionsMigration.dum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ return new class extends Migration
1212
*/
1313
public function up(): void
1414
{
15-
Schema::create('{{TABLE}}', function (Blueprint $table) {
15+
Schema::create('{{ table }}', function (Blueprint $table) {
1616
$table->id();
1717
$table->string('ip_address', 45)->nullable();
1818
$table->text('user_agent')->nullable();
@@ -31,7 +31,7 @@ return new class extends Migration
3131
*/
3232
public function drop($force = false): void
3333
{
34-
Schema::dropTable('{{TABLE}}', $force);
34+
Schema::dropTable('{{ table }}', $force);
3535
}
3636

3737
};

src/Migrations/Traits/MigrationTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private static function runMigrationCreateTable($table_name, $type = null)
8383
};
8484

8585
// dummy content
86-
$dummyContent = Str::replace('{{TABLE}}', $table, File::get($dummyPath));
86+
$dummyContent = Str::replace('{{ table }}', $table, File::get($dummyPath));
8787

8888
// absolute path
8989
self::$storagePath = self::$migrations . $fileName;

src/Migrations/Traits/SchemaConfigurationTrait.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,18 @@ protected function createColumnDefinition(?array $options)
9999
], $options);
100100

101101
// create default string
102-
$getType = $this->getColumnType($options['type']);
102+
$type = $this->getColumnType($options['type']);
103103
$unsigned = $this->getUnsigned($options['type']);
104-
$columnDef = "`{$options['name']}` {$getType}";
104+
$columnDef = "`{$options['name']}` {$type}";
105105

106106
// Query for Type and Length
107107
$columnDef .= $this->queryForType_and_Length($options);
108108

109109
// add unsigned
110-
$columnDef .= $this->queryForUnsigned($options, $getType, $unsigned);
110+
$columnDef .= $this->queryForUnsigned($options, $type, $unsigned);
111111

112112
// add collate
113-
$columnDef .= $this->queryForCollate($getType);
113+
$columnDef .= $this->queryForCollate($type);
114114

115115
// add for nullable
116116
$columnDef .= $this->queryForNullable($options);
@@ -372,13 +372,18 @@ protected function getUnsigned($type)
372372

373373
/**
374374
* Create generix identifier name
375+
* @param array $column
375376
* @param string|null $name
376377
*
377378
* @return string
378379
*/
379-
protected function genericIdentifier($name = null)
380+
protected function genericIdentifier($column, $name = null)
380381
{
381-
$column = $this->columns[count($this->columns) - 1];
382+
dd(
383+
$column,
384+
);
385+
386+
$column = $this->columns[count($this->columns)];
382387
$unique = (new Exception)->getTrace()[1]['function'] ?? '__';
383388

384389
// for foreign keys

src/Migrations/Traits/SchemaTrait.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,13 @@ public function timestamp($name)
452452
public function timestamps()
453453
{
454454
return $this->addColumn('created_at', 'timestamps', [
455-
'nullable' => true,
456-
'index' => $this->genericIdentifier('created_at_index')
457-
])
458-
->addColumn('updated_at', 'timestamps', [
459-
'nullable' => true,
460-
'index' => $this->genericIdentifier('updated_at_index')
461-
]);
455+
'nullable' => true,
456+
'index' => $this->genericIdentifier('created_at_index')
457+
])
458+
->addColumn('updated_at', 'timestamps', [
459+
'nullable' => true,
460+
'index' => $this->genericIdentifier('updated_at_index')
461+
]);
462462
}
463463

464464
}

0 commit comments

Comments
 (0)