Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining size in some entities causes new migration every time you run diff #2000

Open
profuel opened this issue Apr 10, 2024 · 0 comments
Open

Comments

@profuel
Copy link

profuel commented Apr 10, 2024

There's a closed report here: #1031
Though I'm sure that please remove size is not a good solution, since not every person can find this thread and learn that some sizes are default and due to a specific behavior of the compare tool, migrations are produced.

To raise a degree of the issue, we faced a complete downtime of the system, when the migration:

ALTER TABLE product CHANGE custom_id custom_id INTEGER;

since the table contains 100 M lines.

Other cases, causing permanent migration, please see table definition (all in one)

    <table name="brand_slug" idMethod="native" allowPkInsert="true">
        <column name="id_brand_slug" type="INTEGER" primaryKey="true" autoIncrement="true"/>
        <column name="slug" type="LONGVARCHAR" required="true"/>
        <column name="price" type="INTEGER" size="11" required="true"/>
        <column name="created_at" type="TIMESTAMP" size="6" required="true"/>

        <index name="index-brand_slug-slug">
            <index-column name="slug"/>
        </index>
    </table>

Please copy schema, generate diff and apply changes to the DB.
Then just generate diff again.
I'm getting:

 DROP INDEX `index-brand_slug-slug` ON `brand_slug`;
 ALTER TABLE `brand_slug`
  CHANGE `created_at` `created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CHANGE `price` `price` INTEGER(11) NOT NULL;
 CREATE INDEX `index-brand_slug-slug` ON `brand_slug` (`slug`);

My ideas of the way how to fix this:

  1. fail generation of the diff/schema - if the size is wrongly specified.
  2. ignore wrongly specified sizes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant