Skip to content

Commit

Permalink
update to laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
miftahurrahmi committed Jun 28, 2024
1 parent 872dc52 commit 1a9cdaf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.0, 8.1]
laravel: ["8.*", "9.*"]
laravel-require: [8.0]
php: [8.2]
laravel: ["11.*"]
laravel-require: [11.0]
mysql-version: [8.0]
coverage: [none]
include:
- php: 8.1
laravel: 9.*
laravel-require: 8.0
- php: 8.2
laravel: 11.*
laravel-require: 11.0
mysql-version: 8.0
coverage: xdebug

Expand Down Expand Up @@ -130,8 +130,8 @@ jobs:
sed -i 's/DB_PASSWORD=/DB_PASSWORD=postgres/g' .env &&
sed -i 's/DB_HOST=127.0.0.1/DB_HOST=localhost/g' .env &&
sed -i 's/DB_USERNAME=root/DB_USERNAME=postgres/g' .env &&
sed -i 's/DB_PORT=3306/DB_PORT=5432/g' .env
sed -i 's/DB_PORT=3306/DB_PORT=5432/g' .env


# Pgsql | Laravel setup
- name: Pgsql | Laravel setup
Expand Down
31 changes: 14 additions & 17 deletions src/Database/Schema/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,14 @@ public static function tableExists($table)

public static function listTables()
{
// $sm = static::registerConnection()->createSchemaManager();
// $list_tables = $sm->listTables();

$sm = Schema::getTables();

$tables = [];

foreach ($sm as $key => $table_name) {
// $tables[$table_name["name"]] = static::listTableDetails($table_name["name"]);
$tables[$table_name["name"]] = $table_name["name"];
}

return $tables;
}

Expand All @@ -62,39 +58,40 @@ public static function listTableDetails($table_name)
{
$sm =static::registerConnection()->createSchemaManager();
$columns = $sm->listTableColumns($table_name);

$foreign_keys = [];
if (static::registerConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$foreign_keys = $sm->listTableForeignKeys($table_name);
}

$indexes = $sm->listTableIndexes($table_name);

return new Table($table_name, $columns, $indexes, [],$foreign_keys, []);
}

public static function registerConnection()
{
$databaseConfig = config('database.connections.' . config('database.default'));
$driver_name = DB::getDriverName();
if($driver_name == 'mysql' || $driver_name = 'pgsql') {

if($driver_name == 'mysql' || $driver_name == 'pgsql') {
$connectionParams = [
'dbname' => $databaseConfig['database'],
'user' => $databaseConfig['username'],
'password' => $databaseConfig['password'],
'host' => $databaseConfig['host'],
'driver' => 'pdo_' . $driver_name,
'driver' => 'pdo_' . $driver_name,
'port' => $databaseConfig['port'],
];
} else {
}

if ($driver_name == 'sqlite') {
$connectionParams = [
'user' => $databaseConfig['username'],
'password' => $databaseConfig['password'],
'path' => $databaseConfig['database'],
'driver' => 'pdo_' . $driver_name,
'driver' => 'pdo_' . $driver_name,
];
}

$doctrine_connection = DriverManager::getConnection($connectionParams);

return $doctrine_connection;
Expand All @@ -111,7 +108,7 @@ public static function describeTable($table_name)
Type::registerCustomPlatformTypes();

$table = static::listTableDetails($table_name);

return collect($table->columns)->map(function ($column) use ($table) {
$column_array = Column::toArray($column);

Expand Down
4 changes: 2 additions & 2 deletions src/Database/Types/Common/VarCharType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

class VarCharType extends DoctrineStringType
{
const NAME = 'varchar';
const NAME = 'string';

public function getName()
{
return static::NAME;
return 'varchar';
}
}
5 changes: 3 additions & 2 deletions src/Database/Types/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ public static function registerCustomPlatformTypes($force = false)

$doctrine_connection = SchemaManager::registerConnection();
$platform = $doctrine_connection->getDatabasePlatform();
$platform_name = ucfirst(DB::getDriverName());
// $platform_name = ucfirst(DB::getDriverName());
$platform_name = ucfirst($platform->getName());

$custom_types = array_merge(
static::getPlatformCustomTypes('Common'),
static::getPlatformCustomTypes($platform_name)
);

foreach ($custom_types as $type) {
$name = $type::NAME;

Expand Down
1 change: 1 addition & 0 deletions src/Helpers/DataTypeToComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class DataTypeToComponent
protected static $type_list = [
'CHAR' => 'text',
'VARCHAR' => 'text',
'STRING' => 'text',
'BINARY' => 'text',
'VARBINARY' => 'text',
'TINYBLOB' => 'text',
Expand Down

0 comments on commit 1a9cdaf

Please sign in to comment.