Migrating from SQLite to PostgreSQL
bytebase.com
bytebase.com
This is sticking so hard to Sqlite, but it's really no longer true I think. Given WAL mode and tools like litestream, it's even feasible to run Sqlite in serverless offerings like Cloud Run. The schema change constraints are annoying though, even when there are known workarounds.
And, this is off topic, but Tailwind is really becoming the new Bootstrap. I open a page and it's instantly visible that this has been implemented with Tailwind (and often Tailwind UI).
https://github.com/mtlynch/logpaste/blob/master/docs/deploym...
The project started in 2021 Jan and I did notice litestream. And actually, one of the main reasons I chose SQLite is because of litestream. Because I could see it could be our HA solution when needing it.
SQLite is great, but the schema change constraint is really painful as you mentioned.
As to the Tailwind, as a backend engineer working on database for most of my 10+ career and single-handedly built the site, I can only say it's godsend;)
> Bytebase offers a web-based collaboration workspace to help DBAs and Developers manage the lifecycle of application database schemas.
So, I guess it’s not surprising you’d be annoyed by not being able to change schema constraints :)
if you go smaller, it does at certain sizes block a bit of the text.
tl;dr it doesn't look like the main graphic on your home page handles fluid layouts
EDIT: this goes with a few other graphics on the front page as well.
I also noticed some of your copy doesn't read well grammatically. "For Developer" I think reads better as "For Developers", as an example.
Only mentioning this cause this is a really cool concept that I wish I had thought of years ago when I worked more heavily with databases and want you to succeed! One of the reasons ORMs are "nice" is the built in schema migration of a lot of the most mature ones (coming from .NET and previously Django). This is a similar idea, but for teams that need high performance SQL optimizations to be able to change schema that may be written against "raw" SQL / Window functions etc.
I did try, but front-end development is harder for a database engineer...
Definitely could be improved here.
[0] https://github.com/bytebase/bytebase/tree/6a72eb630c604e2fe7...
edit: there is already sth like that https://github.com/fergusstrange/embedded-postgres
It's so, so nice, though, so I think it deserves its success.
I wonder if you could write a postgres shim layer to run your tests on a SQLite in-memory instance - though I guess you're at the whims of whatever that shim layer is doing matching actual postgres functionality bug for bug.
I'd be willing to launch a product on it in some circumstances, but depending highly on the resources, composition, goals, and risk tolerance of the team. I'm excited about where it's going but DB is so important and the alternatives are so well understood it still feels like a big move.
Clients -> Internet -> API -> sqlite
tailwind-typography is highly opinionated and "automatically applied", unlike Tailwind itself. I don't think that Tailwind will be quite as immediately visible outside of blogs....unless TailwindUI really takes off.
Unless you're really sensitive to colors, then you might notice the Tailwind gray
The real developer cost of "install postgres, createuser, createdb" is basically nothing.
I see the cost of ever using sqlite (coupling my tests/and/or app, migrating as soon as you have 2 users) as much higher.
Sqlite does seem like a safe, solid, and sane default for the embedded/fopen people though.
The transform CLI command (and Python method) automates the process of starting a transaction, creating a new table with the required changes, copying across the data from the old table, then dropping the old and renaming the new before committing the transaction.
Documentation here:
- Python library: https://sqlite-utils.datasette.io/en/stable/python-api.html#...
- CLI command: https://sqlite-utils.datasette.io/en/stable/cli.html#transfo...
- Blog entry: https://simonwillison.net/2020/Sep/23/sqlite-advanced-alter-...
https://www.2ndquadrant.com/en/blog/postgresql-10-identity-c...
And if any of your tables might grow beyond 2B rows, I'd use 64-bit IDs (serial8) from the start to avoid an expensive migration later.
https://www.2ndquadrant.com/en/blog/sequential-uuid-generato...
"I say we take off and nuke the whole sequence-generated id installation from orbit. It's the only way to be sure." – Ellen 'SQL' Ripley
The reason I do this is for testing. In fact, the SQLite backend is only compiled for test builds. With that, I can test my application logic against the SQLite implementation and be reasonably confident that things work with the PostgreSQL backend as well. And this is infinitely easier and faster than relying on a "real database server". No installation involved, and the same tests run in 300ms as opposed to 8+ seconds.
Yes, it's significantly more work to develop around these two implementations, but the benefits in build/test iteration times are immense. I haven't ever had to touch docker yet. And the abstraction layer also keeps me honest by forbidding me from poking into database internals.
If all you need is what SQLite can provide, go for it! It's lightning fast and astonishingly low overhead.
But other times you just need those event triggers and advanced indexing and range types and rollup and grouping sets and writable CTEs and lateral joins and materialized views and row-level security and…
These days, there's docker, so I see less point supporting multiple databases.
This is a relatively new introduction; v5.7 doesn't have any minimal packages.
For the same service how did RAM+CPU load change pre and post migration?
Many database engines, including SQL Server for instance, also support question marks. Surely PostgreSQL also supports this?
User.where("status = ?", "active").all
ActiveRecord itself sanitizes the input here and the query that's sent to Postgres does not use parameter markers at all.https://www.sqlite.org/lang_expr.html#varparam
So, changing "?" to "?1" could be done in SQLite before the actual migration, leaving just the change from ? to $ when migrating to Postgres.
I suppose they made that decision a long time ago.
In ecpg, prepared statements use ?: https://www.postgresql.org/docs/current/ecpg-commands.html#E...
UPD: I know it’s there, but the library version shipped with interpreters and compilers are often outdated
One thing the article doesn't mention is database unification. PostgreSQL is such a ubiquitous database, which enables us to keep a single database system for a long time.
[1] https://github.com/sebastianconcept/Mapless
[2] https://blog.sebastiansastre.co/article/mapless-is-online-ag...
I've contemplated building it to work on the other direction too but I haven't needed it myself yet so I've not done the work.
Example from the docs -
sequel -C mysql://host1/database postgres://host2/database2
or for Postgres > SQLite sequel -C postgres://host2/database2 sqlite://database.sqlite
and vice-versa sequel -C sqlite://database.sqlite postgres://host2/database2
[0]: https://sequel.jeremyevans.net[1]: https://github.com/jeremyevans/sequel
[2]: https://sequel.jeremyevans.net/rdoc/files/doc/bin_sequel_rdo...
e.g. https://github.com/J-Swift/cod-stats/blob/master/frontend/ge...