-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
360 additions
and
103 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
36 changes: 36 additions & 0 deletions
36
database/migrations/2014_10_12_000000_testbench_create_users_table.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
if (Schema::hasTable('users')) { | ||
return; | ||
} | ||
|
||
Schema::create('users', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->string('email')->unique(); | ||
$table->timestamp('email_verified_at')->nullable(); | ||
$table->string('password'); | ||
$table->rememberToken(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('users'); | ||
} | ||
}; |
32 changes: 32 additions & 0 deletions
32
database/migrations/2014_10_12_100000_testbench_create_password_reset_tokens_table.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
if (Schema::hasTable('password_reset_tokens')) { | ||
return; | ||
} | ||
|
||
Schema::create('password_reset_tokens', function (Blueprint $table) { | ||
$table->string('email')->primary(); | ||
$table->string('token'); | ||
$table->timestamp('created_at')->nullable(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('password_reset_tokens'); | ||
} | ||
}; |
36 changes: 36 additions & 0 deletions
36
database/migrations/2019_08_19_000000_testbench_create_failed_jobs_table.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
if (Schema::hasTable('failed_jobs')) { | ||
return; | ||
} | ||
|
||
Schema::create('failed_jobs', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('uuid')->unique(); | ||
$table->text('connection'); | ||
$table->text('queue'); | ||
$table->longText('payload'); | ||
$table->longText('exception'); | ||
$table->timestamp('failed_at')->useCurrent(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('failed_jobs'); | ||
} | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
cacheResultFile=".phpunit.cache/test-results" | ||
executionOrder="depends,defects" | ||
forceCoversAnnotation="false" | ||
beStrictAboutCoversAnnotation="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
convertDeprecationsToExceptions="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
verbose="true"> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<coverage cacheDirectory=".phpunit.cache/code-coverage" | ||
processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
</coverage> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" failOnRisky="true" failOnWarning="true" cacheDirectory=".phpunit.cache" requireCoverageMetadata="false" beStrictAboutCoverageMetadata="true"> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Recca0120\LaravelErd\Adapter\Contracts; | ||
|
||
interface Column | ||
{ | ||
public function getName(): string; | ||
|
||
public function getNotnull(): bool; | ||
|
||
public function getPrecision(): int; | ||
|
||
public function getColumnType(): string; | ||
|
||
public function getDefault(); | ||
|
||
public function getComment(): ?string; | ||
|
||
public function getAutoincrement(): bool; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Recca0120\LaravelErd\Adapter\Contracts; | ||
|
||
interface SchemaManager | ||
{ | ||
public function introspectTable(string $name): Table; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Recca0120\LaravelErd\Adapter\Contracts; | ||
|
||
use Illuminate\Support\Collection; | ||
|
||
interface Table | ||
{ | ||
public function getName(): string; | ||
|
||
/** | ||
* @return Collection<int, Column> | ||
*/ | ||
public function getColumns(): Collection; | ||
|
||
/** | ||
* @return Collection<int, string> | ||
*/ | ||
public function getPrimaryKey(): Collection; | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Recca0120\LaravelErd\Adapter\DBAL; | ||
|
||
use Doctrine\DBAL\Schema\AbstractSchemaManager; | ||
use Illuminate\Database\Connection; | ||
use Recca0120\LaravelErd\Adapter\Contracts\SchemaManager as SchemaManagerContract; | ||
use Recca0120\LaravelErd\Adapter\Contracts\Table as TableContract; | ||
|
||
class SchemaManager implements SchemaManagerContract | ||
{ | ||
private AbstractSchemaManager $schemaManager; | ||
|
||
public function __construct(Connection $connection) | ||
{ | ||
$this->schemaManager = $connection->getDoctrineSchemaManager(); | ||
} | ||
|
||
public function introspectTable(string $name): TableContract | ||
{ | ||
return new Table($this->schemaManager->introspectTable($name)); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Recca0120\LaravelErd\Adapter\Laravel; | ||
|
||
use Recca0120\LaravelErd\Adapter\Contracts\Column as ColumnContract; | ||
|
||
class Column implements ColumnContract | ||
{ | ||
private array $column; | ||
|
||
public function __construct(array $column) | ||
{ | ||
$this->column = $column; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->column['name']; | ||
} | ||
|
||
public function getNotnull(): bool | ||
{ | ||
return ! $this->column['nullable']; | ||
} | ||
|
||
public function getPrecision(): int | ||
{ | ||
return $this->column['precision'] ?? 10; | ||
} | ||
|
||
public function getColumnType(): string | ||
{ | ||
$type = $this->column['type']; | ||
|
||
return $type === 'varchar' ? 'string' : $type; | ||
} | ||
|
||
public function getDefault() | ||
{ | ||
$default = $this->column['default']; | ||
|
||
return $default ? trim($default, "'") : $default; | ||
} | ||
|
||
public function getComment(): ?string | ||
{ | ||
return $this->column['comment'] ?? null; | ||
} | ||
|
||
public function getAutoincrement(): bool | ||
{ | ||
return $this->column['auto_increment']; | ||
} | ||
} |
Oops, something went wrong.