[GH-ISSUE #100] DBDiff doesn't write migration.sql if no differences was found in database structure #67

Open
opened 2026-02-25 21:33:11 +03:00 by kerem · 0 comments
Owner

Originally created by @llagerlof on GitHub (Aug 26, 2020).
Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/100

Environment:

Windows 10 WSL 1 (Ubuntu)

How to reproduce:

  • Setup 2 identical databases.
  • Run php dbdiff server1.database1:server2.database2

If migration.sql exists, it doesn't change. If migration.sql doesn't exists, it isn't created.

This is bad because can lead to wrong conclusions. e.g.: What if I ran dbdiff into databases with differences and apply the update. When I run dbdiff against the same databases it will look like I didn't applied the update because the previous migration.sql is still there.

.dbdiff contents:

server1:
    user: root
    password: 123456
    port: 3306
    host: 127.0.0.1
server2:
    user: jack
    password: p@ssw0rd
    port: 3306
    host: 2.2.2.2
template: templates/custom-db-migrate.tmpl
type: schema
include: up
nocomments: true

custom-db-migrate.tmpl contents:

-- UP

{{ $up }}

-- END UP

Suggestion to solve this issue:

Write the migration.sql even if there isn't any differences.

Originally created by @llagerlof on GitHub (Aug 26, 2020). Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/100 **Environment:** Windows 10 WSL 1 (Ubuntu) **How to reproduce:** - Setup 2 identical databases. - Run `php dbdiff server1.database1:server2.database2` If `migration.sql` exists, it doesn't change. If `migration.sql` doesn't exists, it isn't created. This is bad because can lead to wrong conclusions. *e.g.:* What if I ran `dbdiff` into databases with differences and apply the update. When I run `dbdiff` against the same databases it will look like I didn't applied the update because the previous `migration.sql` is still there. `.dbdiff` **contents:** ``` server1: user: root password: 123456 port: 3306 host: 127.0.0.1 server2: user: jack password: p@ssw0rd port: 3306 host: 2.2.2.2 template: templates/custom-db-migrate.tmpl type: schema include: up nocomments: true ``` `custom-db-migrate.tmpl` **contents:** ``` -- UP {{ $up }} -- END UP ``` **Suggestion to solve this issue:** Write the `migration.sql` even if there isn't any differences.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/DBDiff#67
No description provided.