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

Fix for #100 - timestamp migrations do not work in MariaDB #112

Merged

Conversation

SOHELAHMED7
Copy link
Contributor

@SOHELAHMED7 SOHELAHMED7 commented Sep 30, 2022

Fix #100


This PR is continued from #103


This PR will:

  • change all tests to use real DB inside Docker container. All tests should run in container. Running tests outside container may fail it. Also it will avoid mocks in tests as we require separate migration code for different databases
  • change Github Action workflow to run all tests in container
  • implement x-db-type and will fix bugs related to it
  • solve issue related to timestamp/datetime in Mariadb (and possibly in MySQL). Corresponding behaviour in Pgsql is fine and should not be affected
  • add defaultValue() tests for text, json, blob, geometry for Mysql, Mariadb and Pgsql. In general make default value implementation perfect and add tests for it.
  • by default run all tests in MySQL DB
  • remove all enum and json related tests partially or completely to focus on above tasks. It will be added later in their own PR. See For ENUM colums, existing column gets an update which removes the "string type" #111 and json field related errors #109 . This tests are removed to focus on solution for above tasks. Also enum and json implementation needs to re-check as it produce errors
  • ensure all changes by @siggi-k on !112 works fine in all DB: Mysql, Mariadb, Pgsql

Sub-tasks

  • remove uuid tests from Mariadb and Mysql as it is only supported in PgSQL
  • use real DB and real Yii app in tests instead of mocks
  • add tests to check down() code in migrations for x-db-type in fresh and secondary code generation of migrations
  • refactor tests and dataprovider in tests/unit/MigrationsGeneratorTest.php
  • run all tests in Github actions inside Docker container
  • implement x-db-type works perfectly in Mariadb, Mysql and Pgsql
  • fix erroneous tests in Github actions
  • fix/adjust failing tests
  • Github actions: run all tests in containers in GA
  • support for data type with array e.g. text[] (in x-db-type)
  • as there are lot of tests are changed, add lot of tests for x-db-type, timestamp/datetime issue, enum, object issues and these all for all DBs: Pgsql, Mysql, Maridb
  • add defaultValue() tests for text, json, blob, geometry for Mysql, Mariadb and Pgsql
  • Mariadb (and possibly Mysql) timestamp issue in generated migrations issue in up() and down() code
  • resolve PR review comments from the maintainer
  • "double precision precision" issue in alterColumn()

@SOHELAHMED7 SOHELAHMED7 mentioned this pull request Oct 3, 2022
@SOHELAHMED7 SOHELAHMED7 marked this pull request as ready for review December 20, 2022 12:29
Copy link
Owner

@cebe cebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thank you very much!

I will test this branch in some projects and see if I find any issues with it. If not I'll merge it.

@SOHELAHMED7
Copy link
Contributor Author

I found a issue that is introduced by this PR. It is 'decimal' in x-db-type is detected as string in models and faker generation. It is being fixed in SOHELAHMED7#2

@SOHELAHMED7
Copy link
Contributor Author

I found a issue that is introduced by this PR. It is 'decimal' in x-db-type is detected as string in models and faker generation. It is being fixed in SOHELAHMED7#2

fixed in SOHELAHMED7@3d4d71c

Also this introduce some minor changes in models generation

'float' will be now 'double' due to compatibility with gettype function of PHP

e.g.

-  * @property float $amount amount
+ * @property double $amount amount

@cebe
Copy link
Owner

cebe commented Dec 22, 2022

Found a few more things (tested on the timestamp-enum-x-db-type-bug-fix branch):

  • Definition in schema:
       billing_type:
          type: string
          maxLength: 3
          enum:
            - CPM
            - CPL
            - CPO
            - CPC

results in the following migration (quotes are note escaped):

        $this->alterColumn('{{%campaigns}}', 'billing_type', 'enum('CPM', 'CPL', 'CPO', 'CPC') NULL DEFAULT NULL');

image

@SOHELAHMED7
Copy link
Contributor Author

For above comment; fix is already applied. Present in https://github.com/SOHELAHMED7/yii2-openapi/pull/2/files

@cebe
Copy link
Owner

cebe commented Dec 30, 2022

Thank you!

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

Successfully merging this pull request may close these issues.

timestamp migrations do not work in MariaDB
3 participants