@langchain/langgraph-checkpoint-postgres
Version:
49 lines • 1.77 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMigrations = void 0;
const sql_js_1 = require("./sql.cjs");
/**
* To add a new migration, add a new string to the list returned by the getMigrations function.
* The position of the migration in the list is the version number.
*/
const getMigrations = (schema) => {
const SCHEMA_TABLES = (0, sql_js_1.getTablesWithSchema)(schema);
return [
`CREATE TABLE IF NOT EXISTS ${SCHEMA_TABLES.checkpoint_migrations} (
v INTEGER PRIMARY KEY
);`,
`CREATE TABLE IF NOT EXISTS ${SCHEMA_TABLES.checkpoints} (
thread_id TEXT NOT NULL,
checkpoint_ns TEXT NOT NULL DEFAULT '',
checkpoint_id TEXT NOT NULL,
parent_checkpoint_id TEXT,
type TEXT,
checkpoint JSONB NOT NULL,
metadata JSONB NOT NULL DEFAULT '{}',
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id)
);`,
`CREATE TABLE IF NOT EXISTS ${SCHEMA_TABLES.checkpoint_blobs} (
thread_id TEXT NOT NULL,
checkpoint_ns TEXT NOT NULL DEFAULT '',
channel TEXT NOT NULL,
version TEXT NOT NULL,
type TEXT NOT NULL,
blob BYTEA,
PRIMARY KEY (thread_id, checkpoint_ns, channel, version)
);`,
`CREATE TABLE IF NOT EXISTS ${SCHEMA_TABLES.checkpoint_writes} (
thread_id TEXT NOT NULL,
checkpoint_ns TEXT NOT NULL DEFAULT '',
checkpoint_id TEXT NOT NULL,
task_id TEXT NOT NULL,
idx INTEGER NOT NULL,
channel TEXT NOT NULL,
type TEXT,
blob BYTEA NOT NULL,
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id, task_id, idx)
);`,
`ALTER TABLE ${SCHEMA_TABLES.checkpoint_blobs} ALTER COLUMN blob DROP not null;`,
];
};
exports.getMigrations = getMigrations;
//# sourceMappingURL=migrations.js.map
;