29 lines
1.1 KiB
PHP
29 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Shared\Installation;
|
|
|
|
use Illuminate\Database\PostgresConnection;
|
|
|
|
/** Compatibility at installation time only; runtime business connections are untouched. */
|
|
final class CompositionSchemaConnection extends PostgresConnection
|
|
{
|
|
public string $originalPermissionCheck;
|
|
public ?CompositionSchemaBuilder $compositionBuilder=null;
|
|
|
|
public function getSchemaBuilder()
|
|
{
|
|
$this->useDefaultSchemaGrammar();
|
|
return $this->compositionBuilder??=new CompositionSchemaBuilder($this);
|
|
}
|
|
|
|
public function statement($query,$bindings=[])
|
|
{
|
|
// Older migrations replaced the permission whitelist. Preserve its original
|
|
// branches as well as the migration's additions, without granting any right.
|
|
if(preg_match('/^ALTER TABLE permission_grants ADD CONSTRAINT permission_grants_scope_check CHECK \((.*)\)$/s',$query,$m)){
|
|
$query='ALTER TABLE permission_grants ADD CONSTRAINT permission_grants_scope_check CHECK (('.$this->originalPermissionCheck.') OR ('.$m[1].'))';
|
|
}
|
|
return parent::statement($query,$bindings);
|
|
}
|
|
}
|