4.1 C
New York
Wednesday, December 4, 2024

Database Setup So Easy Your Cat Could Do It: Docker and Flyway Edition | Blog | bol.com


Image source

Okay, folks, unless you’re one of those rare people who has a cool cat who can program (and if you are, we need to talk), setting up a local database can seem like a daunting task. Fear not! Stevedore and Migratory routeIt’s so simple that even your cat could do it – well, in theory. Let’s dig into it!

Needful

If an application uses a database for persistence, it will need one that it can connect to locally to run itself or its (integration) tests. The question is, what is a database? convenient and efficient What is the way to configure a database like that?

Ideally you would have a database configured that:

  • Only used locally
  • It has the same schema and data every time.
  • It can be built and destroyed whenever we want.
  • It’s easy to recreate it every time

Let’s take a closer look at these statements:

Only used locally

It is important that the tasks we perform in local development do not affect our other environments (such as staging or production). Data for each environment should come only from that environment to avoid contamination and possible confusion.

It has the same schema and data every time

The local database should be a reliable representation of our real database. The code expects a certain state and we must ensure that it will encounter it every time our database is created. Otherwise, we can end up with anything from compilation errors to faulty tests.

It can be built and dismantled whenever you want.

The more control we have over this, the more interesting things we can do. How great would it be if we could easily start configuration before a build and then break it down? And how great would it be if we could easily start configuration before a build and then break it down? More pleasant would it be like that if that were the case? automatically passing by just running the build?

Easy to recreate every time

The easier it is to recreate, the more likely we are to use it. I’m sure many of us have had the experience of avoiding running. That terrible application locally because it’s too much hassle.

Now, I wish there was a configuration that could guarantee all of the above…

Related Articles

Latest Articles