Skip to content

fix: remove logic about schedule deletion - #95

Merged
danfimov merged 5 commits into
danfimov:mainfrom
SnakeOilSalesman:keep-schedules
Nov 29, 2026
Merged

danfimov merged 5 commits into
danfimov:mainfrom
SnakeOilSalesman:keep-schedules

Conversation

@SnakeOilSalesman

Copy link
Copy Markdown
Contributor

By default every startup the schedule source deletes all stored schedules and re-creates them from schedules declared in broker tasks, so schedules added at runtime (via add_schedule) are lost on restart.

This PR adds a keep_schedules: bool = False flag to all schedule sources (asyncpg, psqlpy, psycopg, aiopg). When True, startup only ensures the table exists and keeps all previously stored schedules as they are.

  • flag added to the base class and explicitly exposed in all driver __init__s (including overloads and docstrings)
  • integration tests for both modes on all four drivers
  • docs section in docs/tutorial/schedule_source.md

All checks pass: ruff, mypy, full test suite (278 tests).

If True, startup no longer deletes and re-creates schedules from broker tasks, so schedules added in a previous run are kept.
@danfimov

danfimov commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

@SnakeOilSalesman
I have an old issue about that: #65

I think we should completely remove the logic for finding schedules by label. There’s another source that should do that - LabelScheduleSource.

And, consequently, we should simply never delete any schedules that are already in the database. Because people mostly use postgres schedule source for dynamic scheduls that should live through an app restarts.

Maybe we can implement this logic in this MR?

@SnakeOilSalesman

SnakeOilSalesman commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

@SnakeOilSalesman I have an old issue about that: #65

I think we should completely remove the logic for finding schedules by label. There’s another source that should do that - LabelScheduleSource.

And, consequently, we should simply never delete any schedules that are already in the database. Because people mostly use postgres schedule source for dynamic scheduls that should live through an app restarts.

Maybe we can implement this logic in this MR?

Sure, I'll take a look into it and will get back soon.

@SnakeOilSalesman

SnakeOilSalesman commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

@danfimov I pushed the changes. Do I get your idea right?
Let me know if there is anything else I can do to push this thing closer to master)

BTW, I noticed, that you haven't been updating version field in pyroject.toml. Just wanted to inform you.

@danfimov danfimov linked an issue Nov 28, 2026 that may be closed by this pull request
@danfimov

Copy link
Copy Markdown
Owner

Looks good
Thank you for contribution

@danfimov danfimov changed the title feat: add keep_schedules flag to schedule sources fix: remove logic about schedule deletion Nov 29, 2026
@danfimov
danfimov merged commit 99b1dba into danfimov:main Nov 29, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schedule source shouldn't delete existing schedules during startup

2 participants