zlacker

[parent] [thread] 9 comments
1. taffer+(OP)[view] [source] 2021-06-12 21:28:52
I never understood this point:

- You have a separate schema for your procs

- You define your procs in files

- You write tests for your procs

- You put your files into git

- Then, in a transaction, you drop your old schema and deploy the new one

replies(1): >>rantwa+Qh
2. rantwa+Qh[view] [source] 2021-06-13 00:31:43
>>taffer+(OP)
Do you have access to your production database?

How do you write tests? With what data are you testing?

How do you handle backwards compatibility? (For the code? For the data?)

Do you do this upgrade during deployment? Can you do blue/green deployments? What about canary deployments?

Is this transaction where you are dropping the old and creating the new part of the code or part of the database? (the actual code that does this)

How do you profile the performance of the said code?

replies(2): >>e_prox+VY >>taffer+m21
◧◩
3. e_prox+VY[view] [source] [discussion] 2021-06-13 10:21:23
>>rantwa+Qh
You have to solve these things with a job queue system written in any other language or using any other databases as backends too though.
replies(1): >>rantwa+2q2
◧◩
4. taffer+m21[view] [source] [discussion] 2021-06-13 11:07:08
>>rantwa+Qh
Have an automated process for deployment and a small number of people who have the keys to production deployment. Don't let developers manually change things in the production system or any system at all.

You can use pgtap to write automated unit tests. For profiling, there are explain, autoexplain, and plprofiler.

Blue/Green and Canary deployments are not currently possible with Postgres. On the other hand, Postres has transactional DDL, which means there is no downtime during code deployment and automatic rollback if something goes wrong.

The database is only for data and for stored procedures or functions, which are stored in separate schemas. Your deployment scripts, migration scripts, test scripts and everything else is not stored in the database, but in your source control system, e.g. Git.

For everything else, just use conventional software engineering practices. There is no reason to treat SQL code differently than Ruby or Java code.

replies(1): >>rantwa+Yp2
◧◩◪
5. rantwa+Yp2[view] [source] [discussion] 2021-06-13 21:50:22
>>taffer+m21
this reminds me about a show I saw at some point where someone had put a jet engine on a motorcycle. super dangerous but super fast. asked why they did this, the answer was: "because we can!!!"

seriously, you have the actual data, you have the store procedures and you have the code. Each has their own version. I have never seen this work in a production environment. It's possible that things evolved and there is better tooling since I last tried performing this stunt.

If it works for you that's great and maybe you should write some sort of blog post (do people still blog?) describing the setup and allowing others to either 1) replicate and use it 2) poke holes in it.

replies(2): >>taffer+4k3 >>taffer+zt3
◧◩◪
6. rantwa+2q2[view] [source] [discussion] 2021-06-13 21:50:52
>>e_prox+VY
no you don't. the queue system gives you a bunch of primitives and you build on top of them.
◧◩◪◨
7. taffer+4k3[view] [source] [discussion] 2021-06-14 07:56:23
>>rantwa+Yp2
> seriously, you have the actual data, you have the store procedures and you have the code. Each has their own version. I have never seen this work in a production environment.

How do you handle this in other languages?

replies(1): >>rantwa+ID4
◧◩◪◨
8. taffer+zt3[view] [source] [discussion] 2021-06-14 10:06:36
>>rantwa+Yp2
> this reminds me about a show I saw at some point where someone had put a jet engine on a motorcycle. super dangerous but super fast. asked why they did this, the answer was: "because we can!!!"

How does this nonsense add anything to the discussion?

◧◩◪◨⬒
9. rantwa+ID4[view] [source] [discussion] 2021-06-14 17:30:31
>>taffer+4k3
yo don't have stored procedures. everything is done in the code. so you only have 2 things to worry about (the db schema and the code). you still have the problem of the schema versioning but you only have to worry about 2 things
replies(1): >>taffer+uq5
◧◩◪◨⬒⬓
10. taffer+uq5[view] [source] [discussion] 2021-06-14 21:18:47
>>rantwa+ID4
Now you have your answer: Just instead of deploying to an app server you deploy to your db server. Yet for some reason people forget everything they have learned once the term SQL comes up.
[go to top]