Skip to content

Wrong migratrion and factory, exactly as in #763 #768

@psalandin

Description

@psalandin
  • Laravel Version: 12.40.2
  • PHP Version: 8.4.14
  • Blueprint Version: 2.13.0 and master (downloaded now, nov 26th, 22.43 utc
  • Platform: Windows

Issue:

When building a foreign key from a line like
nazione_id: id foreign:nazione
or
nazione_id: id foreign:**nazione.id
blueprint generates a migraton line like this:
$table→foreignId('nazione_id')→constrained();
whick makes the foreign key to nazione wrong, as it gets defined on table naziones, which does not exists
And this despite the fact that the model Nazione has a meta: table: nazioe property (see below)

Moreover: one of the factories created has a wrong model reference.
As you can generate from the yaml file, there are 4 models: Nazione, Regione, Provincia and Comune.
When building then ComuneFactory class I found the line:
'provincia_id' => **Provincium**::factory(),
which is a model that does not exists

draft.yaml:

models:

  Nazione:
    meta:
      table: nazione
    codice: string:2 unique
    descrizione: string:100
    codice_iso: string:2 unique
    codice_istat: string:3 unique
    prefisso: string:5 nullable
    #attiva: unsignedTinyInteger default:1
    relationships:
      hasMany: Regione

  Regione:
    meta:
      table: regione
    codice: string:3
    descrizione: string:100
    codice_nazione: string:2
    nazione_id: id foreign:nazione
    ripart_geografica: string:100 nullable
    #attiva: unsignedTinyInteger default:1
    indexes:
      - unique: nazione_id, codice
    relationships:
      belongsTo: Nazione
      hasMany: Provincia

  Provincia:
    meta:
      table: provincia
    codice: string:3
    descrizione: string:100
    sigla: string:2 nullable
    regione_id: id foreign:regione.id
    indexes:
      - unique: regione_id, codice
    relationships:
      belongsTo: Regione
      hasMany: Comune

  Comune:
    meta:
      table: comune
    codice: string:3
    descrizione: string:100
    soppresso: unsignedTinyInteger default:0
    provincia_id: id foreign:provincia
    cod_catasto: string:4 nullable
    abilitato: unsignedTinyInteger default:0
    iscr_abilitata: unsignedTinyInteger default:0
    mobile: unsignedTinyInteger default:0
    indexes:
      - unique: provincia_id, codice
      - index: cod_catasto
    relationships:
      belongsTo: Provincia
      hasMany: Istituto

seeders: Nazione, Regione, Provincia, Comune

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions