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
Bigint unsigned ids #7081
Bigint unsigned ids #7081
Conversation
This PR has no migration. I'm not aware of such decision, but the release leader can decide about the faith of each PR. I have no problem moving it to 2.16.0. |
Yeah i meant it because of:
I thought we talked about it. But I feel confortable giving this responsibility to the release leader :D |
Yep, that's the reason this PR does not contain migration and it will be applicable only for new installations. The migration process for old installations is described there as well if someone needs it now. |
Tested and works properly, also code reviewed and running in our production environment. 2.16 or whatever folks decide is fine. |
If I call app/console doctrine:schema:update --dump-sql
|
@escopecz was able to reproduce so we'll revert. It was meant for new installations to prepare for large amount of data. But a migration is ginormous so opted not to do it. |
Is there a way to modify the schema for new installations without causing migrations for existing ones? |
The schema for new installations is generated from the Doctrine entities. In theory, users shouldn't need anything else to migrate from one version to another than the That's what I was aiming for with this PR. Sadly, in practice we sometimes need the |
Ok, but I think the issue @kuzmany noted was not during --dump-sql but during execution of that SQL. When running such alterations you must run Edit: I stand corrected, apparently the order of the alter statements also needs to be more specific than DBAL understands. Hmm. |
Good point. It's with the |
I'd like to, but there is no conceivable way to make the You have to to manually remove those foreign key constraints, then run the SQL, then recreate those foreign key constraints. Otherwise you get errors like this:
I'm running out of ideas on this :( |
Can we also define custom FK names, so that those old ones are removed, and then recreated? |
We have a method somewhere that generates the FK names the way Doctrine does so the I plan to make this change for M3 which may be the best opportunity for this. Users may expect more tedious migration coming from M2 to M3. |
That makes the most sense. I'll abandon my PR and continue to make these migrations manually for now. Please also include the ip_addresses table ID. |
Please be sure you are submitting this against the staging branch.
Description:
We noticed that some of Mautic instances we manage has quite high autoincrements on statistical database tables already and we calculated that we have very few months until they overflow.
This PR changes all IDs to be INT UNSIGNED which will double the max INT limit. It also introduces new BIGINT UNSIGNED columns which are used on selected statistical tables.
I made a little research as I realized that PHP has limits on integers as well. It's defined by constant:
PHP_INT_MAX
Source: http://php.net/manual/en/reserved.constants.php
Note: 9223372036854775807 ~= 2^63
Mysql:
INT SIGNED
max = 2147483647 < that's what we have nowBIGINT SIGNED
max = 2^63BIGINT UNSIGNED
max = 2^64 < that's what we wantSource: https://dev.mysql.com/doc/refman/5.7/en/integer-types.html
So what we are using now is fine and will work on 32 bit processors for the whole range. If we switch to
BIGINT SIGNED
then 32 bit processors would work only to its limits. 64 bit processors the whole range. ForBIGINT UNSIGNED
even 64 bit processors won't be enough and we'll have to convert int to string which would cause troubles in many places within Mautic.I consulted this with our team and we decided to switch to
BIGINT UNSIGNED
anyway as we should not get over 2^63. And users running Mautic on 32 bit systems should not get to its limits too as we suppose those will be small instances.This changes will appear on new installations only. This PR does not contain migrations of current tables on purpose. Those migrations would be massive as MySql will create a copy of the current stat tables to alter the column type. This can lead to big troubles during migrations of big-size databases such as run out of disk space or overloading database with incoming traffic while the tables are locked.
Not only ID columns will be affected by this change. Doctrine is more clever. It changes types also to all foreign key columns. So when I changed leads.id to BIGINT then all tables containing lead_id column will be re-typed too. So it will affect majority of the tables anyway.
If your instance is getting close to the INT limit then follow these steps to migrate:
app/console doctrine:schema:update --dump-sql | grep BIGINT
Steps to reproduce the bug:
Steps to test this PR: