https://github.com/ae0000/dbdiff
Creates a diff (as SQL updates) between to database structures
https://github.com/ae0000/dbdiff
golang mysql tool
Last synced: 4 months ago
JSON representation
Creates a diff (as SQL updates) between to database structures
- Host: GitHub
- URL: https://github.com/ae0000/dbdiff
- Owner: ae0000
- License: apache-2.0
- Created: 2018-09-24T06:35:53.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-24T06:54:24.000Z (almost 8 years ago)
- Last Synced: 2024-11-15T05:16:05.333Z (over 1 year ago)
- Topics: golang, mysql, tool
- Language: Go
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
DBDiff
================================================
Version 0.2
-----------
DBDiff takes two (MySQL) database structures and works out the differences between the
two. It then uses these diffs to create a list of SQL updates you would need to
make to align them.
Notes:
------
The following things are not yet handled.
- [ ] triggers
- [ ] stored procedures
- [ ] views
- [ ] other dbs besides mysql?
Comments are a little dicey as well....
How to use:
--------------
Firstly get your DB structures, something like this:
```
mysqldump --user tt -p \
--comments=FALSE \
--compact=TRUE \
--routines=TRUE \
--no-data \
--triggers=TRUE \
databasename \
| sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > original.sql
```
You should have _original.sql_ and _current.sql_.
Then install this thing..
```
go get github.com/ae0000/dbdiff
cd to/where/ever/the/dbdiff/dir/ends/up
go install
```
Then to actually run the diff:
```
dbdiff diff --original original.sql --current current.sql
```
You should then get something like this printed out:
```
-- :::::::::: Changes for Addresses
-- .....................................................
-- Column : Town
-- Original : char(128) NOT NULL
-- New : char(128) NOT NULL DEFAULT ''
ALTER TABLE `Addresses` MODIFY COLUMN Town char(128) NOT NULL DEFAULT '';
-- .....................................................
-- Column : Description
-- Original : text NOT NULL
-- New : mediumtext NOT NULL
ALTER TABLE `Addresses` MODIFY COLUMN Description mediumtext NOT NULL;
```