another editing installation

This commit is contained in:
Flatlogic Bot 2026-05-02 18:24:06 +00:00
parent d746b6aa45
commit 20a9c1bb12
3 changed files with 30 additions and 2 deletions

View File

@ -43,7 +43,6 @@ return [
'20260221_fix_pos_invoices_columns.sql',
'20260221_fix_supplier_foreign_keys.sql',
'20260318_add_outlet_id_to_purchases.sql',
'20260318_create_outlets_table.sql',
'20260318_multi_outlet_schema.sql',
'20260318_local_definitions.sql',
'20260318_user_outlets_table.sql',

View File

@ -0,0 +1,18 @@
-- Ensure the default outlet exists for installs created from complete_schema.sql snapshots.
-- Fresh installs can otherwise miss outlet ID 1 if the outlet seed migration was marked as already executed.
CREATE TABLE IF NOT EXISTS `outlets` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`address` text DEFAULT NULL,
`phone` varchar(50) DEFAULT NULL,
`status` enum('active','inactive') DEFAULT 'active',
`created_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `outlets` (`id`, `name`, `address`, `phone`, `status`, `created_at`)
SELECT 1, 'Main Outlet', 'Head Office', '', 'active', NOW()
WHERE NOT EXISTS (
SELECT 1 FROM `outlets` WHERE `id` = 1
);

View File

@ -103,6 +103,16 @@ function isLegacyNumberedSnapshotMigrationFile(string $filePath): bool
return preg_match('/^\d{1,7}_/', basename($filePath)) === 1;
}
function isInstallBaselineExcludedMigrationFile(string $filePath): bool
{
// These migrations include required default data that is not embedded in complete_schema.sql.
// Keep them out of the install baseline so fresh installs still execute them.
return in_array(basename($filePath), [
'20260318_create_outlets_table.sql',
'20260502_zzzz_default_outlet_guard.sql',
], true);
}
function fetchInstallBaselineMigrationNames(): array
{
$files = array_merge(
@ -111,7 +121,8 @@ function fetchInstallBaselineMigrationNames(): array
);
$files = array_values(array_filter($files, static function (string $filePath): bool {
return !isLegacyNumberedSnapshotMigrationFile($filePath);
return !isLegacyNumberedSnapshotMigrationFile($filePath)
&& !isInstallBaselineExcludedMigrationFile($filePath);
}));
usort($files, static function (string $left, string $right): int {