yii2-openapi
yii2-openapi copied to clipboard
timestamp migrations do not work in MariaDB
Customer:
description: customer is the one that orders a campaign
type: object
required:
- id
- name
- created_at
properties:
id:
type: integer
name:
type: string
maxLength: 100
created_at:
type: string
format: datetime
nullable: false
x-db-type: datetime
default: CURRENT_TIMESTAMP
updated_at:
type: string
format: datetime
default: null
nullable: true
x-db-type: datetime
generates a migration:
class m220524_140002_change_table_customers extends \yii\db\Migration
{
public function up()
{
$this->alterColumn('{{%customers}}', 'created_at', $this->timestamp()->notNull()->defaultExpression("CURRENT_TIMESTAMP"));
}
public function down()
{
$this->alterColumn('{{%customers}}', 'created_at', $this->timestamp()->notNull()->defaultExpression("CURRENT_TIMESTAMP"));
}
}
similar behavior for ENUM colums, existing column gets an update which removes the "string type":
properties:
system:
type: string
maxLength: 10
enum:
- mail
- test
- other
generates:
class m220524_140005_change_table_mailings extends \yii\db\Migration
{
public function up()
{
$this->alterColumn('{{%mailings}}', 'system', $this->notNull());
}
public function down()
{
$this->alterColumn('{{%mailings}}', 'system', $this->string(10)->notNull());
}
}
x-db-type: datetime
this should explicitly generate "datetime" type and not "timestamp".
Fields with json type also create error like as in enum
Also there are separate errors related json. It will require separate issue.
This issue can be closed.