Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Using Git to track mysql schema - some questions
- #!/bin/sh
- mysqldump -u DBUSER -pDBPASSWORD DATABASE --no-data=true> SQLVersionControl/vc.sql
- git add SQLVersionControl/vc.sql
- exit 0
- #!/bin/sh
- mysqldump -u DBUSER -pDBPASSWORD DATABASE --no-data=true> SQLVersionControl/vc.sql
- git add SQLVersionControl/vc.sql
- exit 0
- #!/bin/bash -e
- # -e means exit if any command fails
- DBHOST=dbhost.yourdomain.com
- DBUSER=dbuser
- DBPASS=dbpass # do this in a more secure fashion
- DBNAME=dbname
- GITREPO=/path/to/git/repo
- cd $GITREPO
- mysqldump -h $DBHOST -u $DBUSER -p$DBPASS -d $DBNAME > $GITREPO/schema.sql # the -d flag means "no data"
- git add schema.sql
- git commit -m "$DBNAME schema version $(`date`)"
- git push # assuming you have a remote to push to
- #!/bin/sh
- mysqldump -u DBUSER -pDBPASSWORD DATABASE --no-data=true> SQLVersionControl/vc.sql
- git add SQLVersionControl/vc.sql
- exit 0
- $> mkdir myschema && cd myschema
- $> git init
- $> echo "CREATE TABLE ..." > schema.sql
- $> git add schema.sql
- $> git commit -m "Initial import"
- #!/bin/bash
- # exit upon error
- set -e
- # another way to set "exit upon error", for readability
- set -o errexit
- mysqldump -umyuser -pmypassword dbase1 --no-data=true > dbase1.sql
- # Uncomment following line to dump all data with schema,
- # useful when used in tandem for the post-checkout hook below.
- # WARNING: can greatly expand your git repo when employing for
- # large databases, so carefully evaluate before employing this method.
- # mysqldump -umyuser -pmypassword dbase1 > dbase1.sql
- git add dbase1.sql
- #!/bin/bash
- # mysqldump (above) is presumably run without '--no-data=true' parameter.
- set -e
- mysql -umyuser -pmypassword dbase1 < dbase1.sql
- root@node1 Dec 12 22:35:14 /var/www# mysql --version
- mysql Ver 14.14 Distrib 5.1.54, for debian-linux-gnu (x86_64) using readline 6.2
- root@node1 Dec 12 22:35:19 /var/www# git --version
- git version 1.7.4.1
- root@node1 Dec 12 22:35:22 /var/www# lsb_release -a
- No LSB modules are available.
- Distributor ID: Ubuntu
- Description: Ubuntu 11.04
- Release: 11.04
- Codename: natty
- root@node1 Dec 12 22:35:28 /var/www#
- git rebase --onto master~8 master~7
Add Comment
Please, Sign In to add comment