Bladeren bron

foreign_keys must be enabled OUTSIDE of a transaction

default_compile_flags
vector-of-bool 4 jaren geleden
bovenliggende
commit
5f57cca29e
2 gewijzigde bestanden met toevoegingen van 4 en 2 verwijderingen
  1. +2
    -1
      src/dds/catalog/catalog.cpp
  2. +2
    -1
      src/dds/db/database.cpp

+ 2
- 1
src/dds/catalog/catalog.cpp Bestand weergeven

@@ -247,13 +247,14 @@ void store_init_packages(nsql::database& db, nsql::statement_cache& st_cache) {
}

void ensure_migrated(nsql::database& db) {
nsql::transaction_guard tr{db};
db.exec(R"(
PRAGMA foreign_keys = 1;
CREATE TABLE IF NOT EXISTS dds_cat_meta AS
WITH init(meta) AS (VALUES ('{"version": 0}'))
SELECT * FROM init;
)");
nsql::transaction_guard tr{db};

auto meta_st = db.prepare("SELECT meta FROM dds_cat_meta");
auto [meta_json] = nsql::unpack_single<std::string>(meta_st);


+ 2
- 1
src/dds/db/database.cpp Bestand weergeven

@@ -52,13 +52,14 @@ void migrate_1(nsql::database& db) {
}

void ensure_migrated(nsql::database& db) {
nsql::transaction_guard tr{db};
db.exec(R"(
PRAGMA foreign_keys = 1;
CREATE TABLE IF NOT EXISTS dds_meta AS
WITH init (meta) AS (VALUES ('{"version": 0}'))
SELECT * FROM init;
)");
nsql::transaction_guard tr{db};

auto meta_st = db.prepare("SELECT meta FROM dds_meta");
auto [meta_json] = nsql::unpack_single<std::string>(meta_st);


Laden…
Annuleren
Opslaan