Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: phpunit

on: [ push, pull_request ]
on: [ push ]

jobs:
build:
Expand All @@ -10,7 +10,7 @@ jobs:
fail-fast: true
matrix:
php: [ "8.0", "8.1", "8.2", "8.3", "8.4" ]
laravel: [ "8.0", "9.0", "10.0", "11.0" ]
laravel: [ "8.0", "9.0", "10.0", "11.0", "12.0" ]
psql: [ "9", "10", "11", "12", "13", "14", "15", "16", "17" ]
exclude:
- laravel: "8.0"
Expand Down Expand Up @@ -42,6 +42,21 @@ jobs:

- laravel: "11.0"
psql: "11"

- laravel: "12.0"
php: "8.0"

- laravel: "12.0"
php: "8.1"

- laravel: "12.0"
psql: "9"

- laravel: "12.0"
psql: "10"

- laravel: "12.0"
psql: "11"

name: php ${{ matrix.php }}, lr ${{ matrix.laravel }}, pg ${{ matrix.psql }}

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Or manually update `require-dev` block of `composer.json` and run `composer upda
| Service | Versions |
|:----------|:-----------------------------------|
| PHP | ^8.0 |
| Laravel | ^8.0, ^9.0, ^10.0, ^11.0 |
| Laravel | ^8.0, ^9.0, ^10.0, ^11.0, ^12.0 |
| Databases | MySQL 5.7+, PostgreSQL 9.5+, MSSQL |

| Laravel \ PostgreSQL | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
Expand All @@ -40,6 +40,7 @@ Or manually update `require-dev` block of `composer.json` and run `composer upda
| 9 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| 10 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| 11 | ✖️ | ✖️ | ✖️ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| 12 | ✖️ | ✖️ | ✖️ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |


## Usage
Expand Down
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,22 @@
"require": {
"php": "^8.0",
"ext-pdo": "*",
"doctrine/dbal": "^3.0 || ^4.0",
"dragon-code/contracts": "^2.15",
"dragon-code/support": "^6.0",
"illuminate/contracts": "^8.0 || ^9.0 || ^10.0 || ^11.0",
"illuminate/database": "^8.0 || ^9.0 || ^10.0 || ^11.0",
"illuminate/support": "^8.0 || ^9.0 || ^10.0 || ^11.0"
"illuminate/contracts": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"illuminate/database": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"illuminate/support": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0"
},
"require-dev": {
"ext-pdo_mysql": "*",
"ext-pdo_pgsql": "*",
"doctrine/dbal": "^3.0 || ^4.0",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"phpunit/phpunit": "^9.6 || ^10.0"
"orchestra/testbench": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0",
"phpunit/phpunit": "^9.6 || ^10.0 || ^11.0"
},
"suggest": {
"doctrine/dbal": "[For Laravel 8-10] Required to rename columns and drop SQLite columns (^3.5.1)."
},
"minimum-stability": "stable",
"prefer-stable": true,
Expand Down Expand Up @@ -80,4 +83,4 @@
]
}
}
}
}
15 changes: 5 additions & 10 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/logs/coverage"/>
<text outputFile="build/logs/coverage.txt"/>
</report>
</coverage>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="DB_USERNAME" value="root"/>
<env name="DB_PASSWORD" value="root"/>
</php>
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="DB_USERNAME" value="root"/>
<env name="DB_PASSWORD" value="root"/>
</php>
</phpunit>
8 changes: 5 additions & 3 deletions src/Console/Migrate.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace DragonCode\MigrateDB\Console;

use DragonCode\Contracts\MigrateDB\Builder;
Expand Down Expand Up @@ -135,9 +137,9 @@ protected function migrateTable(string $table, string $column): void
$this->builder($this->source(), $table)
->orderBy($column)
->chunk(1000, function (Collection $items) use ($table) {
$items = Arr::resolve($items);

$this->builder($this->target(), $table)->insert($items);
$this->builder($this->target(), $table)->insert(
Arr::resolve($items)
);
});

$this->migrated[] = $table;
Expand Down
2 changes: 2 additions & 0 deletions src/Constants/Drivers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace DragonCode\MigrateDB\Constants;

class Drivers
Expand Down
8 changes: 7 additions & 1 deletion src/Database/Builder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace DragonCode\MigrateDB\Database;

use DragonCode\Contracts\MigrateDB\Builder as BuilderContract;
Expand Down Expand Up @@ -33,9 +35,13 @@ public function schema(): SchemaBuilder

public function getAllTables(): array
{
$schema = method_exists($this->schema(), 'getCurrentSchemaName')
? $this->schema()->getCurrentSchemaName()
: null;

$tables = method_exists($this->schema(), 'getAllTables')
? $this->schema()->getAllTables()
: $this->schema()->getTables();
: $this->schema()->getTables($schema);

$key = $this->tableNameColumn();

Expand Down
2 changes: 2 additions & 0 deletions src/Database/Manager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace DragonCode\MigrateDB\Database;

use DragonCode\Contracts\MigrateDB\Builder as BuilderContract;
Expand Down
2 changes: 2 additions & 0 deletions src/Database/MySQLBuilder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace DragonCode\MigrateDB\Database;

class MySQLBuilder extends Builder
Expand Down
2 changes: 2 additions & 0 deletions src/Database/PostgresBuilder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace DragonCode\MigrateDB\Database;

class PostgresBuilder extends Builder
Expand Down
2 changes: 2 additions & 0 deletions src/Database/SqlServerBuilder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace DragonCode\MigrateDB\Database;

class SqlServerBuilder extends Builder
Expand Down
2 changes: 2 additions & 0 deletions src/Exceptions/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace DragonCode\MigrateDB\Exceptions;

use Symfony\Component\Console\Exception\InvalidArgumentException as BaseException;
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/BuilderManager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace DragonCode\MigrateDB\Facades;

use DragonCode\Contracts\MigrateDB\Builder;
Expand Down
2 changes: 2 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace DragonCode\MigrateDB;

use DragonCode\MigrateDB\Console\Migrate;
Expand Down
2 changes: 2 additions & 0 deletions tests/Concerns/Connections.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Concerns;

use Illuminate\Database\Schema\Builder;
Expand Down
8 changes: 7 additions & 1 deletion tests/Concerns/Database.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Concerns;

use DragonCode\MigrateDB\Constants\Drivers;
Expand Down Expand Up @@ -101,8 +103,12 @@ protected function runMigrations(): void

protected function getTables(SchemaBuilder $builder): array
{
$schema = method_exists($builder, 'getCurrentSchemaName')
? $builder->getCurrentSchemaName()
: null;

return method_exists($builder, 'getAllTables')
? $builder->getAllTables()
: $builder->getTables();
: $builder->getTables($schema);
}
}
2 changes: 2 additions & 0 deletions tests/Concerns/Migration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Concerns;

use Illuminate\Database\Migrations\Migration as BaseMigration;
Expand Down
2 changes: 2 additions & 0 deletions tests/Concerns/Seeders.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Concerns;

use Illuminate\Support\Facades\DB;
Expand Down
2 changes: 2 additions & 0 deletions tests/Configurations/BaseConfiguration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Configurations;

use DragonCode\Support\Concerns\Makeable;
Expand Down
2 changes: 2 additions & 0 deletions tests/Configurations/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Configurations;

use DragonCode\Support\Concerns\Makeable;
Expand Down
2 changes: 2 additions & 0 deletions tests/Configurations/Manager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Configurations;

use DragonCode\MigrateDB\Constants\Drivers;
Expand Down
2 changes: 2 additions & 0 deletions tests/Configurations/MySQL.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Configurations;

use DragonCode\MigrateDB\Constants\Drivers;
Expand Down
2 changes: 2 additions & 0 deletions tests/Configurations/Postgres.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Configurations;

use DragonCode\MigrateDB\Constants\Drivers;
Expand Down
2 changes: 2 additions & 0 deletions tests/Configurations/SqlServer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Configurations;

use DragonCode\MigrateDB\Constants\Drivers;
Expand Down
2 changes: 2 additions & 0 deletions tests/Connectors/BaseConnection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Connectors;

use DragonCode\Support\Concerns\Makeable;
Expand Down
6 changes: 5 additions & 1 deletion tests/Connectors/MySqlConnection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Connectors;

use Illuminate\Database\Connectors\ConnectorInterface;
Expand All @@ -11,7 +13,9 @@ class MySqlConnection extends BaseConnection
{
protected function grammar(): Grammar
{
return new MySqlGrammar();
return new MySqlGrammar(
$this->databaseConnection()
);
}

protected function connector(): ConnectorInterface
Expand Down
6 changes: 5 additions & 1 deletion tests/Connectors/PostgresConnection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Connectors;

use Illuminate\Database\Connectors\ConnectorInterface;
Expand Down Expand Up @@ -28,7 +30,9 @@ protected function dropSessions(string $name): string

protected function grammar(): Grammar
{
return new PostgresGrammar();
return new PostgresGrammar(
$this->databaseConnection()
);
}

protected function connector(): ConnectorInterface
Expand Down
6 changes: 5 additions & 1 deletion tests/Connectors/SqlServerConnection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Connectors;

use Illuminate\Database\Connectors\ConnectorInterface;
Expand All @@ -11,7 +13,9 @@ class SqlServerConnection extends BaseConnection
{
protected function grammar(): Grammar
{
return new SqlServerGrammar();
return new SqlServerGrammar(
$this->databaseConnection()
);
}

protected function connector(): ConnectorInterface
Expand Down
2 changes: 2 additions & 0 deletions tests/Providers/TestServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Providers;

use Illuminate\Support\ServiceProvider;
Expand Down
Loading