-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove scheduled_jobs.resource_id
Use SQLite JSON functions to extract needed informations.
- Loading branch information
Showing
13 changed files
with
79 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 28 additions & 3 deletions
31
pkg/bus/sqlite/migrations/1727345059_nullable_policy.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
ALTER TABLE scheduled_jobs DROP COLUMN policy; | ||
CREATE TEMP TABLE tmp_scheduled_jobs AS | ||
SELECT * FROM scheduled_jobs; | ||
|
||
-- Make the policy column nullable since it's not used anymore. | ||
DROP TABLE scheduled_jobs; | ||
|
||
-- Make the policy and resource_id columns nullable since it's not used anymore. | ||
-- Since migrations are executed by domain orders (scheduler, auth, deployment) and | ||
-- I have failed by making deployment rely on the scheduled_jobs table, I must keep | ||
-- it or else I have to update the migration (which I think is worse). | ||
ALTER TABLE scheduled_jobs ADD policy INTEGER NULL; | ||
CREATE TABLE scheduled_jobs | ||
( | ||
id TEXT NOT NULL, | ||
resource_id TEXT NULL, | ||
[group] TEXT NOT NULL, | ||
message_name TEXT NOT NULL, | ||
message_data JSON NOT NULL, | ||
queued_at DATETIME NOT NULL, | ||
not_before DATETIME NOT NULL, | ||
policy INTEGER NULL, | ||
errcode TEXT NULL, | ||
retrieved BOOLEAN NOT NULL DEFAULT false, | ||
|
||
CONSTRAINT pk_scheduled_jobs PRIMARY KEY(id) | ||
); | ||
|
||
INSERT INTO scheduled_jobs | ||
SELECT * FROM tmp_scheduled_jobs; | ||
|
||
CREATE INDEX idx_scheduled_jobs_group ON scheduled_jobs([group]); | ||
CREATE INDEX idx_scheduled_jobs_message_name ON scheduled_jobs(message_name); | ||
|
||
DROP TABLE tmp_scheduled_jobs; |