Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
fabianlindfors
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
13 ms
·
91.
▲
by
fabianlindfors
5y ago
Yes, good note! I highly appreciate anybody willing to experiment with Reshape to help make it production ready :)
92.
▲
by
fabianlindfors
5y ago
> I'm not very familiar with PostgreSQL, how do you handle the casts during inserts/updates? In the example, you can see "up" and "down" settings on the migration. These are SQL expressions which specify how
93.
▲
by
fabianlindfors
5y ago
They are used all the time. If you ever find some examples of this, I'd be really interested to see them. Reshape only uses simple, updatable views [0] which hopefully means it won't struggle with finding indices. [0] https:/
94.
▲
by
fabianlindfors
5y ago
> We have migrated a few fields from varchar to integer. How would your solution deal with this There is actually an example in the README on how to change a column from TEXT to INTEGER, the technique would be the same the other way arou
95.
▲
by
fabianlindfors
5y ago
That's a really nice solution, I especially like the concept of versioning the read-only schema. There is a way to rollback after you have started a migration with `reshape abort`. This stops the migration which is currently in progres
96.
▲
by
fabianlindfors
5y ago
That's really cool, thanks for sharing! I've also considered using shadow tables but haven't needed them yet. Might change in the future. I really like how your solution allows one to user regular DDL statements and not some
97.
▲
by
fabianlindfors
5y ago
It's a very interesting topic! If you have time to test it out, I'd appreciate hearing about any bugs you find or feedback you might have :)
98.
▲
by
fabianlindfors
5y ago
That's a great question. I don't anticipate the view part being very limiting, Postgres seems to have great support for updatable views which means they should be able to transparently take the place of tables in most situations.
99.
▲
by
fabianlindfors
5y ago
Thank you!
100.
▲
by
fabianlindfors
5y ago
The old schemas will be automatically dropped when the migration is completed. So there will ever only be either one schema (current migration) or two during a deploy. I'm not sure what you mean by maintainability and performance. It&#
101.
▲
by
fabianlindfors
5y ago
Your situation sounds just like what I have in mind for Reshape to fix! The backfills performed by Reshape are automatically done in batches to avoid locking. As you said, Reshape can't call code outside the database as it relies on tr
102.
▲
by
fabianlindfors
5y ago
Actually, no! That's because from the perspective of the view, it's simply directly referencing a table and some columns, it doesn't handle any of the updating. What Reshape does is that it sets up triggers for the underlying
103.
▲
by
fabianlindfors
5y ago
Postgres has something called updatable views so INSERTs, UPDATEs, DELETEs can be made against views just as if they were actual tables. For the example in the post, they work differently depending on if the insert is made against the new o
104.
▲
by
fabianlindfors
5y ago
Hi! Most migration tools I have seen simply run the SQL needed to perform the update directly. This causes trouble during deploys as there will inevitably be some downtime between applying the migration and rolling out the application chang
105.
▲
Zero-downtime schema migrations in Postgres using Reshape
(fabianlindfors.se)
177 points
by
fabianlindfors
5y ago
|
34 comments
106.
▲
by
fabianlindfors
5y ago
The idea is not for all the different versions to be permanent, just temporary while the clients are being updated. Check out the top-level comment I wrote for a more fleshed our explanation!
107.
▲
by
fabianlindfors
5y ago
Author here, thanks for reading. As has been mentioned in some comments, the article only covers half the story of how this can be used for migrations. The greater idea is to have every commit be short-lived and two-phased: apply and cleanu
108.
▲
by
fabianlindfors
5y ago
Yes, this approach might actually decrease the power of your database as some things become much trickier. It might be worth trading of some expressive power of the database for smoother, less hands-on migrations though, which is what I
109.
▲
by
fabianlindfors
5y ago
You're right that the article doesn't mention how this can actually be practically used for migrations, but that is exactly what I had in mind. Maybe I'll write another one some day about the two-phase migrations combined wit
110.
▲
by
fabianlindfors
5y ago
With this model, migrations would be two-stepped. First the migration would be applied, creating a new schema and adding the new information to the underlying table. Once the version is old and no longer used by any clients, the migration w
111.
▲
by
fabianlindfors
5y ago
This is precisely the way I was imagining! I'm experimenting with creating a migration tool which will do this fully automatically.
112.
▲
by
fabianlindfors
5y ago
This is definitely a valid concern. My plan for building migrations on top of this is to have older migrations automatically be deleted as they become unused. Preferably you wouldn't actually keep using the old schemas but rather keep
113.
▲
by
fabianlindfors
5y ago
I think you hit the nail on the head regarding complexity. I'm experimenting with creating a migration tool which handles all the views for you. I believe some of the process can be automated and the complexity reduced but remains to b
114.
▲
by
fabianlindfors
5y ago
Interesting link, thanks! It would be really nice if Postgres were to close that gap and make them fully equivalent (if that is even possible).
115.
▲
Zero-downtime schema migrations in Postgres using views
(fabianlindfors.se)
181 points
by
fabianlindfors
5y ago
|
54 comments
116.
▲
Native GPU Virtualization in macOS Big Sur
(developer.apple.com)
3 points
by
fabianlindfors
6y ago
|
0 comments
117.
▲
by
fabianlindfors
6y ago
Totally understand! In my mind, it doesn't end at social networks. There are so many applications which become better with trust, like dating apps, product reviews, and online marketplaces.
118.
▲
by
fabianlindfors
6y ago
I think I have seen a startup doing exactly this here in Sweden, can't remember their name though. We have a well-established e-ID which makes the verification part dead simple. I'm working on bringing e-IDs to more people which w
119.
▲
by
fabianlindfors
6y ago
> Is the plan that a single entity offering this centralized product will control not just which users are allowed to have identities, but which companies are allowed to access users' IDs? Presumably there is a somewhat costly proce
120.
▲
by
fabianlindfors
6y ago
eIDAS is a great initiative but unfortunately I think it’s going to take a while before it becomes useful outside government. As you said, many countries don’t have well established e-IDs and that is what I’m trying to remedy. My main targe
More ›