TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How do you handle CI/CD for databases

16 点作者 totaldude87超过 3 年前
How do you handle the database setup / scripts and other nominal DML DDL steps via CICD pipelines , looking for suggestion on tools and software (both oss and commercial ) and for any major databases like MySQL or oracle or postgres

7 条评论

samokhvalov超过 3 年前
Take a look at Database Lab: <a href="https:&#x2F;&#x2F;postgres.ai&#x2F;products&#x2F;database-migration-testing" rel="nofollow">https:&#x2F;&#x2F;postgres.ai&#x2F;products&#x2F;database-migration-testing</a><p>The idea is to use block-level copy-on-write (ZFS by default, LVM2 is an option too, though less powerful) to be able to get thin clones really fast. Currently supports only Postgres. The engine is open source. Result; single machine with Postgres DB of any size, you pay 1x for storage and compute, and can have dozens of independent DBs, provisioning takes a few seconds.<p>This is used in CI&#x2F;CD context so getting temporary full-size for any tests is not a problem any more.<p>We constantly add new features and looking forward to new use cases.<p>Some case studies with numbers are here: <a href="https:&#x2F;&#x2F;postgres.ai&#x2F;resources" rel="nofollow">https:&#x2F;&#x2F;postgres.ai&#x2F;resources</a><p>Here is how GitLab uses it for DB testing: <a href="https:&#x2F;&#x2F;docs.gitlab.com&#x2F;ee&#x2F;architecture&#x2F;blueprints&#x2F;database_testing&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.gitlab.com&#x2F;ee&#x2F;architecture&#x2F;blueprints&#x2F;database_...</a><p>(disclaimer: I&#x27;m the founder of Postgres.ai, the company that develops Database Lab).
yellow_lead超过 3 年前
Previously I used an ephemeral database for all environments except stage&#x2F;prod. The ephemeral DBs just ran in docker containers. In all environments, we used flyway to manage the database. Flyway can run again and again and won&#x27;t do anything if your database is already up to date. For the ephemeral databases it could initialize them from scratch in the same way.
marcc超过 3 年前
We created and use SchemaHero (<a href="https:&#x2F;&#x2F;schemahero.io" rel="nofollow">https:&#x2F;&#x2F;schemahero.io</a>) for <i>parts</i> of this. We use Terraform to create the database (RDS, etc), and then SchemaHero to manage the schema in a declarative method.
sethammons超过 3 年前
Locally, docker compose will spin up N mysql instances and relevant services under test. Makefiles or bin scripts init things and run tests. Some teams have seed scripts or a snapshot of some sql state they want. When you run local integration tests, data is cleared&#x2F;reset.<p>We use buildkite for CI&#x2F;CD. It runs the same docker compose stuff as we do locally. It runs unit and acceptance tests. If green, it will auto deploy to our k8s staging cluster (though it worked similar when it deployed to vms). If staging is green, it can auto promote to a canary node in prod, and, depending on team set up, w ill auto roll out or allow manual gating for any additional QA. Version numbers are auto bumped by some internal tooling tied into the build system.<p>When we push to stage, the staging env has db instances but they are usually 1-2 nodes where in prod we will have more (3-30 nodes or more depending on the service). In staging, we run a suit of tests that exercise the end user experience. We also regularly run a slimmed down version of those tests in prod.<p>When it comes to unit tests, most of our teams do not mock the db. We use Go, and we will test by using test fakes - a struct that matches an interface is created in the test file and passed around. These tests validate error handling, log generation, sometimes metric generation, and, lastly, the happy path.<p>TL;DR - docker compose and scripts.
jguzmanjr超过 3 年前
We use sqx: <a href="https:&#x2F;&#x2F;github.com&#x2F;launchbadge&#x2F;sqlx" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;launchbadge&#x2F;sqlx</a>. The devs create and commit the up&#x2F;down migration files and the cicd runner runs the migrations against the db.
xs83超过 3 年前
IAC + Migrations is the easiest way:<p>IAC defines the database hardware + setup<p>Migrations make sure that the data you need to start with is in there and any changes are captured and applied on each deployment
allwein超过 3 年前
We use Fluent Migrator for out C# based applications.<p><a href="https:&#x2F;&#x2F;fluentmigrator.github.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;fluentmigrator.github.io&#x2F;</a>