eliza icon indicating copy to clipboard operation
eliza copied to clipboard

Postgres Adapter schema check is nonsensical

Open ryanleecode opened this issue 1 year ago • 0 comments

Describe the bug

The following check is nonsensical because we already do IF NOT EXIST checks within the sql. If one of the tables were dropped, say for example the memories table because we want to change the vector dimensions, it wouldn't be recreated due to this check.

// Check if schema already exists (check for a core table)
const { rows } = await client.query(`
    SELECT EXISTS (
        SELECT FROM information_schema.tables
        WHERE table_name = 'rooms'
    );
`);


if (!rows[0].exists) {
    const schema = fs.readFileSync(
        path.resolve(__dirname, "../schema.sql"),
        "utf8"
    );
    await client.query(schema);
}

https://github.com/elizaOS/eliza/blob/4c658d7d70433fdcb2feeffe879429eaef10685d/packages/adapter-postgres/src/index.ts#L192C13-L206C14

To Reproduce

Expected behavior

Screenshots

Additional context

ryanleecode avatar Dec 22 '24 18:12 ryanleecode