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

initialAutoIncrement for ALTER TABLE queries #15368

Open
3 of 6 tasks
hemanth-kumarv opened this issue Dec 1, 2022 · 2 comments
Open
3 of 6 tasks

initialAutoIncrement for ALTER TABLE queries #15368

hemanth-kumarv opened this issue Dec 1, 2022 · 2 comments
Labels
dialect: mysql For issues and PRs. Things that involve MySQL (and do not involve all dialects). type: feature For issues and PRs. For new features. Never breaking changes.

Comments

@hemanth-kumarv
Copy link

Issue Creation Checklist

  • I understand that my issue will be automatically closed if I don't fill in the requested information
  • I have read the contribution guidelines

Bug Description

initialAutoIncrement is not updated when table exists and SQL ALTER command is executed upon sync

Reproducible Example

module.exports = (sequelize, DataTypes) => {
  const User = sequelize.define(
    'User',
    {
      id: {
        type: DataTypes.BIGINT(20),
        primaryKey: true,
        autoIncrement: true,
      },
      name: {
        type: DataTypes.STRING(500),
        allowNull: false,
      },
    },
    {
      initialAutoIncrement: 1000,
    }
  );

  return User;
};

What do you expect to happen?

Upon executing sync(), AUTO_INCREMENT=1000 needs to be executed in ALTER TABLE command

What is actually happening?

AUTO_INCREMENT=1000 is not executed in ALTER TABLE command

Environment

  • Sequelize version: 6.26.0
  • Node.js version: 16.17.0
  • If TypeScript related: TypeScript version:
  • Database & Version: 8.0.26
  • Connector library & Version: mysql2@2.3.3

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.

Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.

@WikiRik WikiRik added type: feature For issues and PRs. For new features. Never breaking changes. dialect: mysql For issues and PRs. Things that involve MySQL (and do not involve all dialects). labels Dec 1, 2022
@WikiRik
Copy link
Member

WikiRik commented Dec 1, 2022

@ephys I think it might be good to include this after #14687, do you agree?

@ephys
Copy link
Member

ephys commented Dec 1, 2022

We need to check whether it's possible to know which value AUTO_INCREMENT was set to, or sync will eventually crash (app starts & updates AUTO_INCREMENT, app inserts a value, app restarts and sets AUTO_INCREMENT to a value lower than what one of the existing values in the table, which is not allowed and crashes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialect: mysql For issues and PRs. Things that involve MySQL (and do not involve all dialects). type: feature For issues and PRs. For new features. Never breaking changes.
Projects
None yet
Development

No branches or pull requests

3 participants