tattersoftware / codeigniter4-schemas

Database schema management, for CodeIgniter 4
MIT License
22 stars 10 forks source link

After upgrading to CI4 v4.3.0, the generated schema is broken and can't be used with relations. #43

Open jozefrebjak opened 1 year ago

jozefrebjak commented 1 year ago

It appears to be a foreign key issue.

For example schema generated with Shield installed before anad after 4.3.0 upgrade.

CleanShot 2023-01-10 at 14 57 02

My troubleshooting:

in vendor/tatter/schemas/src/Structures/ForeignKey.php

I added dd to the end of __contstruct method and in before 4.3.0 it returns

Tatter\Schemas\Structures\ForeignKey (5) (
    public 'constraint_name' -> string (33) "auth_groups_users_user_id_foreign"
    public 'table_name' -> string (17) "auth_groups_users"
    public 'column_name' -> string (7) "user_id"
    public 'foreign_table_name' -> string (5) "users"
    public 'foreign_column_name' -> string (2) "id"
)

and after

Tatter\Schemas\Structures\ForeignKey#170 (8) (
    public 'constraint_name' -> string (33) "auth_groups_users_user_id_foreign"
    public 'table_name' -> string (17) "auth_groups_users"
    public 'column_name' -> array (1) [
        0 => string (7) "user_id"
    ]
    public 'foreign_table_name' -> string (5) "users"
    public 'foreign_column_name' -> array (1) [
        0 => string (2) "id"
    ]
    public 'on_delete' -> string (7) "CASCADE"
    public 'on_update' -> string (8) "RESTRICT"
    public 'match' -> string (4) "NONE"
)

This issue is there because of

Foreign Key Data

NathanAllmeida commented 1 year ago

same problem this; @MGatner Do you have plans for implementation?

MGatner commented 1 year ago

@jozefrebjak has a fix - I just haven't had a chance to fix the pipeline errors. You can apply his PR locally or someone could get the GitHub Actions workflows updated and working.