puyu-pe / sipro-internal-api-clone-db
Shared clone/export/import utilities for SIPRO internal API adapters.
Package info
github.com/puyu-pe/sipro-internal-api-clone-db
pkg:composer/puyu-pe/sipro-internal-api-clone-db
Requires
- php: >=8.1
- puyu-pe/sipro-internal-api-core: ^2.0.0
Requires (Dev)
- phpunit/phpunit: ^10.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-12 23:10:07 UTC
README
Version 2.0.0 provides framework-independent export/import utilities for
PHP >=8.1 and puyu-pe/sipro-internal-api-core:^2.0.0.
composer require puyu-pe/sipro-internal-api-clone-db:^2.0
The package is verified on PHP 8.1–8.4, including real database round trips. It does not require a particular framework, PHPUnit, or a specific database connection name in consuming applications. PHP and core requirements reflect the runtime features used; no platform requirements need to be ignored.
Application adapter
Extend Adapters\AbstractTenantCloneAdapter and implement its database resolution,
connection, filesystem and binary hooks. Configure mysql, mysqldump, gzip,
and Bash with pipefail on the host that executes export/import.
Canonical signatures include:
protected function resolveTenantDatabase( string $pathResolveKey, string $payloadResolveKey, string $projectCode ): string; protected function loadTenantRecord(string $resolveKey): ?object;
Public calls use exportTenant(resolveKey: ..., dto: ...) and
importTenant(resolveKey: ..., dto: ...). DTOs expose resolveKey. The base
adapter checks path/body identity before resolving a database; application hooks
verify project ownership. Helpers throw core InternalApiException values.
Import verifies a SHA-256 digest and a real path inside dumpDir() before creating
or restoring a database. Checksums are lowercase 64-character hexadecimal strings,
without a sha256: prefix. SQL dumps are trusted administrative artifacts supplied
by the authenticated control plane; application-specific credential clearing is
the responsibility of the consuming application.
Upgrade from 1.x
Update public and protected named parameters, DTO property access, response
constructors, and exception imports together. No aliases for legacy tenant keys
are provided. Both Laravel and CI3 2.0 can consume this adapter through core's
TenantCloneAdapterInterface.
Tests
composer test runs isolated filesystem/command tests. Set SIPRO_TEST_DB_HOST
to a disposable MariaDB instance to run real dump/restore tests. That fixture uses
root with an empty password on an isolated Docker network and creates only random
sipro_* databases, which it removes in finally.
The workspace's verification runner also executes this adapter through real
Laravel and CI3 HTTP entrypoints. Contract resources are under
resources/contracts/v2/ and are test fixtures, not production adapters.