phalcon / migrations

Generate or migrate database changes via migrations.
https://docs.phalcon.io/latest/en/db-migrations
BSD 3-Clause "New" or "Revised" License
28 stars 23 forks source link

[PGsql] Index should be primary key , instead of Normal Index #112

Closed yassinrais closed 3 years ago

yassinrais commented 3 years ago

Table company

 'indexes' => [
                    new Index('pk_company_id_0', ['id'], 'PRIMARY'),
                    new Index('unq_company_country_id', ['country_id', 'name'] ,'UNIQUE')
                ],

After runing migration image

yassinrais commented 3 years ago

Oh , my bad it was

PRIMARY KEY

Instead of only

PRIMARY
yassinrais commented 3 years ago

But the migration generator , does not put any option of indexing key he just let it empty like

 'indexes' => [
      new Index('pk_company_id_0', ['id'], ''),
      new Index('unq_company_country_id', ['country_id', 'name'] ,'')
  ],
BeMySlaveDarlin commented 3 years ago

I will check it soon and put a resolution.

BeMySlaveDarlin commented 3 years ago

First of all, pgsql adapter was hard locked for index definition creation. Using pg you should not have 'indexes' block. But you got that definition array just because your adapter in config file was Pascal case, so adapter check failed and indexes block was generated.

Made adapter check case insensitive and fixed indexes type definition.

Another point - in 'indexes' definition you cant have Primary index. That index is defined via Column definition by using option 'primary' => true.