yii2-openapi icon indicating copy to clipboard operation
yii2-openapi copied to clipboard

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

Open SOHELAHMED7 opened this issue 2 years ago • 2 comments

Ensure its down code have correct migrations code to create table

SOHELAHMED7 avatar Jan 19 '23 15:01 SOHELAHMED7

Stub (and partially failing test ) is present in c859fea47314cf491390e25a3ab8f193f02d3602

SOHELAHMED7 avatar Jan 19 '23 15:01 SOHELAHMED7

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

cebe avatar Jan 27 '23 11:01 cebe

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.

SOHELAHMED7 avatar May 31 '24 05:05 SOHELAHMED7