Subsequent migrations fail after running db:migrate:schema:timestamps:add command

Open
#1,478 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, mysql
Domain
cli, database

Research direction

Start with the db:migrate:schema:timestamps:add command and the migration setup that creates or updates the SequelizeMeta table. Reproduce on MySQL 5.7 with Sequelize CLI and inspect why createdAt lacks a default value; done means subsequent migrations run successfully without the Field 'createdAt' error.

Written by the indexing model from the issue text.

Description

type: bug

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

Reproducible Example

Start up a new sequelize project;
Run npx sequelize-cli db:migrate:schema:timestamps:add command

Subsequent migrations will fail to run returning the following error:

ERROR: Field 'createdAt' doesn't have a default value

From my investigation, what's happening is that createdAt field in SequelizeMeta table doesn't have a default value - and that's where that error is thrown from.

What do you expect to happen?

For the migration to run successfully.

What is actually happening?
Environment
  • Sequelize version: ^6.37.0
  • Node.js version: v18.19.0
  • If TypeScript related: TypeScript version: N\A
  • Database & Version: MySQL v5.7.39
  • Connector library & Version:

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.

Dominant language
JavaScript
Stars
2.6k
Forks
524
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sequelize/cli

All issues in sequelize/cli

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.