forked from cebe/yii2-openapi
-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
GIVEN
title: Company
x-table: companies
type: object
description: Database schema of a Company.
x-indexes:
- 'unique:shortName,postalCode'
properties:
id:
type: integer
readOnly: true
name:
type: string
maxLength: 64
shortName:
type: string
postalCode:
type: string
EXECUTE
rename "postalCode" to "postCode"
new schema
title: Company
x-table: companies
type: object
description: Database schema of a Company.
x-indexes:
- 'unique:shortName,postCode'
properties:
id:
type: integer
readOnly: true
name:
type: string
maxLength: 64
shortName:
type: string
postCode:
type: string
execute
./yii gii/api
ACTUAL
class m240624_100002_change_table_companies extends \yii\db\Migration
{
public function safeUp()
{
$this->addColumn('{{%companies}}', 'postCode', $this->text()->null()->defaultValue(null));
$this->dropColumn('{{%companies}}', 'postalCode');
$this->dropIndex('companies_shortName_postalCode_key', '{{%companies}}');
$this->createIndex('companies_shortName_postCode_key', '{{%companies}}', ["shortName", "postCode"], true);
}
public function safeDown()
{
$this->dropIndex('companies_shortName_postCode_key', '{{%companies}}');
$this->createIndex('companies_shortName_postalCode_key', '{{%companies}}', ["shortName", "postalCode"], true);
$this->addColumn('{{%companies}}', 'postalCode', $this->text()->null()->defaultValue(null));
$this->dropColumn('{{%companies}}', 'postCode');
}
}
EXPECTED
class m240624_100002_change_table_companies extends \yii\db\Migration
{
public function safeUp()
{
$this->dropIndex('companies_shortName_postalCode_key', '{{%companies}}');
$this->addColumn('{{%companies}}', 'postCode', $this->text()->null()->defaultValue(null));
$this->dropColumn('{{%companies}}', 'postalCode');
$this->createIndex('companies_shortName_postCode_key', '{{%companies}}', ["shortName", "postCode"], true);
}
public function safeDown()
{
$this->dropIndex('companies_shortName_postCode_key', '{{%companies}}');
$this->addColumn('{{%companies}}', 'postalCode', $this->text()->null()->defaultValue(null));
$this->dropColumn('{{%companies}}', 'postCode');
$this->createIndex('companies_shortName_postalCode_key', '{{%companies}}', ["shortName", "postalCode"], true);
}
}
BUG
safeUp: first dropIndex , and only then dropColumn
safeDown: first addColumn , and only then createIndex
Metadata
Metadata
Assignees
Labels
No labels