cebe / yii2-openapi

REST API application generator for Yii2, openapi 3.0 YAML -> Yii2
MIT License
130 stars 23 forks source link

Create migration for drop table if a entire schema is deleted from OpenAPI spec #132

Closed SOHELAHMED7 closed 5 months ago

SOHELAHMED7 commented 1 year ago

Also ensure its down code have correct migrations code to create table

SOHELAHMED7 commented 1 year ago

Stub (and partially failing test ) is present in c859fea47314cf491390e25a3ab8f193f02d3602

cebe commented 1 year ago

I should be possible to disable this feature to allow having tables in the same database that are not managed by yii2-openapi.

SOHELAHMED7 commented 5 months ago

I am going to design this as:

x-delete-tables root key (having array value). If a schema is removed then its table should be dropped. In order to create migration for it, table name (which correspond to schema) should be added to x-delete-tables.

This is designed like because often database is used by several teams/individuals and if a team/individual does not have to deal with OpenAPI spec then they are not needed to touch spec file. Only the ones who are dealing with spec should worry about dropping the table of schema which is entirely removed.

Example:

openapi: "3.0.0"

info:
  version: 1.0.0
  title: 132_create_migration_for_drop_table \#132

x-delete-tables: 
  - table_1
  - table_2

paths:
  /:
    get:
      summary: List
      operationId: list
      responses:
        '200':
          description: The information
...

So if a schema is removed, one must put its table name in x-delete-tables to create its drop migrations.