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

Update docs on migrations #34

Open
RCheesley opened this issue Feb 23, 2021 · 2 comments
Open

Update docs on migrations #34

RCheesley opened this issue Feb 23, 2021 · 2 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@RCheesley
Copy link
Sponsor Member

Per the comment in mautic/mautic#9709 (comment) we should update the docs to include instructions for new migrations changing schema introduced in M2 to account for the fact that it was decided that we would not introduce a migration to migrate all signed integers to unsigned because the migration would be massive.

Such migrations should check to see if the other side of the constraint is signed or not (such as the one introduced in #9544). For example, migration Version20210104171005 would need something like this (not tested)

    $categoryIdColumn =  $schema->getTable("{$this->prefix}categories")->getColumn('id');
    if ($categoryIdColumn->getUnsigned()) {
        $this->addSql("ALTER TABLE {$this->prefix}lead_lists ADD category_id INT UNSIGNED DEFAULT NULL");
    } else {
        $this->addSql("ALTER TABLE {$this->prefix}lead_lists ADD category_id INT DEFAULT NULL");
    } 
@RCheesley RCheesley added good first issue Good for newcomers help wanted Extra attention is needed labels Feb 23, 2021
@alanhartless
Copy link

There also needs to be a note about naming foreign constraints and indexes. Doctrine generates the name based on the table name. So if someone is using a different table prefix, Doctrine will generate a different name. This will become problematic when doctrine:schema:update is ran and/or a later migration tries to modify an index or constraint by name that may not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants