cycle / annotated

Schema generation using annotated entities and mappers
MIT License
23 stars 12 forks source link

Adding an index to a JTI table #45

Closed msmakouz closed 2 years ago

msmakouz commented 2 years ago

When adding an index on a child table in JTI, it tries to add to the parent table.

In the branch, I created the test.

For example, I created Entity Person:

/**
 * @Entity
 */
#[Entity]
class Person
{
    /** @Column(type="primary", name="id") */
    #[Column(type: 'primary', name: 'id')]
    protected int $foo_id;

    /** @Column(type="string") */
    #[Column(type: 'string')]
    public string $type;
}

After that, I created the Buyer entity and extended it from Person, added an index to the index_id column. But the index is trying to add to the people table, which is related to the Person entity.

/**
 * @Entity
 * @Index(columns={"index_id"}, unique=true)
 * @InheritanceJoinedTable
 */
#[Entity]
#[Index(columns: ['index_id'], unique: true)]
#[InheritanceJoinedTable]
class Buyer extends Person
{
    /** @Column(type="integer") */
    #[Column(type: 'integer')]
    private int $index_id;
}

index1