<p>I want to credit Max N for making me think about another solution.</p>
<p>In fact I already have the solution, right in front of me. We're a Gradle shop, and our <code>build.gradle</code> files contains our dependencies. So when I release a version, I know exactly what services+versions I need for this version. Since we have branches corresponding to our environments, I the services I need in each environment. So when I just need to</p>
<ul>
<li>I need to Git tag every time we do a build, including the tools that did the build</li>
<li>When deploying, I then need to deploy above tag, which includes code + tools</li>
</ul>
<p>Thanks again Max N.</p>

CC BY-SA 4.0
2021-01-30T17:45:53.590Z
I'm here to help!
Max N
CC BY-SA 4.0
2021-01-29T15:24:57.943Z
2021-01-29T15:24:57.943Z
Chris F
<p>Have you thought about what happen with stale/old data??</p>
<ul>
<li>Each new version creates a ton of new entries.</li>
<li>Management becomes a nightmare</li>
<li>the DB becomes a SPOF(single point of failure).</li>
</ul>
<hr />
<h1>Better Solution: Service discovery</h1>
<p>The better solution would be to use a Service discovery System and annote each Service with their version and the environment as a Metadata tag. This keeps the System more manageble.</p>
<h1>More Help</h1>
<p>IMHO, sticking Linux Code into a <strong>Docker Image</strong> and run multiple copies of it, is the best way of getting a immutable infrastructure up and running.</p>

CC BY-SA 4.0
2021-01-28T17:54:39.863Z
Thanks for the suggestion, I'll look into that. Anything to simplify our release/versioning system will be good.
Chris F
CC BY-SA 4.0
2021-01-28T18:11:04.397Z
I mean, how is the linux kernel packaged? In linux, a kernel version has a set of packages (and their versions) it needs correct? I guess I'm after something like that, or even like Gem for Ruby, or brew on a Mac.
Chris F
CC BY-SA 4.0
2021-01-30T17:42:13.837Z
Kernel and User package are two different things. You could use Docker images.
Max N
CC BY-SA 4.0
2021-01-28T11:47:30.203Z
2021-01-30T17:45:18.253Z
2021-01-30T17:45:18.253Z
Max N
<p>I want to create a schema that reflects the following relationships, and I'm trying to do this in MySQL Workbench. (I'm no DB expert)</p>
<ul>
<li>I have 3 environments - sandbox, staging, and production</li>
<li>I release a product version in each environment, e.g., <code>sb-1.0.0</code> for sandbox, <code>st-1.0.0</code> for staging, and <code>pr-1.0.0</code> for production. I can have multiple releases per environment, but there can only be ONE version that's currently released in each environment.</li>
<li>Each product version in each environment contains a set of services, same set of services in all the environments, but differing in their version numbers. So <code>sb-1.0.0 = [svc1-2.0.0, svc2-2.0.0], st-1.0.0 = [svc1-1.0.0, svc2-2.0.0], and pr-1.0.0 = [svc1-1.0.0, svc2-1.0.0]</code>. As you can see, I have the same 2 services in all environments, but the service versions can be different (or the same) in each  environment.</li>
</ul>
<p>I want to accomplish multiple things.</p>
<ul>
<li>I want to be able to create new releases in each environment, with each release containing the set of services and corresponding versions. So I want to be able to create a <code>pr-2.0.0 = [svc1-2.0.0, svc2-1.0.0]</code> version.</li>
<li>I want to be able to query my DB for version <code>pr-1.0.0</code> and know all the services and their respective versions in this particular release.</li>
<li>I want to have the notion of a &quot;current version&quot; and a &quot;desired version&quot; for each service in each environment.</li>
<li>I want to be be able to then run a script (Kubernetes?) to release each service and their respective version based on the query.</li>
<li>I want to be able to extend it to more environments, e.g., add a UAT environment.</li>
</ul>
<p>So how do I model my DB?</p>

<databases><mysql>
How can I model this schema in MySQL?
Chris F
# How can I model this schema in MySQL?

(Asked by: username_0 on 2021-01-27)

I want to create a schema that reflects the following relationships, and I'm trying to do this in MySQL Workbench. (I'm no DB expert)

* I have 3 environments - sandbox, staging, and production
* I release a product version in each environment, e.g., `sb-1.0.0` for sandbox, `st-1.0.0` for staging, and `pr-1.0.0` for production. I can have multiple releases per environment, but there can only be ONE version that's currently released in each environment.
* Each product version in each environment contains a set of services, same set of services in all the environments, but differing in their version numbers. So `sb-1.0.0 = [svc1-2.0.0, svc2-2.0.0], st-1.0.0 = [svc1-1.0.0, svc2-2.0.0], and pr-1.0.0 = [svc1-1.0.0, svc2-1.0.0]`. As you can see, I have the same 2 services in all environments, but the service versions can be different (or the same) in each environment.

I want to accomplish multiple things.

* I want to be able to create new releases in each environment, with each release containing the set of services and corresponding versions. So I want to be able to create a `pr-2.0.0 = [svc1-2.0.0, svc2-1.0.0]` version.
* I want to be able to query my DB for version `pr-1.0.0` and know all the services and their respective versions in this particular release.
* I want to have the notion of a "current version" and a "desired version" for each service in each environment.
* I want to be be able to then run a script (Kubernetes?) to release each service and their respective version based on the query.
* I want to be able to extend it to more environments, e.g., add a UAT environment.

So how do I model my DB?

**Tags:** databases, mysql


---

## 2 answers

### Answer by username_0 on 2021-01-29. Score: 0 | Accepted answer

I want to credit username_1 for making me think about another solution.

In fact I already have the solution, right in front of me. We're a Gradle shop, and our `build.gradle` files contains our dependencies. So when I release a version, I know exactly what services+versions I need for this version. Since we have branches corresponding to our environments, I the services I need in each environment. So when I just need to

* I need to Git tag every time we do a build, including the tools that did the build
* When deploying, I then need to deploy above tag, which includes code + tools

Thanks again username_1.

> **Comments:**
> **username_1**: I'm here to help!  

---

### Answer by username_1 on 2021-01-28. Score: 1

Have you thought about what happen with stale/old data??

* Each new version creates a ton of new entries.
* Management becomes a nightmare
* the DB becomes a SPOF(single point of failure).

---

# Better Solution: Service discovery

The better solution would be to use a Service discovery System and annote each Service with their version and the environment as a Metadata tag. This keeps the System more manageble.

# More Help

IMHO, sticking Linux Code into a **Docker Image** and run multiple copies of it, is the best way of getting a immutable infrastructure up and running.

> **Comments:**
> **username_0**: Thanks for the suggestion, I'll look into that. Anything to simplify our release/versioning system will be good.  
> **username_0**: I mean, how is the linux kernel packaged? In linux, a kernel version has a set of packages (and their versions) it needs correct? I guess I'm after something like that, or even like Gem for Ruby, or brew on a Mac.  
> **username_1**: Kernel and User package are two different things. You could use Docker images.  

---

