mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 08:58:35 +00:00
Fix getting function for rule
This commit is contained in:
parent
04009699eb
commit
a3722f53a5
3 changed files with 22 additions and 12 deletions
|
|
@ -28,6 +28,11 @@ abstract class Migration
|
|||
|
||||
protected Database $dbForPlatform;
|
||||
|
||||
/**
|
||||
* @var callable(Document): Database
|
||||
*/
|
||||
protected mixed $getProjectDB;
|
||||
|
||||
protected PDO $pdo;
|
||||
|
||||
/**
|
||||
|
|
@ -115,11 +120,17 @@ abstract class Migration
|
|||
* @param Database $dbForPlatform
|
||||
* @return self
|
||||
*/
|
||||
public function setProject(Document $project, Database $dbForProject, Database $dbForPlatform): self
|
||||
public function setProject(
|
||||
Document $project,
|
||||
Database $dbForProject,
|
||||
Database $dbForPlatform,
|
||||
?callable $getProjectDB = null
|
||||
): self
|
||||
{
|
||||
$this->project = $project;
|
||||
$this->dbForProject = $dbForProject;
|
||||
$this->dbForPlatform = $dbForPlatform;
|
||||
$this->getProjectDB = $getProjectDB;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -348,16 +348,15 @@ class V23 extends Migration
|
|||
->setAttribute('search', \implode(' ', [$document->getId(), $document->getAttribute('domain', '')]));
|
||||
|
||||
if ($deploymentResourceType === 'function') {
|
||||
if ($this->project->getInternalId() !== 'console') {
|
||||
$function = $this->dbForProject->getDocument('functions', $resourceId);
|
||||
$project = $this->dbForProject->getDocument('projects', $document->getAttribute('projectId'));
|
||||
$dbForOwnerProject = ($this->getProjectDB)($project);
|
||||
$function = $dbForOwnerProject->getDocument('functions', $resourceId);
|
||||
$deploymentId = $function->getAttribute('deployment', $function->getAttribute('deploymentId', $document->getAttribute('deploymentId')));
|
||||
$deploymentInternalId = $function->getAttribute('deploymentInternalId', $document->getAttribute('deploymentInternalId', ''));
|
||||
|
||||
$deploymentId = $function->getAttribute('deployment', $document->getAttribute('deploymentId', ''));
|
||||
$deploymentInternalId = $function->getAttribute('deploymentInternalId', $document->getAttribute('deploymentInternalId', ''));
|
||||
|
||||
$document
|
||||
->setAttribute('deploymentId', $deploymentId)
|
||||
->setAttribute('deploymentInternalId', $deploymentInternalId);
|
||||
}
|
||||
$document
|
||||
->setAttribute('deploymentId', $deploymentId)
|
||||
->setAttribute('deploymentInternalId', $deploymentInternalId);
|
||||
}
|
||||
break;
|
||||
case 'variables':
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class Migrate extends Action
|
|||
|
||||
try {
|
||||
$migration
|
||||
->setProject($project, $dbForProject, $dbForPlatform)
|
||||
->setProject($project, $dbForProject, $dbForPlatform, $getProjectDB)
|
||||
->setPDO($register->get('db', true))
|
||||
->execute();
|
||||
} catch (\Throwable $th) {
|
||||
|
|
@ -89,7 +89,7 @@ class Migrate extends Action
|
|||
|
||||
try {
|
||||
$migration
|
||||
->setProject($console, $getProjectDB($console), $dbForPlatform)
|
||||
->setProject($console, $getProjectDB($console), $dbForPlatform, $getProjectDB)
|
||||
->setPDO($register->get('db', true))
|
||||
->execute();
|
||||
} catch (\Throwable $th) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue