-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
PHP Version
8.4
CodeIgniter4 Version
4.6.1
CodeIgniter4 Installation Method
Composer (as dependency to an existing project)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
SQLServer 2019
What happened?
When running migrations with CodeIgniter 4, the framework does not place a lock at the beginning of the migration process. Instead, it only inserts a record into the migrations table at the end of each migration. This means that if multiple processes (for example, multiple pods in Kubernetes) start migrations at the same time, there is a risk that the same migration will be executed concurrently, which can cause conflicts or race conditions.
Steps to Reproduce
- Deploy your CodeIgniter 4 application in an environment where multiple instances (pods/containers) can start at the same time.
- Configure each instance to run migrations automatically on startup (e.g., via an initContainer or entrypoint script).
- Start multiple instances simultaneously.
Expected Output
Only one instance should be able to run the migration at a time. The framework should place a lock at the beginning of the migration process to prevent concurrent execution, similar to how Doctrine Migrations (Symfony) works. This would avoid race conditions and ensure that migrations are applied safely, even in distributed environments.
Anything else?
No response