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

Bug with "format: date-time" #161

Open
siggi-k opened this issue Feb 5, 2024 · 1 comment · May be fixed by SOHELAHMED7/yii2-openapi#38
Open

Bug with "format: date-time" #161

siggi-k opened this issue Feb 5, 2024 · 1 comment · May be fixed by SOHELAHMED7/yii2-openapi#38

Comments

@siggi-k
Copy link
Contributor

siggi-k commented Feb 5, 2024

Initial

schema.yaml

openapi: 3.0.3
# Edit this schema and start your project
# This is sample schema
# To generate code which is based on this schema
# run commands mentioned Development section in README.md file
info:
  title: 'Proxy-Service'
  description: ""
  version: 1.0.0
  contact:
    name: '...'
    email: you@example.com
servers:
  - url: 'http://localhost:9937'
    description: 'Local Dev API'
security:
  - BasicAuth: []
components:
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
  schemas:

    Subscription:
      type: object
      required:
        - id
      properties:
        id:
          type: integer
        start:
          type: string
          format: date-time
        end:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
          readOnly: True
        updatedAt:
          type: string
          format: date-time
          readOnly: true

Reproduction steps

./yii gii/api
./yii migrate

#again
./yii gii/api

Expected
No more migration

Result

<?php

/**
 * Table for Subscription
 */
class m240205_140005_change_table_subscriptions extends \yii\db\Migration
{
    public function up()
    {
        $this->alterColumn('{{%subscriptions}}', 'start', $this->timestamp()->null()->defaultValue(null));
        $this->alterColumn('{{%subscriptions}}', 'end', $this->timestamp()->null()->defaultValue(null));
        $this->alterColumn('{{%subscriptions}}', 'createdAt', $this->timestamp()->null()->defaultValue(null));
        $this->alterColumn('{{%subscriptions}}', 'updatedAt', $this->timestamp()->null()->defaultValue(null));
    }

    public function down()
    {
        $this->alterColumn('{{%subscriptions}}', 'updatedAt', $this->timestamp()->null()->defaultValue(null));
        $this->alterColumn('{{%subscriptions}}', 'createdAt', $this->timestamp()->null()->defaultValue(null));
        $this->alterColumn('{{%subscriptions}}', 'end', $this->timestamp()->null()->defaultValue(null));
        $this->alterColumn('{{%subscriptions}}', 'start', $this->timestamp()->null()->defaultValue(null));
    }
}

@SOHELAHMED7
Copy link
Contributor

I am not able to reproduce this issue.

I attempted to create failing test for PgSQL:

// above attempt yields this migration which is correct and expected
<?php

/**
 * Table for Subscription
 */
class m200000_000000_change_table_subscriptions extends \yii\db\Migration
{
    public function safeUp()
    {
        $this->addColumn('{{%subscriptions}}', 'updatedAt2', $this->timestamp()->null()->defaultValue(null));
    }

    public function safeDown()
    {
        $this->dropColumn('{{%subscriptions}}', 'updatedAt2');
    }
}

Please provide following details:

  • which database do you use
  • can you give create table statement of your existing (applied migration) table (e.g. subscriptions table)

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants