File tree Expand file tree Collapse file tree 5 files changed +37
-4
lines changed
generators/queue_classic/templates Expand file tree Collapse file tree 5 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 11Unreleased
22- Fixed a bug in the offset calculation of `.enqueue_at`.
3+ - Use jsonb type for the args column, if available. Otherwise fall back to
4+ json type or keep using text. Also added a migration to update old schemas.
35
46Version 3.0.0rc
57- Improved signal handling
Original file line number Diff line number Diff line change 1+ class UpdateQueueClassic320 < ActiveRecord ::Migration
2+ def self . up
3+ QC ::Setup . update_to_3_2_0
4+ end
5+
6+ def self . down
7+ end
8+ end
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ module Setup
88 DowngradeFrom_3_0_0 = File . join ( Root , "/sql/downgrade_from_3_0_0.sql" )
99 UpgradeTo_3_1_0 = File . join ( Root , "/sql/update_to_3_1_0.sql" )
1010 DowngradeFrom_3_1_0 = File . join ( Root , "/sql/downgrade_from_3_1_0.sql" )
11+ UpgradeTo_3_2_0 = File . join ( Root , "/sql/update_to_3_2_0.sql" )
1112
1213 def self . create ( c = QC ::default_conn_adapter . connection )
1314 conn = QC ::ConnAdapter . new ( c )
@@ -27,6 +28,7 @@ def self.update(c = QC::default_conn_adapter.connection)
2728 conn = QC ::ConnAdapter . new ( c )
2829 conn . execute ( File . read ( UpgradeTo_3_0_0 ) )
2930 conn . execute ( File . read ( UpgradeTo_3_1_0 ) )
31+ conn . execute ( File . read ( UpgradeTo_3_2_0 ) )
3032 conn . execute ( File . read ( DropSqlFunctions ) )
3133 conn . execute ( File . read ( SqlFunctions ) )
3234 end
@@ -54,5 +56,10 @@ def self.downgrade_from_3_1_0(c = QC::default_conn_adapter.connection)
5456 conn = QC ::ConnAdapter . new ( c )
5557 conn . execute ( File . read ( DowngradeFrom_3_1_0 ) )
5658 end
59+
60+ def self . update_to_3_2_0 ( c = QC ::default_conn_adapter . connection )
61+ conn = QC ::ConnAdapter . new ( c )
62+ conn . execute ( File . read ( UpgradeTo_3_2_0 ) )
63+ end
5764 end
5865end
Original file line number Diff line number Diff line change @@ -11,10 +11,12 @@ CREATE TABLE queue_classic_jobs (
1111 scheduled_at timestamptz default now()
1212);
1313
14- -- If json type is available, use it for the args column.
15- perform * from pg_type where typname = ' json' ;
16- if found then
17- alter table queue_classic_jobs alter column args type json using (args::json);
14+ -- If jsonb type is available, use it for the args column
15+ if exists (select 1 from pg_type where typname = ' jsonb' ) then
16+ alter table queue_classic_jobs alter column args type jsonb using args::jsonb;
17+ -- Otherwise, use json type for the args column if available
18+ elsif exists (select 1 from pg_type where typname = ' json' ) then
19+ alter table queue_classic_jobs alter column args type json using args::json;
1820end if;
1921
2022end $$ language plpgsql;
Original file line number Diff line number Diff line change 1+ do $$ begin
2+
3+ -- If jsonb type is available, use it for the args column
4+ if exists (select 1 from pg_type where typname = ' jsonb' ) then
5+ alter table queue_classic_jobs alter column args type jsonb using args::jsonb;
6+ -- Otherwise, use json type for the args column if available
7+ elsif exists (select 1 from pg_type where typname = ' json' ) then
8+ alter table queue_classic_jobs alter column args type json using args::json;
9+ -- Keep using text type for the args column, if neither is available
10+ else
11+ alter table queue_classic_jobs alter column args type text using args::text ;
12+ end if;
13+
14+ end $$ language plpgsql;
You can’t perform that action at this time.
0 commit comments