Welcome Guest, Not a member yet? Register   Sign In
Certain migration timestamp formats not working
#1
Bug 
(This post was last modified: 11-26-2023, 12:16 PM by Muzikant.)

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
Reply
#2

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/CodeIgnit...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?
Reply
#3

(This post was last modified: 01-13-2023, 02:38 AM by Muzikant.)

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.
Reply
#4

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

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

(This post was last modified: 02-02-2023, 08:51 AM by Muzikant.)

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB