OPENBUS-3021 OPENBUS-2970 Correção para evitar o uso de colunas legacy no banco do core 2.1

O commit dd78f342 trouxe
desnecessariamente as colunas loginObserver.legacy e
login.allowLegacyDelegate.

Por enquanto não removi essas colunas da definição da tabela porque
assim podemos usar o banco do core 2.0 para rodar o core 2.1. Tornei
essas colunas NULLABLES. Quando for feito um código de conversão
poderemos remover tais colunas definitivamente.
parent 54db5955
......@@ -38,7 +38,7 @@ local SQL_create_tables = [[
id TEXT PRIMARY KEY,
entity TEXT NOT NULL,
encodedkey BLOB NOT NULL,
allowLegacyDelegate INTEGER NOT NULL
allowLegacyDelegate INTEGER
);
CREATE TABLE IF NOT EXISTS loginObserver (
......@@ -163,9 +163,9 @@ local actions = {
{ name="addSettings",
values = { "key", "value" } },
{ name="addLogin",
values = { "id", "entity", "encodedKey", "allowLegacyDelegate" } },
values = { "id", "entity", "encodedKey" } },
{ name="addLoginObserver",
values = { "id", "ior", "legacy", "login" } },
values = { "id", "ior", "login" } },
{ name="addWatchedLogin",
values = { "login_observer", "login" } },
{ name="addCertificate",
......
......@@ -4,10 +4,6 @@ local dblegacy = require "openbus.util.database_legacy"
local module = {}
local function bool2int(val)
return (val and 1) or 0
end
function module.convert(dblegacy, db)
db.conn:exec("BEGIN;")
local certificateDB = dblegacy:gettable("Certificates")
......@@ -24,14 +20,12 @@ function module.convert(dblegacy, db)
local loginsDB = dblegacy:gettable("Logins")
for id, data in loginsDB:ientries() do
assert(db:pexec("addLogin", id, data.entity, data.encodedkey,
bool2int(data.allowLegacyDelegate)))
assert(db:pexec("addLogin", id, data.entity, data.encodedkey))
end
local loginobsDB = dblegacy:gettable("LoginObservers")
for id, data in loginobsDB:ientries() do
assert(db:pexec("addLoginObserver", id, data.ior, bool2int(data.legacy),
data.login))
assert(db:pexec("addLoginObserver", id, data.ior, data.login))
for login in pairs(data.watched) do
assert(db:pexec("addWatchedLogin", id, login))
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment