You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virt/web/tests/CloudSetupReferralMigration...

32 lines
1.4 KiB
PHP

<?php
// Clean-break setup imports final schemas and never upgrades an old database.
$root = dirname(__DIR__);
$setup = file_get_contents($root . '/app/Command/CloudSetup.php');
$cloud = file_get_contents($root . '/sql/cloud.sql');
$base = file_get_contents($root . '/sql/ss.sql');
if (!is_string($setup) || !is_string($cloud) || !is_string($base)) {
throw new RuntimeException('Cannot read setup schema sources.');
}
$assert = static function ($condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$assert(str_contains($setup, "self::schema('cloud.sql')")
&& str_contains($setup, "self::schema('cloud_log.sql')"),
'cloudInit no longer initializes the final business and log schemas.');
$assert(!preg_match('/\bfunction\s+(?:upgrade|migrate|importLegacy)\b/i', $setup)
&& !preg_match('/\b(?:ALTER|DROP|RENAME)\s+TABLE\b/i', $cloud)
&& !str_contains($setup, "self::schema('migration")
&& !str_contains($setup, 'Schema::table('),
'cloudInit retained an old-database compatibility or destructive path.');
$assert(str_contains($base, 'CREATE TABLE `referral_code_generation_locks`')
&& str_contains($base,
'INSERT INTO `referral_code_generation_locks` (`id`) VALUES (1)'),
'Fresh base schema is missing the referral generation lock.');
echo "Cloud setup clean-break schema contract checks passed.\n";