Open simolus3 opened 2 months ago
hey, it disabled by purpose in libsql server - https://github.com/tursodatabase/libsql/blob/b769c6c/libsql/src/parser.rs#L155
let me find out why we have done this in the first place and if we can allow it
@simolus3 do you really this need though?
They don't recommend this:
This pragma is provided as a work-around for older programs that contain code that expect the incomplete behavior of ALTER TABLE RENAME found in older versions of SQLite. New applications should leave this flag turned off.
https://www.sqlite.org/pragma.html#pragma_legacy_alter_table
is foreign_keys=OFF
not enough: https://www.sqlite.org/lang_altertable.html#otheralter
So for context, I maintain a sqlite3 library for Dart that, among other things, offers help implementing the 12-step procedure suggested to emulate arbitrary ALTER TABLE
statements by re-creating tables and copying data over. As long as these steps as outlined there are followed in a transaction and legacy_alter_table
is only enabled as short as possible, it's not unsafe.
Without legacy_alter_table
, some structures like views would have to be destroyed and re-created manually as the schema is temporarily inconsistent during the 12 steps. I can change my code to do that and avoid legacy_alter_table
, but since this is a library, breaking migrations even in a very subtle way that some users may depend on is horrible. With support for legacy_alter_table
, I could support sqld & Turso much easier. I also understand that supporting legacy pragmas can be undesirable. If this feature is not supposed to be working, I'm happy to close this issue and find a way to work around this.
The
legacy_alter_table
pragma is required to reliably implement the suggested procedure for other kinds of schema changes without manually tracking views. Unfortunately, setting this pragma fails in Turso. I thought that this may perhaps be caused by compile-time options disabling legacy pragmas, but it's available inlibsql-sqlite3
:With a sqld build that should use the same sqlite3 build, it doesn't work: