Skip to content

The migrator modifies native SQL #336

@DisboardTetta

Description

@DisboardTetta

Description

Let's look at a snippet from my migration:

$b->createTable(..., [
       <...>
            'owner_user_id' => 'bigint REFERENCES users(id) ON DELETE SET NULL', <...>
        ]);

For some reason, I get the following error:

SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ","     
  LINE 9: ...ner_user_id" bigint NULL REFERENCES users(id) ON DELETE SET, 

But if we look closely at the resulting script, or rather, a portion of it, for some unknown reason, the part with NULL has simply disappeared, resulting in a dangling SET:

  The SQL being executed was: CREATE TABLE <...>                                                                         
        "owner_user_id" bigint NULL REFERENCES users(id) ON DELETE SET,                         
        "uploaded_at" <...>
  )   

Package version

2.0.1

PHP version

8.4.18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions