Skip to content

Commit

Permalink
Merge pull request #220 from kitloong/7.x
Browse files Browse the repository at this point in the history
Merge 7.x
  • Loading branch information
kitloong committed Jun 1, 2024
2 parents 6e29fd1 + ca7d318 commit 2b97e97
Show file tree
Hide file tree
Showing 76 changed files with 475 additions and 457 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml,xml}]
[*.{yml,yaml}]
indent_size = 2
33 changes: 0 additions & 33 deletions .env.action

This file was deleted.

33 changes: 0 additions & 33 deletions .env.example

This file was deleted.

2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
/.github export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.env.* export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.phpmd.xml export-ignore
/check_migrations.sh export-ignore
/phpcs.xml export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/phpunit-action.xml export-ignore
/testbench.yaml export-ignore
5 changes: 2 additions & 3 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# These are supported funding model platforms

custom: ['https://www.buymeacoffee.com/kitloong']
github: kitloong
buy_me_a_coffee: kitloong
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ If applicable, add screenshots to help explain your problem.

**Details (please complete the following information):**
- DB: [e.g. MySQL]
- DB Version: [e.g. 5.7.37]
- DB Version: [e.g. 8.0.30]
- Laravel Version:
- PHP Version:
- Migrations Generator Version:
- Doctrine DBAL Version [`composer info doctrine/dbal | grep versions`]:
- Migrations Generator Version:

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Alter MySQL 8 root plugin
run: |
mysql --version
mysql --host 127.0.0.1 --port ${{ job.services.mysql8.ports['3306'] }} -u root -e "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY ''"
uses: actions/checkout@v4

- name: SQL Server Create Database
run: |
Expand All @@ -116,7 +111,7 @@ jobs:
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --prefer-stable --prefer-dist --no-interaction --no-progress
- name: Setup .env
- name: Setup environment
run: |
mkdir ./database
composer run action-env-setup
Expand All @@ -125,7 +120,8 @@ jobs:
run: vendor/bin/phpunit --coverage-clover=coverage.xml

- name: Upload to codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/migrations
/storage
/vendor
.env
.php-cs-fixer.cache
.php_cs.cache
.phpstorm.meta.php
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"prefer-stable": true,
"scripts": {
"action-env-setup": [
"@php -r \"file_exists('.env') || copy('.env.action', '.env');\""
"@php -r \"file_exists('phpunit.xml') || copy('phpunit-action.xml', 'phpunit.xml');\""
],
"phpcs": [
"phpcs"
Expand Down
8 changes: 4 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ parameters:
- tests

# The level 9 is the highest level
level: 6
level: 8

ignoreErrors:
- '#Class Dotenv\\Dotenv constructor invoked with 1 parameter, 4 required.#'
- '#Parameter \#1 \$store of class Dotenv\\Dotenv constructor expects Dotenv\\Store\\StoreInterface, string given.#'
- '#Method KitLoong\\MigrationsGenerator\\Database\\(.*)Schema::getViews\(\) should return Illuminate\\Support\\Collection<int, KitLoong\\MigrationsGenerator\\Schema\\Models\\View> but returns Illuminate\\Support\\Collection<(int|\(int\|string\)), KitLoong\\MigrationsGenerator\\Database\\Models\\(.*)\\(.*)View>.#'
- '#Method KitLoong\\MigrationsGenerator\\Database\\(.*)Schema::getProcedures\(\) should return Illuminate\\Support\\Collection<int, KitLoong\\MigrationsGenerator\\Schema\\Models\\Procedure> but returns Illuminate\\Support\\Collection<(int|\(int\|string\)), KitLoong\\MigrationsGenerator\\Database\\Models\\(.*)\\(.*)Procedure>.#'
- '#Method KitLoong\\MigrationsGenerator\\Database\\(.*)Schema::getForeignKeys\(\) should return Illuminate\\Support\\Collection<int, KitLoong\\MigrationsGenerator\\Schema\\Models\\ForeignKey> but returns Illuminate\\Support\\Collection<(int|\(int\|string\)), KitLoong\\MigrationsGenerator\\Database\\Models\\(.*)\\(.*)ForeignKey>.#'
- '#(.*)expects Illuminate\\Support\\Collection<int, KitLoong\\MigrationsGenerator\\Migration\\Blueprint\\WritableBlueprint>, Illuminate\\Support\\Collection<int, KitLoong\\MigrationsGenerator\\Migration\\Blueprint\\(.*)Blueprint> given.#'
- '#Call to an undefined method Mockery\\ExpectationInterface\|Mockery\\HigherOrderMessage::(.*)#'
- '#Cannot call method expectsQuestion\(\) on Illuminate\\Testing\\PendingCommand\|int\.#'

excludePaths:
- ./*/*/FileToBeExcluded.php
- ./tests/resources/**

checkMissingIterableValueType: true
55 changes: 55 additions & 0 deletions phpunit-action.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
stderr="true"
>
<coverage includeUncoveredFiles="true"/>
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
<php>
<env name="MYSQL57_HOST" value="127.0.0.1"/>
<env name="MYSQL57_PORT" value="3306"/>
<env name="MYSQL57_DATABASE" value="migration"/>
<env name="MYSQL57_USERNAME" value="root"/>
<env name="MYSQL57_PASSWORD" value=""/>

<env name="MYSQL8_HOST" value="127.0.0.1"/>
<env name="MYSQL8_PORT" value="33062"/>
<env name="MYSQL8_DATABASE" value="migration"/>
<env name="MYSQL8_USERNAME" value="root"/>
<env name="MYSQL8_PASSWORD" value=""/>

<env name="POSTGRES_HOST" value="127.0.0.1"/>
<env name="POSTGRES_PORT" value="5432"/>
<env name="POSTGRES_DATABASE" value="migration"/>
<env name="POSTGRES_USERNAME" value="root"/>
<env name="POSTGRES_PASSWORD" value="!QAZ2wsx"/>

<env name="SQLSRV_HOST" value="127.0.0.1"/>
<env name="SQLSRV_PORT" value="1433"/>
<env name="SQLSRV_DATABASE" value="migration"/>
<env name="SQLSRV_USERNAME" value="sa"/>
<env name="SQLSRV_PASSWORD" value="!QAZ2wsx"/>

<env name="MARIADB_HOST" value="127.0.0.1"/>
<env name="MARIADB_PORT" value="3307"/>
<env name="MARIADB_DATABASE" value="migration"/>
<env name="MARIADB_USERNAME" value="root"/>
<env name="MARIADB_PASSWORD" value=""/>

<env name="SQLITE_DATABASE" value="./database/migration.sqlite"/>

<env name="MYSQLDUMP_HAS_OPTION_SKIP_COLUMN_STATISTICS" value="true"/>
</php>
</phpunit>
44 changes: 38 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,43 @@
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>src/DBAL/Types</directory>
</exclude>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
<php>
<env name="MYSQL57_HOST" value="mysql57"/>
<env name="MYSQL57_PORT" value="3306"/>
<env name="MYSQL57_DATABASE" value="migration"/>
<env name="MYSQL57_USERNAME" value=""/>
<env name="MYSQL57_PASSWORD" value=""/>

<env name="MYSQL8_HOST" value="mysql8"/>
<env name="MYSQL8_PORT" value="3306"/>
<env name="MYSQL8_DATABASE" value="migration"/>
<env name="MYSQL8_USERNAME" value=""/>
<env name="MYSQL8_PASSWORD" value=""/>

<env name="POSTGRES_HOST" value="postgis"/>
<env name="POSTGRES_PORT" value="5432"/>
<env name="POSTGRES_DATABASE" value="migration"/>
<env name="POSTGRES_USERNAME" value=""/>
<env name="POSTGRES_PASSWORD" value=""/>

<env name="SQLSRV_HOST" value="sqlsrv"/>
<env name="SQLSRV_PORT" value="1433"/>
<env name="SQLSRV_DATABASE" value="migration"/>
<env name="SQLSRV_USERNAME" value=""/>
<env name="SQLSRV_PASSWORD" value=""/>

<env name="MARIADB_HOST" value="mariadb"/>
<env name="MARIADB_PORT" value="3306"/>
<env name="MARIADB_DATABASE" value="migration"/>
<env name="MARIADB_USERNAME" value=""/>
<env name="MARIADB_PASSWORD" value=""/>

<env name="SQLITE_DATABASE" value="./database/migration.sqlite"/>

<env name="MYSQLDUMP_HAS_OPTION_SKIP_COLUMN_STATISTICS" value="false"/>
</php>
</phpunit>
3 changes: 2 additions & 1 deletion src/Database/DatabaseSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* }
*
* @phpstan-type SchemaForeignKey array{
* name: string,
* name: ?string,
* columns: string[],
* foreign_schema: ?string,
* foreign_table: string,
Expand Down Expand Up @@ -78,6 +78,7 @@ protected function getSchemaTable(string $name): array
{
if ($this->tables === []) {
foreach (SchemaFacade::getTables() as $table) {
/** @var SchemaTable $table */
$this->tables[$table['name']] = $table;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Models/DatabaseForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
abstract class DatabaseForeignKey implements ForeignKey
{
protected string $name;
protected ?string $name;

protected string $tableName;

Expand Down Expand Up @@ -46,7 +46,7 @@ public function __construct(string $table, array $foreignKey)
/**
* @inheritDoc
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Models/DatabaseTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ public function __construct(array $table, Collection $columns, Collection $index
$this->comment = $table['comment'];
$this->collation = $table['collation'];

$this->columns = $columns->reduce(function (Collection $columns, array $column) use ($userDefinedTypes) {
$this->columns = $columns->reduce(function ($columns, array $column) use ($userDefinedTypes) {
if (!$userDefinedTypes->contains($column['type_name'])) {
$columns->push($this->makeColumn($this->name, $column));
}

return $columns;
}, new Collection())->values();

$this->udtColumns = $columns->reduce(function (Collection $columns, array $column) use ($userDefinedTypes) {
$this->udtColumns = $columns->reduce(function ($columns, array $column) use ($userDefinedTypes) {
if ($userDefinedTypes->contains($column['type_name'])) {
$columns->push($this->makeUDTColumn($this->name, $column));
}
Expand Down
3 changes: 3 additions & 0 deletions src/Database/Models/MySQL/MySQLColumnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class MySQLColumnType extends DatabaseColumnType
'varchar' => ColumnType::STRING,
'year' => ColumnType::YEAR,

// For MariaDB
'uuid' => ColumnType::UUID,

// Removed from Laravel v11
'geomcollection' => ColumnType::GEOMETRY_COLLECTION,
'linestring' => ColumnType::LINE_STRING,
Expand Down
Loading

0 comments on commit 2b97e97

Please sign in to comment.