CodeIgniter Forums
Certain migration timestamp formats not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Certain migration timestamp formats not working (/showthread.php?tid=85981)



Certain migration timestamp formats not working - Muzikant - 12-28-2022

Hi there.


On my GNU/Linux machine I have installed XAMPP 8.1.12 and a fresh Composer installation of CodeIgniter 4.2.11 (both latest to this moment). I am successfully connected to the database.

There is a timestamp format setting in app/Config/Migrations.php . The default setting works fine:
PHP Code:
public $timestampFormat 'Y-m-d-His_'

If I change the format in a way that "His" have characters between the letters, it will not find any migration:
PHP Code:
public $timestampFormat 'Y-m-d-H-i-s_'

Could anyone confirm this bug? I am pretty sure it is not a feature. Wink


RE: Certain migration timestamp formats not working - kenjis - 12-28-2022

It might be a bug, but seems a specification.
In short, migration only supports filenames with regex /^\d{4}[_-]?\d{2}[_-]?\d{2}[_-]?\d{6}_(\w+)$/.

See https://codeigniter4.github.io/CodeIgniter4/dbmgmt/migration.html#migration-file-names
It does not say that the migration supports filename like Y-m-d-H-i-s_.

By the way, why do you want to change the filename format like that?


RE: Certain migration timestamp formats not working - Muzikant - 12-28-2022

Thank you for your answer, I understand. I was experimenting with it because the default setting does not fit to my OCD. It is not crucial. I found a bug and reported it, that is it.


RE: Certain migration timestamp formats not working - Mni.day - 12-28-2022

Looks like conflict a internal validation and public property for custom format.


RE: Certain migration timestamp formats not working - kenjis - 12-28-2022

The doc comment is not good.
I sent a PR to fix it. https://github.com/codeigniter4/CodeIgniter4/pull/7033


RE: Certain migration timestamp formats not working - Muzikant - 02-02-2023

I do not want to create new topic just for this. Used CodeIgniter 4.3.1 and PHP 8.2.0 through XAMPP.

I ran following commands:
Code:
composer create-project codeigniter4/appstarter test
cd test
php spark make:migration Test
php spark migrate:status

The last command output:
Code:
CodeIgniter v4.3.1 Command Line Tool - Server Time: 2023-02-02 15:39:50 UTC+00:00
[CodeIgniter\Database\Exceptions\DatabaseException]
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
at SYSTEMPATH/Database/BaseConnection.php:645

The problem is, that the database is not connected. An output does not tell anything about it.