How do you sync your database schema?
September 22, 2022 – 10:34 am
It is almost an everyday task for developers to ensure the database schema are in sync in their test/development/production databases. No doubt that everyone who works with MySQL servers will encounter situations where schema should be synchronized but isn’t. When this happens, there must be a reliable solution where it should work in any intricate situation.
Challenge:
You have made numerous MySQL schema changes to your databases during development of a new feature. Now you want to sync development and production schemas so that they match when you push a new release. DBAs often spend significant time creating complex synchronization scripts, even though the update itself might be a simple one. You need a solution that will automatically compare and identify the object differences between two MySQL database schemas and then synchronize them.
1. Manual
a) If you are working with small databases running mysqldump on both databases with the –no-data option to generate SQL scripts, then running file comparison tool(Example: Araxis merge) on the SQL scripts works pretty well.
mysqldump -h localhost -u root -p -no-data dbname1>file1 mysqldump -h localhost -u root -p -no-data dbname2>file2
But this becomes very tedious to carry out this process for large databases.
b) Always record those changes and finally create a hand-crafted SQL file with ALTER TABLE. This is good if you are changing only few database schemas, but risky because it is not done automatically.
2. Command line tools
These command line tools can compare the schema of two databases:
a) – a MySQL Schema Versioning and Migration Utility.
Syntax:
schemasync [options]
This actually generates two scripts. One is Patch script- SQL to migrate the schema of a source DB to a target DB. And, the other one is Revert script- SQL to undo changes after you apply them. This product is good as it produces proper patch and revert SQL scripts. But it requires python to be installed in advance.
b) – tool to compare MySQL database structures.
Syntax:
mysql-diff
The file name will point to the SQL scripts. It can compare two SQL scripts and can also connect to MySQL servers through jdbc, compare and generate the changes. mysql-diff doesn’t support Views/Functions/Stored procedures/Triggers comparison. It requires JDK to run.
If you want to a color-coded side-by-side comparison which makes it easy to pinpoint at a glance, similarities or differences between two databases then SQLyog is what you are looking for.
Select the databases you want to compare and press the compare button. That is all you need to do. Once your database schema are compared, you can view the object differences and generate only necessary synchronization script to update the destination database.
You can select which object or the number of objects you want to sync and press the button ‘Execute All’ to apply the sync changes. There is also an option to ‘Save to file’, with which you can sync at a later point in time.
Advantages of using Schema synchronization:
- Side-by-side comparison which makes it easy to locate the differences.
- Filter to eliminate comparing all database objects.
- Useful before doing SQLyog’s Database synchronization(To sync only the data, schema must be same).
- Visually represent the differences between MySQL databases with details and modification scripts for the different objects.
- Synchronization of columns, indexes, constraints, views, stored procedures and functions.
what does wtw mean snapchat
what are the red and blue lines in fortnite
what does 111 mean spiritually
How to make creamy mashed potatoes?
Why si there an udyr in every single one of tricks sub games
what does dog days mean
Tricks on how to get 100 streaks on snapchat
Tricks magic tricks how to make something levitate
what does z mean in russian
How to hide?
Easy magic tricks how to
Tips to keep house coole when ac breaks
Which direction should i installment boot shaped rubber tips on hiking poles
Drop seeder/spreader tips for telling where i have already dropped
How to get my smell back?
How to shave your face # tips & tricks
How to get rid of keloid on nose?
How to find the zeros of a function?
How much do door dashers get from tips
what age does amazon hire
How to make a tiktok video
How to block youtube on ipad?
what time does janet documentary come on
What order should i learn tricks
what does uh mean
what does h/t mean
what does a bump on your vagina mean
How to figure out who has opposition chess tricks
How long to cook a roast in the oven
what does purity mean
How to squat?
How to get a girl to like you over text
How to make brown butter?
what does a brand ambassador do
How to talk to a girl over text
How to get water out of iphone
Tips on how to persuade mothers
Mario kart wii how to tricks air
How to bake chicken breast
How to refund a game on xbox?
How to get more protein?
How to cook leg of lamb
How to fix stick drift?
Can shipt shoppers see who tips
How to read guitar chords?
what are the best airpods
what do angel numbers 222 mean
Tips on how to start a conversation with a girl
what does it mean to be bisexual
Trainer tips on how to get to pokemon tcg world championships
How to get rid of face fat?
what does cisgender mean
what does the fire mean on snapchat
what does itchy feet mean spiritually
How to make facebook dark mode
Tips on how to grow your clothing line
How long does plastic take to decompose?
How to reheat chicken wings?
How to cook boneless pork ribs?
what does chicago mean
What tips or best on pool cue
How to change facebook page name tricks
what does fysa mean
what does it mean when liver enzymes are high
How to make evil in little alchemy 2?
what does something casual mean
what age does mcdonald's hire
what does it mean when your messages are green
How to do swinging tricks in spiderman ps4
what does kudos mean
How to make night in little alchemy
How to get rid of nair burn overnight
Why do some daisies have pink tips
What are tricks to increase productivity in occupational therapy
How to get ink out of clothes
what time does tampa bay play
How much is a gel manicure with tips
How long does magnesium citrate take to work?
what does democracy mean
When woodburning why does my tips turn black
what does 5 leaf clover mean
How much trouble can an owner get and to for withholding tips without a proper sign
First-time homebuyers tax credit 2021 how to apply?
How to get security tag off
what are the zoomies
what does blah mean
what does it mean to be septic
what does wsg mean in texting
How to make bubbles tricks
Tips when buying home insurance
How old to work at target
How to check airpod battery life
what does medicare b cover
How to cook chicken thighs
How to make a game in roblox
what does clapping mean sexually
Why does my cat eat q tips
How much tips does starbuck make
what time does this is us come on
what does lucas mean
What kinda tips for pot delivery
what does pushin p mean slang
what does rawr mean in text
what does an insurance adjuster do
How much of a calorie deficit to lose weight?
How to get johnson and johnson vaccine?
How to make money for teens
How many hat tricks does connor mcdavid have?
How to fold a chip bag?
How to apply at walmart
How to do cloth changing magic tricks
Which russian piping tips are the best?
what does aim mean
what does multifaceted mean
Tips on how to grow your hair fast
How to start a book club
what does bing bong mean tiktok
How to move a hot tub?