timgit / pg-boss

Queueing jobs in Postgres from Node.js like a boss
MIT License
2.04k stars 157 forks source link

More "If not exists" in plans #155

Closed leventov closed 4 years ago

leventov commented 4 years ago

When I dropped pg-boss's tables manually (but didn't drop pgboss.job_state type nor the pgboss schema - I've missed that) it stopped working silently.

Maybe plans.js could insert more IF NOT EXISTS syntax to make pgboss more robust against this. Alternatively, contractor.js may add some extra logging here: https://github.com/timgit/pg-boss/blob/master/src/contractor.js#L62 to indicate that the schema is corrupted, at least to make the error more intelligible.

timgit commented 4 years ago

I disagree with this, since pg-boss needs to make some assumptions about its schema in order to safely migrate it between versions. The usage docs state that you can uninstall everything from the database with a DROP SCHEMA statement. Since you were making manual changes outside the scope of install or uninstall, I think it's fair it failed in an unpredictable way.

The code you linked should have thrown an error message indicating the actual problem.