feat(server): add SQLite KV store exposed as $kv in script sandbox

Co-authored-by: Nasyarobby Putra <nasyarobby@gmail.com>
This commit is contained in:
Cursor Agent
2026-08-14 11:11:17 +00:00
co-authored by nsrb
parent 8519c92ed1
commit b88dd4d6e7
4 changed files with 404 additions and 0 deletions
@@ -0,0 +1,24 @@
/**
* @param {import("knex").Knex} knex
*/
export async function up(knex) {
await knex.schema.createTable("script_state", (t) => {
t.text("namespace").notNullable();
t.text("key").notNullable();
t.text("value").notNullable();
t.text("updated_at").notNullable();
t.text("expires_at");
t.primary(["namespace", "key"]);
});
await knex.schema.raw(
"CREATE INDEX script_state_namespace_updated_at_idx ON script_state (namespace, updated_at DESC)",
);
}
/**
* @param {import("knex").Knex} knex
*/
export async function down(knex) {
await knex.schema.dropTableIfExists("script_state");
}