Answers: <p>We use <a href="https://flywaydb.org/" rel="noreferrer">Flyway</a> at work for managing Postgres schemas in the app, and <a href="https://github.com/comeara/pillar" rel="noreferrer">Pillar</a> for managing Cassandra schemas. We have found it best if the app manages its own schema. </p>
  
  <p>We had a horrible experience having <a href="/questions/tagged/ansible" class="post-tag" title="show questions tagged &#39;ansible&#39;" rel="tag">ansible</a> manage schemas before the apps managed their own schemas.</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-04-01T22:28:50.363Z
Answers: 2017-04-02T04:39:50.403Z
Answers: 2017-04-02T04:39:50.403Z
Answers: trashcan
Answers: <p>We use <a href="http://www.liquibase.org/" rel="noreferrer">liquibase</a> at our work and I'll speak highly for it.  It's also used by our QA tool <a href="https://www.qasymphony.com/" rel="noreferrer">QASymphony</a>.</p>
  
  <p>We're utilizing it against MSSQL and Oracle databases internally and QASymphony uses/has used it with both postgres + mysql instances.</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-04-02T00:51:01.193Z
Answers: 2017-04-02T00:51:01.193Z
Answers: whoisearth
Answers: <p>To answer this question in the context of a mainframe environment, and specific to DB2® databases, there are typically 2 commonly used (not cheap ...) alternatives to pick from:</p>
  <ul>
  <li><p><a href="http://www.bmc.com/it-solutions/object-administration-db2.html" rel="noreferrer">Object Administration for DB2®</a>, from BMC. Here are some details about it (quote from the linked page):</p>
  <blockquote>
  <p>Making changes to objects in your database—or even just performing routine administrative tasks—can be difficult, risky work. There are dozens of tasks to keep track of, and a single misstep could have a disastrous impact on availability and data integrity. You can cut back on both effort and risk with BMC Object Administration for DB2 11, a collection of tools to help you:</p>
  <ul>
  <li>Reduce the time required to administer complex and disparate DB2 environments.</li>
  <li>Automate routine tasks throughout the application lifecycle for improved integrity.</li>
  <li>Improve productivity with simplified DB2 catalog navigation and change management.</li>
  <li>Enhance application availability by performing changes and maintenance with minimal outages.</li>
  </ul>
  </blockquote>
  </li>
  <li><p><a href="http://www-03.ibm.com/software/products/en/db2admin" rel="noreferrer">DB2 Administration Tool for z/OS</a>, from IBM.</p>
  <blockquote>
  <p>It simplifies the complex tasks associated with safely managing DB2 objects and schema throughout the application lifecycle with the least possible impact to availability.</p>
  <ul>
  <li>Allows users to navigate the DB2 catalog quickly and easily</li>
  <li>Builds and executes dynamic SQL statements without knowing the exact SQL syntax</li>
  <li>Manages and tracks changes made to DB2 object definitions resolving any potential conflicts prior to execution</li>
  <li>Helps build DB2 commands to execute against databases and tables</li>
  <li>Enables users to create, alter, migrate, drop and reverse engineer DB2 objects</li>
  <li>Builds and executes utility jobs, allowing users to take advantage of LISTDEFs and TEMPLATEs for increased productivity</li>
  </ul>
  </blockquote>
  </li>
  </ul>
  <h3>Integration with SCM tools</h3>
  <p>Some time ago I was challenged by a customer to actually &quot;integrate&quot; the BMC alternative in their SCM lifecycle (managed by <a href="http://serena.com/products/changeman-zmf/index.html" rel="noreferrer">SERENA ChangeMan ZMF</a>). The idea behind such integration being &quot;<em>Consider our DB2 DBA-team (doing stuff with DDLs) as a special case of a development team, accidentally using some exotic editor (the BMC tool) to produce the code (DDL) to be migrated</em>&quot;.</p>
  <p>About the only (but <em>real</em>!) challenge about this integration was to also facilitate &quot;restartability&quot;, which is one of the key benefits of such DBA tool:</p>
  <ul>
  <li><p><em>Restartability</em> means that when this DBA tool is doing its thing (via sometimes long running jobs, as per the nature of the work to be completed), unexpected things may happen (deadlocks, time abends, etc).</p>
  </li>
  <li><p>If any of those things happen, and you don't want to restart from your backup (before you started), then the DBA tool expects you to restart from the (check-)point from which things started to go wrong (and from where you want everything to be re-executed).</p>
  </li>
  <li><p>Better still (or should I say &quot;even worse&quot;?), if a newbee to the DBA tool doesn't real know how to restart from such checkpoint, and simply tries again (from the beginning), then the DBA tool will simply fail with some kind of user error. And this with an indication with something like &quot;<em>Until you tell me how you want me to proceed after my last point of failure, I refuse to do anything (to not make things even worse)</em>&quot;.</p>
  </li>
  <li><p>In the end, the real clue to implement this restartability in the SCM tool being used, required the SCM tool to be tuned also. Actually to allow it to be used for <em>restarting failed SCM procedures</em> (typically related to deliveries to target test/prod environments) ... instead of just <em>submitting the failed SCM procedure all over again</em> (which is how typically those SCM tools recover from such situations).</p>
  </li>
  </ul>
  <p>Bonus: after the SCM integration of the BMC alternative got completed, the customer decided to change their DBA tool to the IBM alternative. And even though both alternatives don't really look the same, the impact of it to the SCM integration was rather minimal: simply a matter of replacing (in some reusable SCM customization) some calls to the BMC alternative by the equivalent calls to the IBM alternative ... which (using DevOps terminology) got implemented by <a href="/questions/tagged/feature-flags" class="post-tag" title="show questions tagged &#39;feature-flags&#39;" rel="tag">feature-flags</a> / <a href="/questions/tagged/feature-toggles" class="post-tag" title="show questions tagged &#39;feature-toggles&#39;" rel="tag">feature-toggles</a>.</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-04-07T17:52:22.407Z
Answers: 2017-04-07T17:52:22.407Z
Answers: 2020-06-18T08:28:10.803Z
Answers: Pierre.Vriens
Answers: <h2>The Challenges</h2>
  <hr />
  <blockquote>
  <p>I am aware that there are practices such as only adding database objects, i.e. tables and columns, never modifying or removing them</p>
  </blockquote>
  <p>At one company I worked for, a rolling window of raw data equated to about 6 months of data and ate up 10 TB.  The data was then processed into an RDBMS format, with some data portions hitting the cutting room floor. After, this dataset still weighed in at 6 TB of usable data which accounted for about 10 years of reportable data.</p>
  <p>The point being that at scale, these kinds of practices (never modifying or removing data) simply isn't practical. Storage is expensive - probably the greatest compute expense of most companies. This provides several interesting challenges:</p>
  <ol>
  <li><strong>Backups</strong> - the InnoDB plugins are great and all, but the backup times on that much data just isn't that practical.</li>
  <li><strong>Restore times</strong> - for large datasets - especially if you need replication to catch up after a restore getting back to an operational state can take days or even weeks.</li>
  <li><strong>Creating/seeding new instances</strong> - Often the work you may be doing in dev/test involves ETL (Extract, Transform and Load) jobs on your dataset.  These jobs need to be validated using QA testing units, but this needs to be done in a non-destructive manner so that the original production dataset is preserved. While in a disaster, you may be willing to deal with a long restore time on the understanding that backups are an insurance policy (and the intent is to avoid disasters) the DevOps development workflow requires that, essentially, you be able to perform a restore or copy of your data on a regular basis (perhaps multiple times a day).</li>
  <li><strong>Capacity</strong> - Slinging around that much data at the scale I just described can be very I/O intensive. Not only do you need to address the problems described in 1-3, but you need to do it in a way that doesn't cause outages or performance slowdowns to your production systems.</li>
  </ol>
  <h2>While the above considerations may not be a concern at smaller scales, at larger scales, these become huge problems to tackle. This means that it is <em><strong>extremely important</strong></em> that you define your requirements and forecast the size of your dataset.
  <br>
  <br>
  Defining requirements</h2>
  <hr />
  <p>As a result of that excercise, you need to define several requirements:</p>
  <ul>
  <li><strong>RTO</strong> - RTO or Restore Time Objective for backups is one of the most important drivers of database backup solutions. While at first it might not appear relevant to most of the other problems described, it becomes extremely relevant when you ask &quot;What if I used my backup solution for creating or seeding new instances?&quot; (I'll cover some techniques for doing that in the next section)</li>
  <li><strong>RPO</strong> - RPO or Restore Point Objective for backups defines A) how far back you are able to restore to (minutes, hours, days, weeks, months, or years) B) The backup interval or frequency at different tiers and C) how granularly you can restore. For example, for E-mail databases, Message Level Backups - restoring a specific E-mail - are often sought. Similarly, you may find that data older than a few days is completely useless - so there is no point restoring back a year. It depends on the kind of data you are working with.</li>
  <li><strong>Size of your dataset</strong> - This is important because for a 1MB database, your RTO may be achieved with most backup products and solutions. For a 10TB database however, you will find that a full, row level backup to LTO 3 tape <em>probably</em> won't achieve your RTO and could interfere with your RPO because backups begin exceeding your backup window. You can't exactly just do a mysqldump on this large of a dataset, but could probably get away with that on the 1MB database.</li>
  <li><strong>Database consistency</strong> - A final thing that makes an immense difference in continuous deployment, site reliability, scalability and high-availability when working with databases is your need (or lack thereof) for consistency. There are three basic types: immediate consistency, Just-In-Time (JIT) consistency and eventual consistency.</li>
  </ul>
  <p>In addition to the above major considerations, you also need to consider:</p>
  <ul>
  <li>Licensing and support requirements (open source or closed source; in house support, third party support or vendor support, and does this fit your budget?)</li>
  <li>Application/language requirements (the connectors for many databases can be important; is your app compiled? Do you have access to the source code? Can you recompile it, or is it provided by a vendor? Does it run on an interpreted language?)</li>
  <li>Political requirements (Does your organization only trust Oracle? Do they hate Oracle? Do they not trust MySql? How do you feel about MariaDB or Postgres? Do we require an EAL certified DB product due to contracts?)</li>
  <li>Database engine (innoDB? MyISAM? Blackhole? NDB Cluster? Spider?)</li>
  <li>Historical or compatibility requirements (we used PL/SQL for years and half our code is built into the oracle engine! How could we ever port over to MariaDB?!?)</li>
  </ul>
  <h2>All of these things (significantly) impact the tools available to you.
  <br>
  <br>
  Some Options for in-house data management</h2>
  <hr />
  <p><em>Note: The following is in no way exhaustive, and other SE users should chime in with additional suggestions.</em></p>
  <p>With the generic considerations out of the way, let me provide you with some techniques and technologies for addressing some of the above. First, ask yourself if you really <em>need</em> to use an RDBMS or if unstructured data with something like Hadoop, CouchDB, KV pairs, or even Object Oriented Storage (something like swift) is an option.</p>
  <p>Second, consider looking into a cloud based solution. This outsources some of this headache and leaves the complicated problems to highly qualified (and paid) individuals. At scale however, you can find this really eats into your budget (cloud providers DO make a profit at this, and at a certain scale, you can just afford to employ these experts yourself) or if you are working under specific security or political requirements (read: we can't do clouds). If you need to run in-house, consider a hybrid NFS/Fibre Channel Filer. Most of these filers, such as those by NetApp, Pure Storage and Tegile support a delta-based snapshotting and cloning technique that can be very handy for A) taking backups, B) restoring backups and C) seeding new backups.</p>
  <p>At this point, I need to note that I am not a backup and storage expert, so there some portions of this problem that I never quite was able to solve before I moved on to other problems (and greener pastures).</p>
  <p><em>But</em> that being said, some of these products allow you to take differential snapshots underneath your database. You will need to script out a full &quot;lock tables with read lock&quot; on one of your database instances (a read-only slave is recommended) and dump your binlog position or GTID for InnoDB based engines. But, when using these filers, once you script that, you will be able to use these snapshots to create new instances of your database. You will want to put binlogs on a separate partition and put only your database data on the other partition. With this, you will be able to clone these partitions (on NetApps, this is know as a &quot;<a href="https://www.youtube.com/watch?v=c8VI_L5K8VM" rel="nofollow noreferrer">FlexClone</a>&quot;) The only issue with this technique is that FlexClones cannot span datastores which means that all your I/O is still impacting the same datastore/volume and calculating the deltas on these volumes can cause some overhead in terms of CPU resources.</p>
  <p>This is because for each block read, the filer must determine if the data resides in the frozen original snapshot, or in the delta. For volumes/stores with multiple snapshots, this might need to be checked multiple times. You can overcome this by refreshing the data (meaning, discard your snapshot and clone it again periodically - which might happen naturally and organically for a good continuous deployment environment) or by permanently splitting the volume (known as a &quot;Flex Split&quot; in NetApp terminology) which will take a moment to permanently resolve the deltas and create an entirely new and separate volume.</p>
  <p>These delta clones have the added benefit of reducing your overall storage requirement - you can spawn several clones or instance of your production database to do your development, testing and validation. If you are only keeping one copy of your large dataset plus the (what are likely to be) small deltas, you reduce your overall storage cost and footprint.</p>
  <p>The only trick here is that this may not constitute a full backup solution as the &quot;backup&quot; still resides on your filer. For this you may need to use something NetApp calls a Snap Mirror which will mirror data (using rsync-style technology) between filers and even datacenters, or use some type of integrated backup solution which can backup to tape one of your delta snapshots or a flex-clone.</p>
  <p>This however has one major flaw: All of your data - dev, test and prod is <em>still</em> using I/O on the same filer and storage head. To work around this, consider creating a slave database instance on a second filer which can be the seeding point for you Test and/or dev filer, or consider using a load balancer/applcation delivery controller for your application layer to mirror production requests into your testing (and/or dev) environment(s). This has the added benefit of throwing prodcution traffic at your QA/Test environment before promoting deployments and code to production and allows you to test for issues that might not be immediately noticed otherwise. You can then check your logs for errors based on production traffic and user behavior in test.</p>
  <h2>This should allow you to use a few script to programatically spawn and destroy entire (and large) datasets for use with continuous deployment methodologies.
  <br>
  <br>
  Scalability and High Availability</h2>
  <p>While you asked about continuous deployment, DevOps is conserned with more than <em>just</em> continuous deployment - so I am going to include some bits about redundancy, scalability and high availability.</p>
  <p>I mentioned, JIT, immediate and eventual consistency. This is where varous RDBMS engines come in. Eventual consistency is relatively easy by simply configuring circular asynchronous replication. This can cause some collisions however *(what if your application layer updates data on one side of the cluster and on the other side of the cluster before replication is completed?) For immediate consistency, look at Galera cluster which will force synchronous replication, but causes scalability issues (how will you replicate to your Disaster Recovery site or load balance geographically without incurring significant latency due to propigation delay at the network layer?) You can also see if you can do synchronous replication within the datacenter and asynchronous replication between sites, but this seems the worst of both worlds.</p>
  <p>Typically however, most people do not need fully synchronous replication - this is <em>usually</em> only needed for very specific (and exotic) high-write environments where multi-master is needed with table sharding. Most apps can deal with Just-In-Time consistency using a database proxy. For example, <a href="http://www.scalearc.com/" rel="nofollow noreferrer">ScaleArc</a> will monitor replication status and track where writes just went (to send subsequent read requests to that location until replication catches up) in order to provide Just-In-Time consistency and the <em>appearance</em> of database consistency. ScaleArc is compatible with Postgres, MySQL, MariaDB, Oracle and MSSQL and can use regular expressions to shard/partition your databases for applications that can't use shard keys. It also has a robust REST API for your configuration management software to interact with - and their support team is outstanding.</p>
  <p>Similarly, you might wish to consider a free alternative, <a href="https://mariadb.com/products/mariadb-maxscale" rel="nofollow noreferrer">MaxScale</a> developed by the MariaDB team for MariaDB. It lacks the GUI and some of the caching features of ScaleArc however.</p>
  <p>Finally, MySQL fabric (and the in-RAM only MySQL Cluster - if you can afford that much RAM) are other potentials - especially with MySQL's new proxy. This can provide the scalability and redundancy component to your environment.</p>
  <p>Postgres and Oracle (Eg, GoldenGate and RAC Cluster) should have the replication and sharding features you need, but ScaleArc will pair well if you need a proxy.</p>
  <p>Ultimately, all these pieces and technologies add up to a highly flexible environment suitable for continuous deployment and development if you are unable to simply use a cloud based environment and let your cloud provider deal with the above problems for you.</p>
  
Answers: CC BY-SA 4.0
Answers: 2017-05-21T04:36:17.390Z
Answers: 2023-07-18T18:00:47.743Z
Answers: 2023-07-18T18:00:47.743Z
Answers: James Shewey
Answers: <p>I'd argue a tool alone won't really help unless you shift the schema responsibility to the application team.</p>
  
  <p>We do use <a href="http://www.liquibase.org/" rel="noreferrer">liquibase</a> or <a href="https://flywaydb.org/" rel="noreferrer">flyway</a> at work, where the application team is responsible to create the changesets.</p>
  
  <p>Along with this,you can avoid a purely additive way.<br>
  Each application is required to be compatible with its precedent version, when an alteration of schema has to be done, then the application will integrate a new column in the schema, write to it and still read and write from/to previous column (allowing the previous version to still have the same data).<br>
  The next version of the application is allowed to stop updating the old column and only the third version will be allowed to remove the now unused column.</p>
  
  <p>Obviously, regular backups are needed in case something goes wrong.<br>
  A proper subset of data likely to create problems in integration tests to avoid them in production is also a good idea. The ideal case get an anonymous subset of production data.</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-04-03T08:19:39.693Z
Answers: 2017-04-03T08:19:39.693Z
Answers: Tensibai
Answers: <p>Pramod Sadalage and Scott Ambler wrote a book <a href="http://rads.stackoverflow.com/amzn/click/0321774515" rel="noreferrer">Refactoring Databases: Evolutionary Database Design</a> that is an incredibly solid primer to the subject of DBs in a CD org/team.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-12-25T10:51:12.357Z
Answers: Could you add a summary?
Answers: 030
Answers: CC BY-SA 3.0
Answers: 2017-04-01T23:09:33.623Z
Answers: 2017-04-01T23:09:33.623Z
Answers: paul_h
Body: <p>Continuous Delivery or Continuous Deployment of infrastructure and code is comparatively simple compared to trying the same approaches for databases, specifically RDBMSs.  Code and infrastructure will not change or evolve once deployment has completed.  Databases, however, will have new data added to them making the data if not the schema inherently mutable components.</p>
  
  <p>I am aware that there are practices such as only adding database objects, i.e. tables and columns, never modifying or removing them - this purely additive way of approaching database schemas has the advantage of ensuring that schemas are backwards compatible at the cost of successively more complicated schemas.</p>
  
  <p>Equally there are products such as <a href="https://flywaydb.org/" rel="noreferrer">Flyway</a> and <a href="http://www.red-gate.com/products/sql-development/readyroll/" rel="noreferrer">Ready Roll</a> which assist in writing migrations to be written between versions of a schema.</p>
  
  <p>What other practices and tools exist currently to allow for continuous deployment of database schemas into a production environment where data integrity is of a concern?</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-09-12T15:09:39.333Z
Comments: You might find Flyway interesting https://flywaydb.org/
Comments: Thorbjørn Ravn Andersen
Comments: CC BY-SA 3.0
Comments: 2017-03-31T20:38:55.427Z
Comments: Why would DB schema(s) change or migrations be needed if the code accessing the DB doesn't change? (assuming no manual DB accesses, which *might* explain it)
Comments: Dan Cornilescu
Comments: CC BY-SA 3.0
Comments: 2017-04-07T15:52:12.447Z
Comments: Hey @DanCornilescu, how about adding "indexes" to reduce/address performance issues?
Comments: Pierre.Vriens
Comments: CC BY-SA 3.0
Comments: 2017-04-07T17:27:17.030Z
Comments: Frankly I know very little  about traditional DBs - the question could very well apply to their indexes. I'm using google's cloud datastore for which changing indexes typically come with app code changes as well. My comment is an honest question, not in any way some "complaint" about Richard's question (which I upvoted).
Comments: Dan Cornilescu
Comments: CC BY-SA 3.0
Comments: 2017-04-07T17:57:42.223Z
Comments: @DanCornilescu I also (honestly) believe what you wrote in your prior comment (and my prior comment was just an attempt to provide a possible answer to the question in your first comment). Next (real?) question?
Comments: Pierre.Vriens
Tags: <continuous-deployment><continuous-delivery><databases><flyway>
Title: What practices or tools enable Continuous Deployment of Databases?
UserDisplayName: Richard Slater
ThreadText: # What practices or tools enable Continuous Deployment of Databases?
  
  (Asked by: username_0 on 2017-03-31)
  
  Continuous Delivery or Continuous Deployment of infrastructure and code is comparatively simple compared to trying the same approaches for databases, specifically RDBMSs. Code and infrastructure will not change or evolve once deployment has completed. Databases, however, will have new data added to them making the data if not the schema inherently mutable components.
  
  I am aware that there are practices such as only adding database objects, i.e. tables and columns, never modifying or removing them - this purely additive way of approaching database schemas has the advantage of ensuring that schemas are backwards compatible at the cost of successively more complicated schemas.
  
  Equally there are products such as [Flyway](https://flywaydb.org/) and [Ready Roll](http://www.red-gate.com/products/sql-development/readyroll/) which assist in writing migrations to be written between versions of a schema.
  
  What other practices and tools exist currently to allow for continuous deployment of database schemas into a production environment where data integrity is of a concern?
  
  **Tags:** continuous-deployment, continuous-delivery, databases, flyway
  
  > **Comments:**
  > **username_2**: Why would DB schema(s) change or migrations be needed if the code accessing the DB doesn't change? (assuming no manual DB accesses, which *might* explain it)  
  > **username_3**: Hey @username_2, how about adding "indexes" to reduce/address performance issues?  
  > **username_2**: Frankly I know very little  about traditional DBs - the question could very well apply to their indexes. I'm using google's cloud datastore for which changing indexes typically come with app code changes as well. My comment is an honest question, not in any way some "complaint" about username_0's question (which I upvoted).  
  > **username_3**: @username_2 I also (honestly) believe what you wrote in your prior comment (and my prior comment was just an attempt to provide a possible answer to the question in your first comment). Next (real?) question?  
  > **username_1**: You might find Flyway interesting https://flywaydb.org/  
  
  ---
  
  ## 6 answers
  
  ### Answer by username_8 on 2017-04-01. Score: 15 | Accepted answer
  
  Pramod Sadalage and Scott Ambler wrote a book [Refactoring Databases: Evolutionary Database Design](http://rads.stackoverflow.com/amzn/click/0321774515) that is an incredibly solid primer to the subject of DBs in a CD org/team.
  
  > **Comments:**
  > **username_9**: Could you add a summary?  
  
  ---
  
  ### Answer by username_6 on 2017-05-21. Score: 15
  
  ## The Challenges
  
  ---
  
  > I am aware that there are practices such as only adding database objects, i.e. tables and columns, never modifying or removing them
  
  At one company I worked for, a rolling window of raw data equated to about 6 months of data and ate up 10 TB. The data was then processed into an RDBMS format, with some data portions hitting the cutting room floor. After, this dataset still weighed in at 6 TB of usable data which accounted for about 10 years of reportable data.
  
  The point being that at scale, these kinds of practices (never modifying or removing data) simply isn't practical. Storage is expensive - probably the greatest compute expense of most companies. This provides several interesting challenges:
  
  1. **Backups** - the InnoDB plugins are great and all, but the backup times on that much data just isn't that practical.
  2. **Restore times** - for large datasets - especially if you need replication to catch up after a restore getting back to an operational state can take days or even weeks.
  3. **Creating/seeding new instances** - Often the work you may be doing in dev/test involves ETL (Extract, Transform and Load) jobs on your dataset. These jobs need to be validated using QA testing units, but this needs to be done in a non-destructive manner so that the original production dataset is preserved. While in a disaster, you may be willing to deal with a long restore time on the understanding that backups are an insurance policy (and the intent is to avoid disasters) the DevOps development workflow requires that, essentially, you be able to perform a restore or copy of your data on a regular basis (perhaps multiple times a day).
  4. **Capacity** - Slinging around that much data at the scale I just described can be very I/O intensive. Not only do you need to address the problems described in 1-3, but you need to do it in a way that doesn't cause outages or performance slowdowns to your production systems.
  
  ## While the above considerations may not be a concern at smaller scales, at larger scales, these become huge problems to tackle. This means that it is ***extremely important*** that you define your requirements and forecast the size of your dataset. Defining requirements
  
  ---
  
  As a result of that excercise, you need to define several requirements:
  
  * **RTO** - RTO or Restore Time Objective for backups is one of the most important drivers of database backup solutions. While at first it might not appear relevant to most of the other problems described, it becomes extremely relevant when you ask "What if I used my backup solution for creating or seeding new instances?" (I'll cover some techniques for doing that in the next section)
  * **RPO** - RPO or Restore Point Objective for backups defines A) how far back you are able to restore to (minutes, hours, days, weeks, months, or years) B) The backup interval or frequency at different tiers and C) how granularly you can restore. For example, for E-mail databases, Message Level Backups - restoring a specific E-mail - are often sought. Similarly, you may find that data older than a few days is completely useless - so there is no point restoring back a year. It depends on the kind of data you are working with.
  * **Size of your dataset** - This is important because for a 1MB database, your RTO may be achieved with most backup products and solutions. For a 10TB database however, you will find that a full, row level backup to LTO 3 tape *probably* won't achieve your RTO and could interfere with your RPO because backups begin exceeding your backup window. You can't exactly just do a mysqldump on this large of a dataset, but could probably get away with that on the 1MB database.
  * **Database consistency** - A final thing that makes an immense difference in continuous deployment, site reliability, scalability and high-availability when working with databases is your need (or lack thereof) for consistency. There are three basic types: immediate consistency, Just-In-Time (JIT) consistency and eventual consistency.
  
  In addition to the above major considerations, you also need to consider:
  
  * Licensing and support requirements (open source or closed source; in house support, third party support or vendor support, and does this fit your budget?)
  * Application/language requirements (the connectors for many databases can be important; is your app compiled? Do you have access to the source code? Can you recompile it, or is it provided by a vendor? Does it run on an interpreted language?)
  * Political requirements (Does your organization only trust Oracle? Do they hate Oracle? Do they not trust MySql? How do you feel about MariaDB or Postgres? Do we require an EAL certified DB product due to contracts?)
  * Database engine (innoDB? MyISAM? Blackhole? NDB Cluster? Spider?)
  * Historical or compatibility requirements (we used PL/SQL for years and half our code is built into the oracle engine! How could we ever port over to MariaDB?!?)
  
  ## All of these things (significantly) impact the tools available to you. Some Options for in-house data management
  
  ---
  
  *Note: The following is in no way exhaustive, and other SE users should chime in with additional suggestions.*
  
  With the generic considerations out of the way, let me provide you with some techniques and technologies for addressing some of the above. First, ask yourself if you really *need* to use an RDBMS or if unstructured data with something like Hadoop, CouchDB, KV pairs, or even Object Oriented Storage (something like swift) is an option.
  
  Second, consider looking into a cloud based solution. This outsources some of this headache and leaves the complicated problems to highly qualified (and paid) individuals. At scale however, you can find this really eats into your budget (cloud providers DO make a profit at this, and at a certain scale, you can just afford to employ these experts yourself) or if you are working under specific security or political requirements (read: we can't do clouds). If you need to run in-house, consider a hybrid NFS/Fibre Channel Filer. Most of these filers, such as those by NetApp, Pure Storage and Tegile support a delta-based snapshotting and cloning technique that can be very handy for A) taking backups, B) restoring backups and C) seeding new backups.
  
  At this point, I need to note that I am not a backup and storage expert, so there some portions of this problem that I never quite was able to solve before I moved on to other problems (and greener pastures).
  
  *But* that being said, some of these products allow you to take differential snapshots underneath your database. You will need to script out a full "lock tables with read lock" on one of your database instances (a read-only slave is recommended) and dump your binlog position or GTID for InnoDB based engines. But, when using these filers, once you script that, you will be able to use these snapshots to create new instances of your database. You will want to put binlogs on a separate partition and put only your database data on the other partition. With this, you will be able to clone these partitions (on NetApps, this is know as a "[FlexClone](https://www.youtube.com/watch?v=c8VI_L5K8VM)") The only issue with this technique is that FlexClones cannot span datastores which means that all your I/O is still impacting the same datastore/volume and calculating the deltas on these volumes can cause some overhead in terms of CPU resources.
  
  This is because for each block read, the filer must determine if the data resides in the frozen original snapshot, or in the delta. For volumes/stores with multiple snapshots, this might need to be checked multiple times. You can overcome this by refreshing the data (meaning, discard your snapshot and clone it again periodically - which might happen naturally and organically for a good continuous deployment environment) or by permanently splitting the volume (known as a "Flex Split" in NetApp terminology) which will take a moment to permanently resolve the deltas and create an entirely new and separate volume.
  
  These delta clones have the added benefit of reducing your overall storage requirement - you can spawn several clones or instance of your production database to do your development, testing and validation. If you are only keeping one copy of your large dataset plus the (what are likely to be) small deltas, you reduce your overall storage cost and footprint.
  
  The only trick here is that this may not constitute a full backup solution as the "backup" still resides on your filer. For this you may need to use something NetApp calls a Snap Mirror which will mirror data (using rsync-style technology) between filers and even datacenters, or use some type of integrated backup solution which can backup to tape one of your delta snapshots or a flex-clone.
  
  This however has one major flaw: All of your data - dev, test and prod is *still* using I/O on the same filer and storage head. To work around this, consider creating a slave database instance on a second filer which can be the seeding point for you Test and/or dev filer, or consider using a load balancer/applcation delivery controller for your application layer to mirror production requests into your testing (and/or dev) environment(s). This has the added benefit of throwing prodcution traffic at your QA/Test environment before promoting deployments and code to production and allows you to test for issues that might not be immediately noticed otherwise. You can then check your logs for errors based on production traffic and user behavior in test.
  
  ## This should allow you to use a few script to programatically spawn and destroy entire (and large) datasets for use with continuous deployment methodologies. Scalability and High Availability
  
  While you asked about continuous deployment, DevOps is conserned with more than *just* continuous deployment - so I am going to include some bits about redundancy, scalability and high availability.
  
  I mentioned, JIT, immediate and eventual consistency. This is where varous RDBMS engines come in. Eventual consistency is relatively easy by simply configuring circular asynchronous replication. This can cause some collisions however \*(what if your application layer updates data on one side of the cluster and on the other side of the cluster before replication is completed?) For immediate consistency, look at Galera cluster which will force synchronous replication, but causes scalability issues (how will you replicate to your Disaster Recovery site or load balance geographically without incurring significant latency due to propigation delay at the network layer?) You can also see if you can do synchronous replication within the datacenter and asynchronous replication between sites, but this seems the worst of both worlds.
  
  Typically however, most people do not need fully synchronous replication - this is *usually* only needed for very specific (and exotic) high-write environments where multi-master is needed with table sharding. Most apps can deal with Just-In-Time consistency using a database proxy. For example, [ScaleArc](http://www.scalearc.com/) will monitor replication status and track where writes just went (to send subsequent read requests to that location until replication catches up) in order to provide Just-In-Time consistency and the *appearance* of database consistency. ScaleArc is compatible with Postgres, MySQL, MariaDB, Oracle and MSSQL and can use regular expressions to shard/partition your databases for applications that can't use shard keys. It also has a robust REST API for your configuration management software to interact with - and their support team is outstanding.
  
  Similarly, you might wish to consider a free alternative, [MaxScale](https://mariadb.com/products/mariadb-maxscale) developed by the MariaDB team for MariaDB. It lacks the GUI and some of the caching features of ScaleArc however.
  
  Finally, MySQL fabric (and the in-RAM only MySQL Cluster - if you can afford that much RAM) are other potentials - especially with MySQL's new proxy. This can provide the scalability and redundancy component to your environment.
  
  Postgres and Oracle (Eg, GoldenGate and RAC Cluster) should have the replication and sharding features you need, but ScaleArc will pair well if you need a proxy.
  
  Ultimately, all these pieces and technologies add up to a highly flexible environment suitable for continuous deployment and development if you are unable to simply use a cloud based environment and let your cloud provider deal with the above problems for you.
  
  
  ---
  
  ### Answer by username_7 on 2017-04-03. Score: 8
  
  I'd argue a tool alone won't really help unless you shift the schema responsibility to the application team.
  
  We do use [liquibase](http://www.liquibase.org/) or [flyway](https://flywaydb.org/) at work, where the application team is responsible to create the changesets.
  
  Along with this,you can avoid a purely additive way.  
  Each application is required to be compatible with its precedent version, when an alteration of schema has to be done, then the application will integrate a new column in the schema, write to it and still read and write from/to previous column (allowing the previous version to still have the same data).  
  The next version of the application is allowed to stop updating the old column and only the third version will be allowed to remove the now unused column.
  
  Obviously, regular backups are needed in case something goes wrong.  
  A proper subset of data likely to create problems in integration tests to avoid them in production is also a good idea. The ideal case get an anonymous subset of production data.
  
  
  ---
  
  ### Answer by username_4 on 2017-04-01. Score: 7
  
  We use [Flyway](https://flywaydb.org/) at work for managing Postgres schemas in the app, and [Pillar](https://github.com/comeara/pillar) for managing Cassandra schemas. We have found it best if the app manages its own schema.
  
  We had a horrible experience having [ansible](/questions/tagged/ansible "show questions tagged 'ansible'") manage schemas before the apps managed their own schemas.
  
  
  ---
  
  ### Answer by username_5 on 2017-04-02. Score: 4
  
  We use [liquibase](http://www.liquibase.org/) at our work and I'll speak highly for it. It's also used by our QA tool [QASymphony](https://www.qasymphony.com/).
  
  We're utilizing it against MSSQL and Oracle databases internally and QASymphony uses/has used it with both postgres + mysql instances.
  
  
  ---
  
  ### Answer by username_3 on 2017-04-07. Score: 4
  
  To answer this question in the context of a mainframe environment, and specific to DB2® databases, there are typically 2 commonly used (not cheap ...) alternatives to pick from:
  
  * [Object Administration for DB2®](http://www.bmc.com/it-solutions/object-administration-db2.html), from BMC. Here are some details about it (quote from the linked page):
  
    > Making changes to objects in your database—or even just performing routine administrative tasks—can be difficult, risky work. There are dozens of tasks to keep track of, and a single misstep could have a disastrous impact on availability and data integrity. You can cut back on both effort and risk with BMC Object Administration for DB2 11, a collection of tools to help you:
    >
    > + Reduce the time required to administer complex and disparate DB2 environments.
    > + Automate routine tasks throughout the application lifecycle for improved integrity.
    > + Improve productivity with simplified DB2 catalog navigation and change management.
    > + Enhance application availability by performing changes and maintenance with minimal outages.
  * [DB2 Administration Tool for z/OS](http://www-03.ibm.com/software/products/en/db2admin), from IBM.
  
    > It simplifies the complex tasks associated with safely managing DB2 objects and schema throughout the application lifecycle with the least possible impact to availability.
    >
    > + Allows users to navigate the DB2 catalog quickly and easily
    > + Builds and executes dynamic SQL statements without knowing the exact SQL syntax
    > + Manages and tracks changes made to DB2 object definitions resolving any potential conflicts prior to execution
    > + Helps build DB2 commands to execute against databases and tables
    > + Enables users to create, alter, migrate, drop and reverse engineer DB2 objects
    > + Builds and executes utility jobs, allowing users to take advantage of LISTDEFs and TEMPLATEs for increased productivity
  
  ### Integration with SCM tools
  
  Some time ago I was challenged by a customer to actually "integrate" the BMC alternative in their SCM lifecycle (managed by [SERENA ChangeMan ZMF](http://serena.com/products/changeman-zmf/index.html)). The idea behind such integration being "*Consider our DB2 DBA-team (doing stuff with DDLs) as a special case of a development team, accidentally using some exotic editor (the BMC tool) to produce the code (DDL) to be migrated*".
  
  About the only (but *real*!) challenge about this integration was to also facilitate "restartability", which is one of the key benefits of such DBA tool:
  
  * *Restartability* means that when this DBA tool is doing its thing (via sometimes long running jobs, as per the nature of the work to be completed), unexpected things may happen (deadlocks, time abends, etc).
  * If any of those things happen, and you don't want to restart from your backup (before you started), then the DBA tool expects you to restart from the (check-)point from which things started to go wrong (and from where you want everything to be re-executed).
  * Better still (or should I say "even worse"?), if a newbee to the DBA tool doesn't real know how to restart from such checkpoint, and simply tries again (from the beginning), then the DBA tool will simply fail with some kind of user error. And this with an indication with something like "*Until you tell me how you want me to proceed after my last point of failure, I refuse to do anything (to not make things even worse)*".
  * In the end, the real clue to implement this restartability in the SCM tool being used, required the SCM tool to be tuned also. Actually to allow it to be used for *restarting failed SCM procedures* (typically related to deliveries to target test/prod environments) ... instead of just *submitting the failed SCM procedure all over again* (which is how typically those SCM tools recover from such situations).
  
  Bonus: after the SCM integration of the BMC alternative got completed, the customer decided to change their DBA tool to the IBM alternative. And even though both alternatives don't really look the same, the impact of it to the SCM integration was rather minimal: simply a matter of replacing (in some reusable SCM customization) some calls to the BMC alternative by the equivalent calls to the IBM alternative ... which (using DevOps terminology) got implemented by [feature-flags](/questions/tagged/feature-flags "show questions tagged 'feature-flags'") / [feature-toggles](/questions/tagged/feature-toggles "show questions tagged 'feature-toggles'").
  
  
  ---
  
  