Commit Graph

15 Commits

Author SHA1 Message Date
Tau
e95071822a sql: Add "maintenance transaction" system
SQLite's ALTER TABLE functionality leaves a lot to be desired, so
in practice the way you alter SQLite schema is to create a new
table, migrate the data into it, then drop the old table. However,
this is potentially complicated by the presence of foreign key
constraints.

In order to resolve the foreign key constraint issue we add a
`maintenance()` method to the `DataSource` abstraction layer. This
operates similarly to the existing `transaction()` method, but the
SQLite implementation of this method defers enforcement of foreign
keys until the transaction is about to commit.
2021-02-03 23:43:38 +00:00
Tau
c0516fdb33 sql: Drive-by method documentation 2021-02-03 23:43:38 +00:00
Tau
cc2b816c3c sql: Throw conventionally... 2021-02-03 23:43:38 +00:00
Tau
6947912dfc
sql: Add NULL support to database wrappers 2020-03-22 22:38:54 +00:00
Tau
b69f86f203 Switch to @decafcode/sqlite for database access 2020-01-05 10:00:12 -05:00
Tau
beb9144e9b sql/util.ts: Add a simple SQL record mapper
sql-bricks can write queries for us, and the mapper handles type
conversions to and from SQL-friendly strings.
2019-11-06 17:29:07 -05:00
Tau
125e4d8ca7 sql/sqlite.ts: Fix NULL handling 2019-11-06 17:29:07 -05:00
Tau
6a4ac795b2 Heal the layer break around the Id<> type 2019-11-06 17:29:07 -05:00
Tau
3aee0f611c sql/sqlite.ts: Make FK constraints do something
They don't by default, because they didn't in older versions of
SQLite and some older applications might rely on that. You have to
send an explicit pragma prior to opening a transaction to make them
take effect.
2019-11-06 17:29:07 -05:00
Tau
151dd41e64 sql: Add db compaction method 2019-11-06 17:28:31 -05:00
Tau
13e234a68c sql: Add raw SQL interface method 2019-11-06 17:28:31 -05:00
Tau
f348feff62 sql/sqlite.ts: Fix type check 2019-11-06 17:28:30 -05:00
Tau
072d70b42a Migrate to SQLite3
We'll keep the door open for side-by-side support of Postgres in
the background, but due to SQLite's type system quirks we cannot
use the same DDL for both databases, so we would have to maintain
two sets of DDL (schema init and schema migration scripts) at once.

Interested future contributors can shoulder this maintenance burden
if they so choose.
2019-11-06 17:28:30 -05:00
Tau
f9970fa81c Force explicit conversion of rows fetched from SQL DB
Everything is a scalar value now, and while this does involve more
boilerplate it will also catch type conversion issues like
"1" + 0 === "10" in the future.
2019-11-06 17:28:30 -05:00
Tau
3e6b4f4798 Add an SQL DB abstraction layer
Because what self-respecting Enterprise(R) project doesn't have
one of those?
2019-11-06 17:28:30 -05:00