Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Can not define index on relation id #168

Closed
cebe opened this issue May 2, 2024 · 0 comments · Fixed by SOHELAHMED7/yii2-openapi#35 or #171
Closed

Can not define index on relation id #168

cebe opened this issue May 2, 2024 · 0 comments · Fixed by SOHELAHMED7/yii2-openapi#35 or #171
Labels
bug Something isn't working

Comments

@cebe
Copy link
Owner

cebe commented May 2, 2024

components:
  schemas:
    Webhook:
      x-indexes:
        - 'unique:user_id,name' # references implicit ID
      type: object
      description: example for x-fk-column-name
      properties:
        id:
          type: integer
        name:
          type: string
        user:
          $ref: '#/components/schemas/User' # this will automatically create `user_id` column

results in:

cebe\yii2openapi\lib\exceptions\InvalidDefinitionException: Invalid index definition - property user_id not declared

/app/src/lib/AttributeResolver.php:441
/app/src/lib/AttributeResolver.php:124
/app/src/lib/SchemaToDatabase.php:93
/app/src/generator/ApiGenerator.php:471

I'll submit a failing test case.

@cebe cebe added the bug Something isn't working label May 2, 2024
SOHELAHMED7 added a commit to SOHELAHMED7/yii2-openapi that referenced this issue May 7, 2024
…elation-id

Fix cebe#168: Cannot define index on relation
@cebe cebe closed this as completed in #171 May 7, 2024
cebe added a commit that referenced this issue May 7, 2024
Fix #168

Failing test: https://github.com/cebe/yii2-openapi/pull/169/files

PR in fork: SOHELAHMED7#35

Also add other enhancements and fix bugs related to [index and foreign
key order](https://stackoverflow.com/a/8482400) in migrations.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
1 participant