mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-07-10 23:17:08 -04:00
Fixed bug in CI4 conversion functionality
The bug was causing one row to be inserted because the function was being called twice
This commit is contained in:
committed by
Steve Ireland
parent
caf31185b0
commit
98d19040c7
@@ -25,6 +25,8 @@ class Login extends BaseController
|
||||
? config('OSPOS')->settings['gcaptcha_enable']
|
||||
: false;
|
||||
|
||||
$migration->migrate_to_ci4();
|
||||
|
||||
$data = [
|
||||
'has_errors' => false,
|
||||
'is_latest' => $migration->is_latest(),
|
||||
|
||||
@@ -31,13 +31,12 @@ class Load_config
|
||||
$config = config('OSPOS');
|
||||
$appconfig = model(Appconfig::class);
|
||||
|
||||
$config->settings['application_version'] = $migration->get_current_version();
|
||||
|
||||
if (!$migration->is_latest())
|
||||
if (!$migration->is_latest())
|
||||
{
|
||||
$this->session->destroy();
|
||||
}
|
||||
|
||||
$config->settings['application_version'] = $migration->get_current_version();
|
||||
foreach($appconfig->get_all()->getResult() as $app_config)
|
||||
{
|
||||
$config->settings[$app_config->key] = $app_config->value;
|
||||
|
||||
@@ -10,19 +10,13 @@ class MY_Migration extends MigrationRunner
|
||||
{
|
||||
public function is_latest(): bool
|
||||
{
|
||||
$ci3_migrations_version = $this->ci3_migrations_exists();
|
||||
if($ci3_migrations_version)
|
||||
{
|
||||
$this->migrate_to_ci4_migrations($ci3_migrations_version);
|
||||
}
|
||||
|
||||
$latest_version = $this->get_latest_migration();
|
||||
$current_version = $this->get_current_version();
|
||||
|
||||
return $latest_version == $current_version;
|
||||
return $latest_version === $current_version;
|
||||
}
|
||||
|
||||
public function get_latest_migration(): string
|
||||
public function get_latest_migration(): int
|
||||
{
|
||||
$migrations = $this->findMigrations();
|
||||
return basename(end($migrations)->version);
|
||||
@@ -33,7 +27,7 @@ class MY_Migration extends MigrationRunner
|
||||
*
|
||||
* @return string The version number of the last successfully run database migration.
|
||||
*/
|
||||
public function get_current_version(): string
|
||||
public function get_current_version(): int
|
||||
{
|
||||
if($this->db->tableExists('migrations'))
|
||||
{
|
||||
@@ -45,6 +39,15 @@ class MY_Migration extends MigrationRunner
|
||||
return '';
|
||||
}
|
||||
|
||||
public function migrate_to_ci4(): void
|
||||
{
|
||||
$ci3_migrations_version = $this->ci3_migrations_exists();
|
||||
if($ci3_migrations_version)
|
||||
{
|
||||
$this->migrate_table($ci3_migrations_version);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a ci3 version of the migrations table exists
|
||||
*
|
||||
@@ -62,7 +65,7 @@ class MY_Migration extends MigrationRunner
|
||||
return false;
|
||||
}
|
||||
|
||||
private function migrate_to_ci4_migrations(string $ci3_migrations_version)
|
||||
private function migrate_table(string $ci3_migrations_version)
|
||||
{
|
||||
$this->convert_table();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user