mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-03 23:01:50 -04:00
fix: check for core tables not migrations table in initial migration (#4447)
When tests use refresh=true, CodeIgniter creates migrations table first, so listTables() was returning that table and skipping initial schema. Now checks for actual application tables (app_config, items, etc).
This commit is contained in:
@@ -17,13 +17,19 @@ class Migration_Initial_Schema extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Check if database already has tables (existing install)
|
||||
// Check if core application tables exist (existing install)
|
||||
// Note: migrations table may exist even on fresh DB due to migration tracking
|
||||
$tables = $this->db->listTables();
|
||||
|
||||
if (!empty($tables)) {
|
||||
// Database already populated - skip initial schema
|
||||
// This is an existing installation upgrading from older version
|
||||
return;
|
||||
// Check for a core application table, not just migrations table
|
||||
foreach ($tables as $table) {
|
||||
// Strip prefix if present for comparison
|
||||
$tableName = str_replace($this->db->getPrefix(), '', $table);
|
||||
if (in_array($tableName, ['app_config', 'items', 'employees', 'people'])) {
|
||||
// Database already populated - skip initial schema
|
||||
// This is an existing installation upgrading from older version
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fresh install - load initial schema
|
||||
|
||||
Reference in New Issue
Block a user