smr/tools/migrate/main.lua

23 lines
653 B
Lua

local argparse = require("argparse")
local sql = require("lsqlite3")
local parser = argparse(){
name = "tools/migrate/main.lua",
description = "Perform database migrations",
epilog = "Other tools included in the smr source distribution include:accounts,archive",
}
parser:help_max_width(80)
parser:option("-d --database","The database file","kore_chroot/data/posts.db")
args = parser:parse()
local db,err,errmsg = sql.open(args.database, sql.OPEN_READWRITE)
if not db then
error(string.format("Failed to open %s : %s",args.database,errmsg))
end
--Unlisted pastes update
local db:exec([[
UPDATE posts SET hash=randomblob(64) WHERE hash = -1;
]])