Describe the bug
If driver option withDatetimeMicroseconds equals a true, \Cycle\Migrations\Migrator can not resolve executed migrations and attempt to apply them again.
This is because the migrator does not know that a more precise time format should be used, and the driver saves the file with the precise time.
Is this a regression?
No response
To Reproduce
Save this code into issue.php
<?php
use Cycle\Database\Config\DatabaseConfig;
use Cycle\Database\Config\SQLite\FileConnectionConfig;
use Cycle\Database\Config\SQLiteDriverConfig;
use Cycle\Database\DatabaseManager;
use Cycle\Migrations\Config\MigrationConfig;
use Cycle\Migrations\FileRepository;
use Cycle\Migrations\Migrator;
require __DIR__ . '/vendor/autoload.php';
$dbal = new DatabaseManager(new DatabaseConfig([
'default' => 'main',
'databases' => [
'main' => [
'connection' => 'main',
],
],
'connections' => [
'main' => new SQLiteDriverConfig(
connection: new FileConnectionConfig(__DIR__ . '/issue.sqlite'),
options: [
'withDatetimeMicroseconds' => true,
],
),
],
]));
$config = new MigrationConfig([
'directory' => __DIR__ . '/migrations',
'vendorDirectories' => [],
'table' => 'migrations',
'namespace' => 'Migration',
'safe' => false,
]);
$repository = new FileRepository($config);
$migrator = new Migrator($config, $dbal, $repository);
if (!$migrator->isConfigured()) {
$migrator->configure();
}
do {
$migration = $migrator->run();
} while (!is_null($migration));
create directory migrations and create new migration (for example, copy from documentation)
run
script failed =(
Expected behaviour
I expect the migration to be successful
Media prove
No response
Database
No response
Your environment
- OS: Linux Mint
- PHP: 8.3.6
- Package version: 4.2.6
Additional context
Ideally, you should be able to determine the value of the withDatetimeMicroseconds option from the driver. However, adding a method to the driver interface will break backward compatibility (if someone is using a custom driver).
Describe the bug
If driver option
withDatetimeMicrosecondsequals atrue,\Cycle\Migrations\Migratorcan not resolve executed migrations and attempt to apply them again.This is because the migrator does not know that a more precise time format should be used, and the driver saves the file with the precise time.
Is this a regression?
No response
To Reproduce
Save this code into issue.php
create directory
migrationsand create new migration (for example, copy from documentation)run
script failed =(
Expected behaviour
I expect the migration to be successful
Media prove
No response
Database
No response
Your environment
Additional context
Ideally, you should be able to determine the value of the withDatetimeMicroseconds option from the driver. However, adding a method to the driver interface will break backward compatibility (if someone is using a custom driver).